Camelia, the Perl 6 bug

IRC log for #moe, 2013-04-01

| Channels | #moe index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:41 chansen joined #moe
01:26 moe [moe] stevan created anon-code (+4 new commits): http://git.io/pDUr8w
01:26 moe moe/anon-code 6853b5e Stevan Little: add in code literals
01:26 moe moe/anon-code 972e111 Stevan Little: completely re-organize parser, this was necessary to support code literals
01:26 moe moe/anon-code 80d8b43 Stevan Little: adjust the Parser name here
01:32 moe [moe] stevan merged anon-code into master: http://git.io/5QqMrg
01:33 moe [moe] stevan deleted anon-code at cba9d7e: http://git.io/zP4U7Q
02:10 moe [moe] stevan pushed 5 new commits to master: http://git.io/C7HAwA
02:10 moe moe/master d761fba Stevan Little: add a Code class to the builtins
02:10 moe moe/master 8beca4a Stevan Little: remove CodeCall AST node in favor of just calling the apply method
02:10 moe moe/master 47ba21c Stevan Little: test for the apply method
02:48 moe [moe] stevan pushed 3 new commits to master: http://git.io/ZqGVWw
02:48 moe moe/master 2091272 Stevan Little: fix some names and allow anon-code to be stored in attributes too
02:48 moe moe/master 83c1d33 Stevan Little: differentiate between call and apply (call requires the arguments to match the signature, whereas apply just takes an array and flattens it for you)
02:48 moe moe/master 342569a Stevan Little: anon-code should have a default signature of *@_
08:26 marcus joined #moe
09:20 melo joined #moe
11:07 gizmomathboy joined #moe
11:48 gizmomathboy joined #moe
12:33 stevan joined #moe
13:45 jnap joined #moe
14:01 bluescreen joined #moe
14:53 awwaiid stevan, I don't know if you're into it, but I think that if you are using -> {...} instead of sub {...} then we could introduce other perl6isms, such as alphabetical local variable parameter aliases.
14:54 awwaiid though I guess -> $x, $y { $x + $y } might be more clear
14:54 awwaiid and forces scope
14:54 awwaiid dunno
14:54 awwaiid oh I see your fully syntax in your test now that I look better
14:54 awwaiid I guess it's good as is
14:56 * awwaiid wonders about splipping some partial-application into the call vs apply on subrefs
14:57 PerlJam awwaiid: It's only auto-declared parameters that are alphabetic, and they are also distinguished with a twigil.  Not sure how that would fit in moe-land where there are no twigils.
14:57 awwaiid what are their twigil? I can't recal
14:57 PerlJam though with a "use v6-compat" or something, I bet p6isms could come easily.
14:57 PerlJam awwaiid: $^a   the ^ is a twigil.
14:58 awwaiid oh yes, that's right
15:06 arnsholt I'm pretty sure ^ twigilled variables are added in order of use, not alphabetically
15:07 stevan "alphabetical local variable parameter aliases" say what?
15:08 stevan PerlJam: we have twigils :)
15:09 PerlJam ah, that's awesome :)
15:09 PerlJam arnsholt: S06:1931  second paragraph
15:09 stevan PerlJam: I have $.foo already going for the class attribute syntax
15:10 stevan and $?CLASS, $?SELF, etc
15:10 doy stevan: $ ./run/Niecza.exe -e 'say sub { $^a + $^b }.(1, 3)'
15:10 doy 4
15:10 stevan though I am thinking that would be better as $^CLASS
15:10 stevan right, that sounds reasonable
15:10 stevan awwaiid: patches welcome :)
15:10 stevan right now the default signature on anon subs is *@_
15:11 jnap joined #moe
15:12 stevan not enforcing that on subs and methods though, not sure if it makes sense
15:13 awwaiid this $^x stuff would be best with *@_ I think
15:13 stevan yeah
15:13 stevan basically $^a would lazily evaluate to @_[0]
15:13 awwaiid exactly
15:13 awwaiid except more magical
15:13 stevan how more magical?
15:14 stevan in what way?
15:14 stevan I would think thats pretty simple
15:14 stevan also, how do i get @_[27]?
15:14 * stevan assumes it is not just the alphabet, but all of unicode
15:14 phaylon $^aa! :D
15:14 stevan hehe
15:14 stevan base-26
15:15 phaylon eval '$^' . ('z'++) # moar compatible
15:16 stevan hehe
15:16 phaylon IIRC Perl 6 does something $^a like for named parameters as well, with $:foo or something like that
15:16 stevan :$foo
15:17 PerlJam phaylon: yep
15:17 awwaiid in perl6 it is alphabetical
15:17 phaylon stevan: might be as well :)
15:17 stevan https://github.com/MoeOrganization/mo​e/blob/master/src/test/scala/org/moe/​parser/SubroutineTestSuite.scala#L76
15:17 awwaiid based on your usage
15:17 PerlJam awwaiid: it's unicode-ical
15:17 PerlJam :)
15:17 stevan added support this weekend
15:17 awwaiid ya ya
15:17 stevan phaylon: ^
15:17 awwaiid but if you use $^x and $^y only, then $^x == @_[0] and $^y == @_[1]
15:18 stevan scroll up to see the slurpy array and slurpy hash
15:18 awwaiid it is not optimized for getting @_[26] :)
15:18 PerlJam stevan: :$foo is something different.   $:foo is a auto-declared named param
15:18 * stevan cocks head to the side
15:18 stevan wha?
15:18 stevan auto-declared named param?
15:19 phaylon stevan: I meant inside the param
15:19 phaylon yea
15:19 awwaiid so sub { $^y / $^x } is the same as sub {$^b / $^a}
15:20 phaylon sub foo { $:foo + $:bar }(:foo(23), :bar(17)) # or whatever the named arg syntax is
15:20 stevan oh
15:20 stevan thats, uhm, magical
15:20 stevan I will skip that feature
15:20 * stevan is not a fan of implicit stuff like that
15:20 phaylon well, depends. if the named ones are all automatically in a rest hash, it's less magical than $^a
15:21 stevan yeah, maybe
15:21 phaylon because you have $:foo => %REST{foo} vs $^a => $_[0]
15:21 phaylon or, @_[0]
15:21 * phaylon confused himself too early in the morning
15:22 stevan :)
15:22 awwaiid worse, $^a or-whatever-is-first => $_[0]
15:22 phaylon yea
15:23 awwaiid but it looks awefully neat to do ->{ $^x1 + $^x2 } in some sort of map situation :)
15:23 stevan right
15:23 awwaiid but probably too high a barrier to entry
15:23 PerlJam Here's a link to the relevant section of the synopsis: http://perlcabal.org/syn/S06.html#line_1931
15:23 phaylon stevan: out of curiosity, how are you handling positional/named params internally? do you pack them together in an object or pass them separately?
15:23 PerlJam (if you'd like to read about the perl 6 semantics)
15:23 stevan phaylon: I am kinda cheating
15:24 awwaiid kinda? hah
15:24 stevan named arguments are just a pair literal
15:24 phaylon aah, so it's one list with different types of args
15:24 stevan and when I loop through to check positionals, i just punt when I hit a named one
15:25 phaylon I do the same in the AST, but then separate them and pass pos and nam ones
15:25 stevan actually, I dont punt, I make a list of the args that didn't get resolved
15:25 stevan then I loop through them
15:25 stevan look for pairs
15:25 stevan then try and match against a map of named paramters
15:25 stevan its kinda kludgy, but it works
15:25 stevan I still need to add a bunch of validation logic to make sure the signatures are valid
15:25 phaylon well, it sounds optimizable, since you can just give it some other marker for "these are prepared, be smarter"
15:25 stevan yes
15:26 stevan I only really started thinking about moving some validation down into the AST/Parser level this weekend
15:26 phaylon at which point you can pass in stuff like lazily evaluating arg lists for optimizattions, so it should be flexible too
15:27 stevan https://github.com/MoeOrganization/m​oe/blob/master/src/main/scala/org/mo​e/parser/MoeProductions.scala#L265
15:27 phaylon heh, I switched my toy project from scheme pair lists to vectors, since pair lists suck when you want to join 2 5 million entry ones :)
15:27 stevan this in particular made me realize what I could do
15:27 stevan haha, why would  you join 25 million of them?
15:28 phaylon because I wanted to see how fast it is :)
15:28 stevan ah
15:28 phaylon and it wasn't so I switched :)
15:28 stevan I am no where near needing to care about that
15:29 phaylon well, lists are everywhere in scheme, so I had to change a lot of the bootstrapping stuff and wanted to get it on before I got more stuff to change
15:29 stevan right
15:29 stevan pairs are basically simple tuples in Scala
15:29 phaylon yea
15:30 phaylon it's easy to go for car/caddr/cadddr/... in scheme, when one should actually abstract
15:30 phaylon because what else would it be but a list? then 5hrs later you realise "oh no that's not internal"
15:33 jnap1 joined #moe
15:35 phaylon that's a very nice way of defining syntax btw, scala does look quite good
15:45 arnsholt PerlJam: Huh. Right you are. It's a Rakudo-bug I thought was spec =)
16:26 jnap joined #moe
17:01 marcus joined #moe
17:22 marcus joined #moe
18:11 marcus joined #moe
18:34 tobyink joined #moe
19:14 am0c joined #moe
19:26 jnap joined #moe
19:44 jasonmay joined #moe
20:07 stevan I think it is time to replace -> with .
20:08 * stevan is already breaking so much back compat, shit won't mater
20:08 stevan and it was one of the top things people asked for
20:08 stevan awwaiid: would that make you sad?
20:11 moe [moe] stevan pushed 2 new commits to master: http://git.io/jhTZqQ
20:11 moe moe/master f7bc513 Stevan Little: make this a little more sane, and never return Unit from one of the native class methods
20:11 moe moe/master 5e05344 Stevan Little: add in map, grep and each to Array and add some tests for it
20:13 prammer I was wondering about the disconnect between "$x->foo" and "has $.foo"
20:13 prammer "has $->foo" anyone? ;)
20:13 tadzik :o
20:14 tadzik dot is way saner
20:14 tadzik so string concat becomes ~, like in 6?
20:14 stevan prammer: well $.foo is a twigil, $x->foo is the method send operator
20:14 prammer I agree it's saner.  But if method invocation stays -> ...
20:14 stevan maybe just go OCaml style and use #
20:14 jnap why not just do + like javascript?  at least that is familiar
20:14 stevan $x#foo
20:15 stevan jnap: you mean for string concat?
20:15 stevan yes, I agree
20:15 jnap yeah
20:15 doy jnap: + for concatenation in javascript is really irritating
20:15 stevan doy: why?
20:15 doy it requires a type system that actually makes sense
20:15 stevan yeah
20:15 prammer what do you want 5 + "5" to mean?
20:15 doy right
20:15 stevan prammer: well, we need some kind of implicit coercion context thing
20:16 stevan prakesh was working on it, he submitted a small patch to show as an example
20:16 doy reusing operators for string and numeric operations doesn't work well in combination with implicit coercions between strings and numbers
20:16 prammer this is kinda why perl is know as being "operator oriented" no?  because we don't overload them too much
20:16 doy right
20:16 jnap the main upside in perl to having + and . separate is you can sometimes very occasionally use it to do the right thing in a tricky way.
20:16 stevan basically the parser captures the context of the operation and the AST does the coercion
20:16 doy that's why perl in general avoids reusing operators in that way
20:16 jnap and most of the rest of the time its a typo :)
20:16 doy and i think it's the right decision
20:16 stevan ok, we can steal again from p6 with ~
20:17 stevan which I kind of liked
20:17 doy (one of the few places it got that wrong was in the bitwise operators, and perl 6 fixed that)
20:17 jnap I alsmost thinkg 5 + "5" should do something very bad, and obviously so, since its nearly always a mistake
20:17 stevan 5 + "5".Int is how you would do it in Perl
20:17 jnap usuallt the programmer meant to do arithmatic and there was an error somewhere
20:18 sahadev joined #moe
20:18 prammer I don't have a firm opinion on what (5 + "5") should mean.  But last time I thought about it and debated with people at $work, that's what it seemed to boil down to
20:21 jasonmay +
20:22 jnap typically I would do like "5 $number" or somthing rather thatn "5 ".$number
20:23 doy if we aren't going to have strict typing, + really has to always mean numeric addition
20:23 jnap I would care more to end the insanity that is "my object is ${\$self->mymethod}"
20:24 jasonmay could always steal ruby's #{...} or soemthing similar
20:24 prammer jnap: p6 has an answer worth look at for that
20:24 * sahadev just finished implementing explicit coercion methods/operators (+ for Int, ? for Bool and . for Str)
20:24 jasonmay for the interpolation part of the solution at least
20:24 sahadev jnap++
20:25 jnap donno, I guess I sorta think that Perl is the language where we follow the grooves wore in the grass by common use and 5 + "5" seems like is the walking off the cliff version, why optimize for that?
20:25 sahadev just to confuse matters more, I used "." as the explicit string coercion operator.
20:26 doy jnap: so you think 5 + "5" and "5" + 5 should always throw an exception?
20:26 sahadev but it felt really ugly to use it is a prefix operator. also it breaks floatLiterals now.
20:27 stevan sahadev: really?
20:27 sahadev stevan: what should .2 mean? 2->Str or 0.2?
20:28 stevan sahadev: check out the dot-moe branch, i just switched . to ~
20:28 moe [moe] stevan created dot-moe (+1 new commit): http://git.io/R3D_jA
20:28 moe moe/dot-moe be8888e Stevan Little: s/./~/g && s/->/./g
20:28 stevan so you could do ~2
20:29 jnap doy:  not sure if it should or not, but I just speculate that it might be the right thing to do is to be painful in some obivious manner.  Haven't really thought it totally through.  I just think when I see that use case I want to approach it from the position that its probably a mistake rather than to figure out how to support it
20:29 jnap don't know if that's the Perl way or not
20:35 prammer imagine the "5" were read from user input.  can you do (5 + $read_from_user) ?  or do you have to do (5 + $read_from_user.Int) ?
20:36 jnap I would say if you are not cleaning user input in some way, let the chaos begin
20:38 prammer I can see that.  But since when has perl prevented chaos? :)
20:41 jasonmay what features so far are from perl5 and not from perl 6?
20:41 prammer I actually did have this conversation with my 5 year old.  How do you put together 5 and 5 and get 55 instead of 10?
20:43 hobbs jnap: I think you're discounting a large portion of what Perl gets used for. Although maybe we don't give a shit.
20:43 jnap hobbs:  you might be totally right!
20:44 prammer there are a good number of languages that use + for string concat
20:44 hobbs I've written a lot of things in ten years that would have gotten longer and clumsier if I had to go turning a lot of strings into ints or nums
20:44 jnap not sure, I'm not the one that said lets use . for method calls :)
20:45 hobbs I don't enjoy the javascript way very much
20:45 jnap (5 + $read_from_user.Int)  doesn't seem like so much more work though
20:46 hobbs going one way you have parseInt and parseFloat; going the other way, numbers know how to turn themselves into strings, but that means that + does something different depending on its LHS
20:46 jnap well like I said I almost always do like "some thinng $XX $YYY more stuff" when I want string context since I think that's cleaner lookin
20:51 phaylon I was thinking about having string, numeric and an additional set of object operators that allow overriding
20:53 moe [moe] prakashk created prakashk/explicit-coercion (+3 new commits): http://git.io/COJ0rQ
20:53 moe moe/prakashk/explicit-coercion ff55a81 Prakash Kailasa: last one in a group of statements can end with semicolon
20:53 moe moe/prakashk/explicit-coercion 71eb82a Prakash Kailasa: print parse errors when processing code from file or passed with -e option; assume reasonable defaults for all REPL options.
20:53 moe moe/prakashk/explicit-coercion 342de61 Prakash Kailasa: explicit coercion methods (Int, Num, Bool, Str) and operators (+ for Int, ? for Bool and . for Str). This breaks FloatLiterals in a small way (.2 should be written as 0.2 to mean a float number)
21:06 broquaint joined #moe
21:13 moe [moe] prakashk created prakashk/explicit-coercion-with-dot-moe (+2 new commits): http://git.io/0osoTQ
21:13 moe moe/prakashk/explicit-coercion-with-dot-moe 576d3fd Prakash Kailasa: Merge branch 'prakashk/explicit-coercion' into prakashk/context-with-dot-moe
21:13 moe moe/prakashk/explicit-coercion-with-dot-moe d038850 Prakash Kailasa: explicit coercion methods (Int, Num, Bool, Str) and operators (+ for Int, ? for Bool and ~ for Str). This does not break FloatLiterals, since "." is no longer used for stringification.
21:26 awwaiid stevan, are you going to use -> for something else?
21:32 perigrin decrement or less than.
21:32 perigrin (duh)
21:34 * sri bets on perl6-ish blocks
21:35 sri -> $foo { ... }
21:35 sri although they are kind of silly
21:37 doy they're really only useful if you want to build more syntax out of them
21:37 doy for @things -> $thing { ... }
21:37 sri yea
21:37 doy if that's not something we're interested in, there's not much point
21:39 * sri likes fat arrow closures in javascript more ['foo', 'bar', 'baz'].map(word => word.toUpperCase());
21:40 * phaylon violently abuses both in his toy language, as usual
21:42 phaylon they can be nice as shortcuts for languages that have verbose lambda syntax
21:47 awwaiid stevan implemented -> subref thingies last night
21:47 sri :D
21:47 awwaiid so I guess I mean ... are there any OTHER uses? hehe
21:47 awwaiid because if not, hey sure have your . and keep ->
21:47 phaylon oh, I see moe will have real booleans? nice
21:47 awwaiid and deprecate ->
21:48 awwaiid but I'm about to give up as I see my endevours for perl5 compat are doomed :)
22:06 stevan sri, already have perl 6 blocks, they worked fine with -> method calls
22:08 stevan awwaiid: the thing about p5 compat is that we've already lost it since I am not going to support package based classes, nor am I going to support tie or AUTOLOAD
22:09 stevan or XS
22:09 stevan so right there, you've lost most all useful compat
22:09 stevan prammer == prakashk?
22:11 stevan at this point, ask tadzik pointed out to me, this is becoming more of a Perl 6 Lite then a Perl 5 TNG
22:11 stevan and I cant rightly argue with him
22:11 stevan because (as tadzik also said) -> tadzik: yeah, if the goal is "let's fix the insane things", it mostly means "let's do what Perl 6 did"
22:12 tadzik yep. I thought it's all a nice trick stevan did
22:12 stevan not a trick, just a natural progression
22:12 tadzik sure, it was just my conspiracy theory sense tickling ;)
22:13 tadzik if you say "let's do a new Perl 5" you attract people that otherwise wouldn't work on implementing Perl 6
22:13 phaylon I wonder what the code looks like with those sunglasses from "they live"
22:13 stevan phaylon: you see the AST, as if it has no syntax
22:13 tadzik and I like the way where this is going
22:13 tadzik and I don't say that as a big Perl 6 fan
22:14 stevan tadzik: thanks
22:14 tadzik stevan++ # good job
22:14 phaylon stevan: meh, I use scheme, I basically write an AST producing more ASTs :D
22:14 stevan phaylon: then it would probably look like scheme then :)
22:14 phaylon has any perl6 implementation ever tried embedding a perl5 interpreter and doing some interop?
22:15 stevan yes, Pugs did
22:15 stevan it was how we did p5 regexp
22:15 stevan and there was some code interop too
22:15 phaylon did that work alright? because that would always be a nice alternative. and if the interface is a bit worse than a native one would be, people will want to build replacements :)
22:15 stevan I believe it was audrey and clkao who did it
22:16 stevan phaylon: it is in my plan to (at some point when I can no longer put it off) write something like that
22:16 stevan but it requires learning C and JINI and such and I am not that excited about the prospects of that
22:16 phaylon yea, me neither. and chicken even  has some nice schemey stuff for ffi calls, but still..
22:17 awwaiid I know stevan, and it doesn't surprise me to go this way. But that's because I'm not surprised that a clean subset of perl5 is intractable. Doesn't stop me from advocating :)
22:17 tadzik phaylon: it's being worked on right now
22:17 tadzik (embedding p6)
22:17 phaylon p6? :)
22:17 tadzik er, p5
22:17 tadzik or not, it's not embedding actually
22:18 stevan phaylon: this is a project I expanded upon that maps OCaml and Perl -> https://gist.github.com/st​evan/bc5b8b04a29253e88253
22:18 tadzik it's just compiling perl 5 with perl6 runtime
22:18 stevan I would probably go this way
22:18 tadzik embedding was done by a module once, it doesn't work anymore
22:18 phaylon neat, thanks
22:18 stevan tadzik: IIRC jnthn is using some of the STD_P5 to add p5 regexp support to Perl 6
22:19 stevan phaylon: it basically maps the key types in P5, Scalar, Array, Hash, Ref and Code
22:19 stevan then has a converter
22:19 stevan https://gist.github.com/stevan/bc5b8b​04a29253e88253#file-gistfile2-ml-L284
22:19 phaylon yea, but with my C knowledge it's still magic to me :)
22:19 stevan it defines a OCaml type that can be used to map it back and forth
22:20 stevan the C is actually fairly readable, but the OCaml one is the important part
22:20 tadzik ah, p5regex is quite working, I think
22:20 phaylon well, I think that'll work out, since chicken has some nice first-class pointer stuff because it compiles to C, it was the perl side that had me completely baffled :)
22:21 phaylon I tend to stay clear of raw C and instead use stuff that compiles to it
22:21 stevan phaylon: I think the key is deciding exactly how much you interop you want and then figuring out what the API bridge will be
22:22 phaylon well, it's gonna be annoying anyway, because of continuations :)
22:22 doy awwaiid: i don't think that a clean subset of perl 5 is intractable, but i also don't think it's really a language that anybody in 2013 would be all that interested in using
22:22 awwaiid stevan -- ok my new advocacy: a SMALL well defined language. As small as it can possibly be while still having perl-nature. And then give it one more squeeze. This is already being hinted at by doing things in the runtime rather than the "language" where possible.
22:22 doy (i guess it depends on what you mean by 'intractable')
22:23 awwaiid doy: I guess I mean "nobody who has tried has succeeded, and I don't think anyone ever will"
22:23 stevan awwaiid: yes, that is largely the goal
22:23 awwaiid stevan, great. Expect my advocacy to push that way going forward, in case I am gone and you need to consult the awwaiid-voice in your head.
22:23 stevan will do
22:24 * stevan pictures a talking hat in his head
22:24 doy the problem is that perl 5 is built on foundations that made sense 15-20 years ago when people knew a lot less about language design, but don't really as much today
22:24 doy it still works because those weird parts also make it incredibly flexible
22:24 stevan also, it has been since added to and added too and added too
22:25 doy so you can build modern things on top of it
22:25 stevan and never taken away from
22:25 doy but if you try to remove the crazy parts, you're left with a very limited and not very interesting language
22:25 doy stevan: yeah, that too
22:26 doy i was just reading through the python docs today and they say that you should avoid using the % string formatting operator in new code because it will be removed in a future version of the language
22:26 stevan BLASPHEMY! KILL THE SNAKE!
22:26 stevan also, I kinda liked that
22:26 doy and that's just totally insane from the perspective of p5p
22:26 awwaiid right. I'm looking for that magical core philosophy to carry forward. Like the all is file / pipe nature of unix. Or something.
22:26 doy "why do you want to break working code?"
22:27 stevan awwaiid: sure that can carry forward (says the guy who hasn't even begun to think about the IO layer)
22:27 awwaiid I didn't actually mean that as an example for perl directly :)
22:27 stevan I will strive to be as perlish as possible
22:28 stevan which means when a language design question arises and the answer is not obvious to me, i first check Perl 5, then I check Perl 6 and I pick the lest unsane version
22:28 doy honestly, i think that the whole "perl is just a common layer over unix" concept is something that holds it back to a decent extent these days
22:29 awwaiid though it is damn nice to be able to do blah blah `unix stuff $blah` ... s/asdf-(.*)/`grep '$1' lookup.txt`/e ... or some other insane thing
22:29 awwaiid I agree doy. Was probably a bad example of what I'm thinking of :)
22:29 awwaiid ok, must change locations. bbiab
22:29 stevan ok, gotta run, $kid[1] has a concert
22:30 stevan awwaiid: i will let you buy me lots of beers and try and convince me at DCBPW

| Channels | #moe index | Today | | Search | Google Search | Plain-Text | summary