Perl 6 - the future is here, just unevenly distributed

IRC log for #perl6-dev, 2016-10-27

| Channels | #perl6-dev index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:13 japhb .oO( "Good night, Westley. Good work. Sleep well. I'll most likely kill you in the morning." )
01:04 MasterDuke currently Signature.$!count == Inf when there's a slurpy. however, that requires $!count to be a Mu in BOOTSTRAP.nqp because it could be an Int or a Num later. any reason we couldn't have it == -1 when there's a slurpy?
01:05 MasterDuke it would require a bunch of changes in code, but it looks like the only spectest that would break is "is (-> *@a { }).count, Inf, 'slurpy positional causes infinite count';  #OK not used"
01:09 vendethiel joined #perl6-dev
01:28 * viki likes Inf since it represents what the actual .count is
01:35 MasterDuke sure, and it's not like we're going to get a 10% performance improvement, but you also can't do anything with the Inf. using -1 could have almost the exact same meaning as a representation (i.e., so many args the count has overflowed)
01:38 viki What do you mean? You can compare against Inf like you would against a 4 or a 1. Having a -1 would require all user code to special-case against slurpies
01:38 viki m: say [1, 2, 3] <= Inf
01:38 camelia rakudo-moar a1fcee: OUTPUT«True␤»
01:38 viki there's no "almost" same meaning with Inf. It's exactly accurate. With -1 you're introducing a convention
01:40 FROGGS_ joined #perl6-dev
01:41 MasterDuke well, i wonder how much user code is actually checking the .count of signatures?
01:46 viki IMO that doesn't even matter. A design decision shouldn't be made for minor performance gains and design shouldn't have special cases just because X and not X+1 users use that feature at this moment in time.
01:46 viki Which spectest is that Inf in? 6.c-errata or master?
01:46 MasterDuke master
01:46 MasterDuke S06-signature/arity.t
01:49 ilbot3 joined #perl6-dev
01:49 Topic for #perl6-dev is now Perl 6 language and compiler development 2.0 | Logs at http://irclog.perlgeek.de/perl6-dev/today
01:49 MasterDuke i'm not pronouncing anything definite, but in general i don't think a "clever" design decision has to be kept (and paid for in (unmeasured so far) minor performance loss) if after 10+ years it turns out nobody is using it
01:49 MasterDuke and yeah, i was wondering about those also
01:50 viki fair nuf
01:55 MasterDuke not the most perfect of arguments, but a 'git grep "\.count.*Inf"' in moritz's perl6-all-modules returned nothing relevant
01:56 viki What about just .count?
01:57 viki I'm imagining cases like if $sig.count > 1 { this thing can take more than one arg.... } type of stuff
01:57 viki Or if .count <= 1. I think we even have such a thing in core, for meta ops
01:58 viki And such comparisons work naturally with an Inf, but special-casing it to -1 would break them.
01:58 MasterDuke there are a lot of .count, but none of them look like they're on a signature
01:58 viki In fact, IMO it'd make more sense to use (2**64-1) or whatever as a value, rather than -1 :)
01:58 MasterDuke oh, it would definitely require a bunch of changes in core
01:59 * viki goes to bed
01:59 viki \o
01:59 MasterDuke later...
02:00 viki But, since the Inf is in 6.c-errata we can't change it. It's our promise to the users.
02:01 MasterDuke that's something i don't actually understand thoroughly, the difference between master, 6.c-errata, etc.
02:05 MasterDuke fyi, there doesn't appear to be any comparisons that couldn't be relatively easily changed (i.e., no .count <= 0 to be worked around). mostly comparisons to 1 or Inf
02:08 viki Just in core. Considering the feature is already in use in core, "no one uses it anyway" is a poor argument. But my -1 on it is purely from logical point that -1 is directly opposite of reality a slurpy represents and any comparisons require specialcasing and if a programmer doesn't remember to do that specialcasing, they have a bug in their code.
02:13 viki 6.c roast is THE Perl 6 Language Version 6.c specification. We promise to users any release claiming to do 6.c passes that entire test suite. That's in theory, in practice tests have bugs or are outright wrong. Such cases are corrected in 6.c-errata branch. So it's still a 6.c language spec, sans errors. As for master, my view on it is that it's a work in progress to be eventually turned into a 6.d. It
02:13 viki represents the decisions we've made so far for how the compiler should work. It doesn't include any changes that would break 6.c, since the release must pass both master and 6.c-errata, but IMO as far as *changes* go, master is much more maleable, since we did not promise to users that all compilers will pass master at whatever state it is during the release. That leads to 6.d, and I'm fuzzy on the
02:13 viki details, but as I understand it, we *can* make changes that would not pass a 6.c spectest, but I'm unsure what severety is acceptable. I doubt many users would be happy if we make too drastic a change on each major release.
02:13 MasterDuke well, '.count == Inf' in core is trivially changed to '.count == -1', so i personally wouldn't weight that too highly. and i doubt there's much userland code dealing with the .count of signatures. but i am sensitive to not breaking promises
02:14 MasterDuke mostly playing devil's advocate here
02:14 MasterDuke wanting to be thoroughly persuaded either way
02:16 viki We have a list for 6.d changes too: https://github.com/perl6/specs/blob/master/v6d.pod
02:16 japhb Inf is as true as it can be, given the limited size of computers, whereas -1 is a lie.  It feels to me like C language thinking applied to a language that (at least where numbers are concerned) is decidedly un-C-like.
02:17 viki .count == Inf to me represents reality and works with > and < comparators. .count == -1 looks nonsensical, requires special knowledge, and opens a door for bugs. So far the only reasoning FOR -1 that I read is it would give us an unknown and likely tiny speed improvement. so *shrug* :)
02:17 japhb Part of the Perl 6 philosophy is to torture the implementor on behalf of the user, not the other way around (as very many languages do).
02:18 viki Yeah, it does remind me of C too. :)
02:18 * viki & # finally going to bed
02:18 japhb Good night, $user.  :-)
02:25 MasterDuke i am pretty much completely in favor of keeping it as is, but i think the discussion has been useful as far as bringing up solid arguments instead of just "this is the way it's always been"
04:19 MasterDuke in nqp, is there any difference between 'my $hash := nqp::hash()' and 'my %hash := nqp::hash()'?
05:50 RabidGravy joined #perl6-dev
06:21 [Tux] This is Rakudo version 2016.10-74-ga1fceeb built on MoarVM version 2016.10-15-g715e39a
06:21 [Tux] csv-ip5xs        3.143
06:21 [Tux] test            14.854
06:22 [Tux] test-t           6.778
06:22 [Tux] csv-parser      17.335
06:23 [Tux] Not by much, but this *is* a new low :) $ grep ' 6\.[0-7]' speed.log
06:23 [Tux] 2016-09-12 17:26:41 test-t 6.787
06:23 [Tux] 2016-09-15 13:10:01 test-t 6.796
06:23 [Tux] 2016-10-27 08:19:32 test-t 6.778
06:34 lizmat Files=1150, Tests=53692, 209 wallclock secs (12.54 usr  3.87 sys + 1278.46 cusr 120.72 csys = 1415.59 CPU)   # also a new low for me  :-)
07:03 arnsholt MasterDuke: Anbsolutely no difference!
07:04 arnsholt (Also, note that "my %hash" does the same thing as too)
07:04 arnsholt Also identical, "my @hash := nqp::hash()"
07:04 arnsholt O:)
07:05 timotimo don't forget that a %!foo will require you to := nqp::hash() or := {} if the class you're in has a BUILD
07:08 arnsholt Oh, didn't know that!
07:13 timotimo i ran into that a few days ago. only cost me like five minutes, though
07:17 arnsholt Yeah, I guess it wouldn't be the hardest thing to debug in NQP =)
07:18 timotimo yep
07:20 timotimo i've been interested in the serialized blob recently
08:26 pmurias joined #perl6-dev
09:04 dalek nqp: a6d6c2b | (Pawel Murias)++ | src/vm/js/Operations.nqp:
09:04 dalek nqp: [js] Fix the returning of natives by a try block that catches an exception.
09:04 dalek nqp: review: https://github.com/perl6/nqp/commit/a6d6c2b25d
09:04 dalek nqp: 07ad89c | (Pawel Murias)++ | t/nqp/044-try-catch.t:
09:04 dalek nqp: Test getting int and str return values from a try block that throws an exception.
09:04 dalek nqp: review: https://github.com/perl6/nqp/commit/07ad89c553
09:31 jnthn joined #perl6-dev
09:41 llfourn joined #perl6-dev
10:59 dalek rakudo/nom: 5ac593e | lizmat++ | src/core/Regex.pm:
10:59 dalek rakudo/nom: Make ~~ /foo/ and ~~ Regex:D work the same
10:59 dalek rakudo/nom:
10:59 dalek rakudo/nom: Spotted by labster++ .  So, '"foo" ~~ /foo/' returns the Match
10:59 dalek rakudo/nom: object and sets $/, whereas 'my $a = rx/foo/; "foo" ~~ $a' only
10:59 dalek rakudo/nom: returned True and did not set $/.
10:59 dalek rakudo/nom: review: https://github.com/rakudo/rakudo/commit/5ac593ee09
10:59 lizmat causes some spectest breakage, but the tests are too specific
11:01 dalek rakudo/js: 35ed92b | (Pawel Murias)++ | src/vm/js/Perl6/Ops.nqp:
11:01 dalek rakudo/js: [js] Implement nqp::p6trialbind.
11:01 dalek rakudo/js: review: https://github.com/rakudo/rakudo/commit/35ed92bc99
11:01 dalek roast: 40b8c3e | lizmat++ | S03-operators/relational.t:
11:01 dalek roast: Make chained regex test less specific
11:01 dalek roast:
11:01 dalek roast: To fix test breakage by 5ac593e
11:01 dalek roast: review: https://github.com/perl6/roast/commit/40b8c3ebf1
11:04 dalek roast/6.c-errata: 7525842 | lizmat++ | S03-operators/relational.t:
11:04 dalek roast/6.c-errata: Make chained regex test less specific
11:04 dalek roast/6.c-errata:
11:04 dalek roast/6.c-errata: To fix test breakage by 5ac593e
11:04 dalek roast/6.c-errata: review: https://github.com/perl6/roast/commit/7525842cdd
11:40 AlexDaniel joined #perl6-dev
12:18 dalek rakudo/nom: 05b65d0 | lizmat++ | src/core/Regex.pm:
12:18 dalek rakudo/nom: Make ~~ /foo/ a bit faster
12:18 dalek rakudo/nom:
12:18 dalek rakudo/nom: 2% for successful matches, 6% for failed matches.
12:18 dalek rakudo/nom: review: https://github.com/rakudo/rakudo/commit/05b65d0b12
12:25 gfldex is rakudo meant to understand BOMs? I'm asking because of http://seriot.ch/parsing_json.html
12:29 lizmat gfldex: I think that's on the list of things to fix with the encoding / decoding refactor, jnthn probably knows more
12:37 jnthn The UTF-8 encoding certainly recognizes and strips the BOM
12:45 dalek rakudo/nom: e4dc8b6 | lizmat++ | src/core/Regex.pm:
12:45 dalek rakudo/nom: Make <foo bar baz> ~~ /foo/ about 2x faster
12:45 dalek rakudo/nom:
12:45 dalek rakudo/nom: - rewrite using nqp ops
12:45 dalek rakudo/nom: - don't create Match object until we found a match
12:45 dalek rakudo/nom: - no need to -return- on succesful match
12:45 dalek rakudo/nom: review: https://github.com/rakudo/rakudo/commit/e4dc8b6ed1
12:49 viki :o
12:49 viki lizmat++
13:41 gfldex jnthn: should it understand Little-endian UTF-16 Unicode text, with no line terminators ?
13:43 jnthn Seems that the utf16 decoder knows about those: https://github.com/MoarVM/MoarVM/blob/e3cedc1791c2b17d1254b132f050c5e7faee51f6/src/strings/utf16.c#L31
13:43 jnthn Though I note it doesn't seem to have implemented the decode stream interface
13:44 gfldex it says "Malformed UTF-8" for https://raw.githubusercontent.com/nst/JSONTestSuite/master/test_parsing/i_string_UTF-16LE_with_BOM.json
13:46 jnthn We don't auto-detect which encoding to use based on BOM
13:57 ilmari for JSON you can even detect the encoding without a BOM, since the first character must be ascii ({, [, ", , 0-9))
13:57 ilmari (or ascii whitespace)
14:00 ugjka joined #perl6-dev
14:11 japhb jnthn: Did you bump versions after your OO::Monitors fixes?  My home machine was failing to install OO::Monitors last night, and this morning I realized it may be because my home build script is less aggressive and doesn't try to force master/master/nom.
14:12 jnthn japhb: Ah, no
14:25 dalek roast: a3f26de | (Zoffix Znet)++ | S02-types/infinity.t:
14:25 dalek roast: Toss redundant test
14:25 dalek roast:
14:25 dalek roast: The -Inf.Int tests are redundant, since prefix:<-> is lower precedence
14:25 dalek roast: than postfix:<.> and so the result of the .Int exception will be the same
14:25 dalek roast: and there's no reason to test it.
14:25 dalek roast: review: https://github.com/perl6/roast/commit/a3f26deb88
14:26 sivoais joined #perl6-dev
14:47 japhb m: say Inf.chars; say -Inf.chars;
14:47 camelia rakudo-moar e4dc8b: OUTPUT«3␤4␤»
14:47 japhb Zoffix: Are you sure about that redundancy and relative precedence? ^^
14:48 viki japhb: yes. The above is a bug soon to be fixed
14:48 japhb Ah, so you want to treat -Inf as -(Inf) and not as a token of its own
14:48 viki m: say Inf.chars; say -∞.chars;
14:48 camelia rakudo-moar e4dc8b: OUTPUT«3␤-3␤»
14:49 japhb Regardless of that, isn't the spirit of the test to make sure that (-Inf).Int is handled correctly, and thus the fix is to insert said parens, rather than delete the test?
14:56 ggoebel joined #perl6-dev
14:56 AlexDani` joined #perl6-dev
14:57 dalek roast: 3cc848d | (Zoffix Znet)++ | S02-types/infinity.t:
14:57 dalek roast: Revert "Toss redundant test"
14:57 dalek roast:
14:57 dalek roast: This reverts commit a3f26deb881d5a25c3cb8d5ce87261a21a71b5d2.
14:57 dalek roast:
14:57 dalek roast: Test to be rewritten with parens to create negative Infs
14:57 dalek roast: review: https://github.com/perl6/roast/commit/3cc848d010
14:57 dalek roast: 9ce67f1 | (Zoffix Znet)++ | S02-types/infinity.t:
14:57 dalek roast: Test (-Inf).Int throwage
14:57 dalek roast:
14:57 dalek roast: japhb++
14:57 dalek roast: review: https://github.com/perl6/roast/commit/9ce67f1f0b
17:29 dalek joined #perl6-dev
17:36 hankache joined #perl6-dev
17:58 perlpilot joined #perl6-dev
18:01 MasterDuke_ joined #perl6-dev
18:04 MasterDuke_ re the Signature.$!count discussion from yesterday. what about making the private $!count attribute an int, but the .count method still return a num?
18:05 MasterDuke_ so https://github.com/rakudo/rakudo/blob/nom/src/core/Signature.pm#L87 will instead be something like: $!count >= 0 ?? $!count !! Inf
18:08 viki What do we gain from that?
18:08 viki I mean from int $count
18:10 MasterDuke_ something that can be more easily optimized than a Mu
18:12 [Coke] is this for something that's already been identified as something that needs optimizing?
18:12 [Coke] (I missed the beginning of the discussion on this)
18:13 MasterDuke_ [Coke]: i've been continuing to "clean up" BOOTSTRAP.nqp
18:13 [Coke] ah, ok.
18:14 MasterDuke_ so along with converting BOOTSTRAPATTRs to Attributes, i'm also trying to make the types more specific where possible
18:15 MasterDuke_ i.e., some things are Mu and i think they could be a native or something else more specific
18:21 MasterDuke_ and it just seems a little crazy to use a Mu for something where the range of values that are probably ever seen could fit in a uint8 (aside from the fact that Inf is also valid)
18:21 viki ZOFVM: Files=1198, Tests=130088, 131 wallclock secs (19.85 usr  2.90 sys + 2302.94 cusr 201.64 csys = 2527.33 CPU)
18:23 dalek rakudo/throw-list-contains: fed556f | (Zoffix Znet)++ | src/core/List.pm:
18:23 dalek rakudo/throw-list-contains: Make List.contains throw
18:23 dalek rakudo/throw-list-contains:
18:23 dalek rakudo/throw-list-contains: Due to non-obvious behaviour of the method (it stringifies the list first),
18:23 dalek rakudo/throw-list-contains: make the method throw.
18:23 dalek rakudo/throw-list-contains: review: https://github.com/rakudo/rakudo/commit/fed556fcb8
18:23 timotimo not sure if i like that ^
18:23 viki timotimo: yeah, I made a branch and a PR to get feedback on the proposal: https://github.com/rakudo/rakudo/pull/907
18:27 perlpilot Is fixing .contains() not an option?
18:28 timotimo it's not broken
18:28 timotimo just not always what you'd expect
18:28 nine s/not always/practically never/
18:28 perlpilot that sounds like "broken" to me  :)
18:31 timotimo .. we could rename it to strcontains :P
18:35 perlpilot In absence of a "real" fix for List.contains, making it fail seems like a reasonably conservative thing to do.  IMHO.
18:37 nine If anyone really, really means strcontains, the workaround is trivial: $list.Str.contains($foo)
18:43 AlexDaniel viki++, good one
18:44 [Coke] we have a history in six of not using the same method name to do different things.
18:44 viki perlpilot: fixing it would result in method of the same name doing completely different things for different objects, which felt iffy
18:44 MasterDuke_ or ~$list.contains($foo)
18:45 timotimo MasterDuke_: precedence
18:45 AlexDaniel ummmm, what?
18:45 [Coke] (I don't particularly have a problem with it)
18:45 viki MasterDuke_: wouldn't that stringify the result?
18:45 [Coke] (and I think I mean routine name, not method name)
18:45 MasterDuke_ not sure about the precedence, but  ~($list).contains($foo) should do it, right?
18:46 viki No
18:46 viki (~$list).contains($foo)
18:46 AlexDaniel m: my @list = ‘a’, ‘bb’; say @list.contains(‘a b’)
18:46 camelia rakudo-moar e4dc8b: OUTPUT«True␤»
18:46 AlexDaniel m: my @list = ‘a’, ‘bb’; say ~@list.contains(‘a b’)
18:46 camelia rakudo-moar e4dc8b: OUTPUT«True␤»
18:46 AlexDaniel m: my @list = ‘a’, ‘bb’; say ~(@list).contains(‘a b’)
18:46 camelia rakudo-moar e4dc8b: OUTPUT«True␤»
18:46 AlexDaniel m: my @list = ‘a’, ‘bb’; say ~(@list) .contains(‘a b’)
18:46 camelia rakudo-moar e4dc8b: OUTPUT«True␤»
18:46 jnthn How much breaks if we remove contains from Cool?
18:46 AlexDaniel m: my @list = ‘a’, ‘bb’; say (~@list).contains(‘a b’)
18:46 camelia rakudo-moar e4dc8b: OUTPUT«True␤»
18:46 AlexDaniel wait, I'm doing something completely wrong :)
18:47 * jnthn is not too fond of implementations that exist simply to throw...
18:47 MasterDuke_ m: say ~(^9).contains("2 3")
18:47 camelia rakudo-moar e4dc8b: OUTPUT«True␤»
18:48 AlexDaniel well it already stringifies everything, so no point in trying
18:49 MasterDuke_ yeah, i kind of meant as a workaround like nine said, assuming the PR (or something similar) gets merged
18:50 viki m: say ~bag().contains: 42
18:50 camelia rakudo-moar e4dc8b: OUTPUT«No such method 'contains' for invocant of type 'Bag'␤  in block <unit> at <tmp> line 1␤␤»
18:50 viki m: say (~bag()).contains: 42
18:50 camelia rakudo-moar e4dc8b: OUTPUT«False␤»
18:51 viki 1 sec, I'll say
18:54 viki m: say ~bag() .contains: 42
18:54 camelia rakudo-moar e4dc8b: OUTPUT«False␤»
18:56 MasterDuke_ m: my @a = <1 z 3 y 5>; say @a[@a.index("z")]
18:56 camelia rakudo-moar e4dc8b: OUTPUT«3␤»
18:56 MasterDuke_ ^^^ another possible source of confusion
18:57 AlexDaniel :D
18:57 MasterDuke_ if someone thought .index was similar to .grep (i.e., return the index in the array where the thing was found)
18:58 viki What does it actually do?
18:58 viki m: say (0..100).index(5)
18:58 camelia rakudo-moar e4dc8b: OUTPUT«10␤»
18:58 viki :/
18:58 MasterDuke_ pos in string
18:58 viki oh boy
18:59 viki jnthn: only a couple of tests in t/spec/S32-str/contains.t that call .contains() on an Int
18:59 MasterDuke_ https://github.com/rakudo/rakudo/blob/nom/src/core/Cool.pm#L160
19:00 vendethiel joined #perl6-dev
19:00 MasterDuke_ self.Str.index($needle)
19:00 viki jnthn: and they're present in 6.c-errata too: https://github.com/perl6/roast/blob/6.c-errata/S32-str/contains.t#L25-L34
19:05 jnthn OK. Might be worth keeping in mind as an option.
19:08 * viki wouldn't want to break 6.c-errata.
19:09 viki m: "fooBARber" ~~ /<[A..Z]>+/; $/.contains('BAR').say
19:09 camelia rakudo-moar e4dc8b: OUTPUT«True␤»
19:12 viki m: say (1..10).contains: "2 3"
19:12 camelia rakudo-moar e4dc8b: OUTPUT«True␤»
19:13 viki Imma close the PR. There's no consensus on it and it'd need same solution for Range and .index() which is too messy
19:14 ggoebel joined #perl6-dev
19:15 MasterDuke_ and .rindex, .starts-with, .ends-with, .indices, .substr-eq
19:15 MasterDuke_ but i'd be curious for TimToady's thoughts
19:16 viki .oO( where's a DWIM there's a WAT )
19:22 viki Make another class, like Cool with those methods... Call it Smart
19:22 viki For 𝗦tringy 𝗠ethods that 𝗔ctually do the 𝗥ight 𝗧hing ^_^
19:27 viki or Nerd... for Not Entirely Right DWIMM :")
19:29 AlexDaniel viki: perhaps open a ticket for that instead
19:29 AlexDaniel who knows, maybe @LARRY thinks that getting rid of such footgun is worth the trouble
19:42 viki I'm not a fan of tickets. It would just rot among the other 1,400. Especially since not everyone agrees that anything is broken at all.
20:00 masak viki: that's true. the best way of making something happen is to do it.
20:06 viki masak, indeed. And after the discussion, the only viable solution I see is splitting Cool, which IMO isn't a worthy pursuit just to avoid a wat. :)
20:14 ugexe m: my @a = [90..100]; say @a.contains("98 99"); say @a>>.contains("98 99")
20:14 camelia rakudo-moar e4dc8b: OUTPUT«True␤[False False False False False False False False False False False]␤»
20:30 gfldex there is .flip and .reverse, and there is .contains and .???
20:31 gfldex IMHO there is a lack of thought by the design departement
20:32 gfldex also, if .contains throws so should .flip
20:36 perlpilot more like "lack of focus on this particular bit of the design" than "lack of thought"
20:37 viki Design department? :)
20:37 gfldex i still have hopes :)
20:50 Ven joined #perl6-dev
20:56 AlexDaniel gfldex: .contains and .first? 🤷
20:57 AlexDaniel whenever I had to do that kind of thing I always used any, I think
21:07 nine Good news is that INIT phasers do indeed run even when we load a precompiled module. Bad news is that I'm probably gonna have to runtime generate an INIT phaser into Inline::Perl5's users. And that doesn't exactly sound like a walk in the park.
21:11 FROGGS joined #perl6-dev
21:18 perlpilot m: my @a = <a b c d >; say so @a.starts-with("a b"); say so @a.ends-with("c d");
21:18 camelia rakudo-moar e4dc8b: OUTPUT«True␤True␤»
21:19 perlpilot Also a little surprising
21:20 jnthn nine: If doing that, might just be worth putting in a general mechanism for phaser export
21:20 jnthn nine: I mean, we already have EXPORTHOW for meta-objects; could do EXPORTPHASER for those :P
21:46 lizmat fwiw, re .contains, .index, .starts-with, .ends-with: the underlying issues is really that Lists are Cool
21:46 lizmat so why are they Cool in the first place ?
21:47 lizmat *issue
21:51 gfldex m: sub can-substr(Cool $c){ $c.substr(1,2).say }; can-substr(<a b c>);
21:51 camelia rakudo-moar e4dc8b: OUTPUT« b␤»
21:52 AlexDaniel gfldex: what point are you trying to make?
21:52 gfldex m: substr(<a b c>, 1, 2).say;
21:52 camelia rakudo-moar e4dc8b: OUTPUT« b␤»
21:53 dalek rakudo/nom: 8c35481 | lizmat++ | src/Perl6/Metamodel/BOOTSTRAP.nqp:
21:53 dalek rakudo/nom: Fix comment
21:53 dalek rakudo/nom: review: https://github.com/rakudo/rakudo/commit/8c3548163a
21:53 gfldex if List stops to be Cool, there will be a disconnection between the coerciness of substr and .substr
21:53 gfldex and there are plenty of such pairs of subs and methods
21:54 AlexDaniel but why should substr(<a b c, 1, 2) work at all?
21:54 AlexDaniel >*
21:54 AlexDaniel s: &infix:<+>, \(2, 5)
21:54 SourceBaby AlexDaniel, Sauce is at https://github.com/rakudo/rakudo/blob/e4dc8b6/src/core/Int.pm#L245
21:54 AlexDaniel s: &infix:<+>, \(<a b c>, 5)
21:54 SourceBaby AlexDaniel, Sauce is at https://github.com/rakudo/rakudo/blob/e4dc8b6/src/core/Numeric.pm#L186
21:55 gfldex because in a dynamic language you have to care about getting your types right. If you don't care about types, things will just work. For a wide range of values for work.
21:55 AlexDaniel and by “work” what do you mean?
21:55 AlexDaniel m: substr(<a   b     c>, 1, 2).say;
21:55 camelia rakudo-moar e4dc8b: OUTPUT« b␤»
21:56 AlexDaniel < > does not get you strings, not even close
21:56 AlexDaniel well it does, but…
21:56 lizmat well, making List Any breaks the build quite early  :-)
21:57 jnthn I think it simply boils down to: with each operation you need to know what type it's going to coerce to if that's not what it gets. That runs deep in Perl (5 and 6).
21:57 jnthn It's perhaps a bit unfortunate that we added contains/start-with/ends-with.
21:58 gfldex m: say so <a b c>.starts-with('a');
21:58 camelia rakudo-moar e4dc8b: OUTPUT«True␤»
21:58 jnthn Since matching against /$foo/, /^ $foo/ and /$foo $/ are unambiguously about strings.
21:59 gfldex it will work in quite a lot of cases, but may break for others. The bother could be in the realm of a linter.
21:59 AlexDaniel m: say 42.starts-with(‘4’)
21:59 camelia rakudo-moar e4dc8b: OUTPUT«True␤»
22:00 gfldex and if it should start with '4' depends on the intention of the programmer. Sadly Rakudo can't read minds yet.
22:02 AlexDaniel my point was that starts-with and friends are not just about strings, they are fine for numbers too
22:02 gfldex Perl 6 does not support copy constructors for implicit coercion like C++ does. That's why we need Cool.
22:03 jnthn Having operations in the language consistently coerce things to the type they want is, IMO, preferable to them overloading the same word with different meanings, anyway. But no approach is without its ways for people to trip over.
22:04 jnthn So contains/starts-with/ends-with consistently being about strings is fine. You learn that once, and you know what they're going to do whenever you see them.
22:05 gfldex i think .contains is fine as it is. It's one of the things you have to learn when you use Perl 6. And given it's a fairly common pattern to have methods that coerce to some type, it's not a large burden on the user.
22:05 jnthn Indeed, I don't think you could get very far in Perl 6 without realizing that it works in that way.
22:05 gfldex You may want to print that bold in books tho. :->
22:05 jnthn For example, all the list-y methods treat non-Iterable things as a 1-item list.
22:07 jnthn It's better to be consistent in this approach than to introduce discontinuities because somebody might be confused about what the units .contains is referring to are.
22:07 jnthn We've even gone so far as having substr and subbuf, and we'll likely end up with subuni too for the same reason.
22:08 lizmat m: say <a b c d e>.index("e")   # .index also
22:08 camelia rakudo-moar e4dc8b: OUTPUT«8␤»
22:08 jnthn Indeed
22:09 lizmat m: say <a b c d e>.rindex("e")   # and its counterpart .rindex
22:09 camelia rakudo-moar e4dc8b: OUTPUT«8␤»
22:09 jnthn JavaScript has .indexOf on both Array and String.
22:09 jnthn And they do different things.
22:09 jnthn Meaning you have to know what type of data you'll have to know the semantics.
22:11 jnthn Which is unpredictable even after you learn the language well. :)
22:12 jnthn So I'd say we're in a better place.
22:12 AlexDaniel yea, that's bad. And we don't do it, it's good, I agree. Instead we print wrong results that are far from being useful at all, even if you know what these results mean.
22:14 dalek joined #perl6-dev

| Channels | #perl6-dev index | Today | | Search | Google Search | Plain-Text | summary