6macros: discussing the finer points of Perl 6 macros, Qtrees, and how to stay sane | irclog: irclog.perlgeek.de/6macros/today
Set by moderator on 28 July 2015.
01:52 ilbot3 joined 02:14 Ven`` joined
masak blocks started out as first-class in 007. they were removed as terms/values exactly because I didn't want to take the Perl 6 route of having a `leave` semantics. 05:10
instead, blocks always acted as if they had an implicit `leave None`. this was part of what was confusing when using them -- there was a big temptation to put a block in a .map(), for example 05:12
it might seem stubborn of me to insist that blocks not return any value, but I was looking at languages like Perl 5 and Python and JavaScript -- even Java and C# -- for prior art. they all have only one "level" of value-returning type of code. only routines, not blocks and routines. 05:13
so for example github.com/masak/007/issues/215 aims to give us all the advantages of value-returning blocks, but using only (the semantics of) subs 05:14
not saying that early decision (to ban blocks from the design) needs to be protected at all costs, but I still find it superfluous and somehow against 007 aim at minimalism to have both routines/return and blocks/leave 05:16
and because of that, I'm willing to entertain the idea of just considering quasis to be routines and making `return` work in quasis/injections, rather than (re-)introducing the idea of blocks, introducing `leave`, and then making `leave` work in quasis/injections 05:19
hope that makes sense :) I do understand it's a position one can agree or disagree with
in the end, I'm motivated by a desire to keep the language simple. I'm not (yet) convinced that 1st-class blocks are necessary for macros and quasis 05:20
12:45 Ven`` joined
Ven`` Blocks not being first-class is not an issue, as I see it. They don't need to be. 12:45
Some expression-oriented languages can still compile down to statement-oriented languages, say. That's why the comma operator has existed at least since C. 12:46
The example I'd use is CoffeeScript's ability to compile down `if`s, `while`s, etc, as expressions in JS. 12:51
Using the comma operator for sequencing, ?: for if, and the ultimate hack otherwise: an IIFE for loops. 12:52
(which is why returning from such constructs is forbidden: "x = return 1 for a in b" yields "cannot use a pure statement in an expression")
There's no difference between "{ foo(); if (a) bar(); else baz() }" and `(foo(), a ? bar() : baz())` 12:53
We don't need leave. Both it and return are hacks to begin with. I probably won't get too many friends for saying that, but... Short-circuiting is not very interesting. 12:54
WRT blocks returning values, of course, in Lisp it's not an issue, because everything is an expression. 12:55
(and a lot of lisps don't have a `return` statement. CL has `return` but that actually only works for what they call "blocks". So it's backwards to how we have it here) 12:58
I'm saying all this because this is apparently an area where you're ok with distancing yourself from Perl 6 so we should try to find some inspiration from other languages. 12:59
14:36 cognominal joined 17:49 vendethiel- joined 18:07 Ven joined
masak I started a repository called george-lazenby to follow to its logical conclusion the idea that everything is an expression 18:40
but I can't find it anymore. maybe I removed it in a fit of sanity.
(never got a round tuit to do anything; all it did was sit there falling behind 007's HEAD)
vendethiel- even loops? :P 18:44
I remember arguing with #perl6 in 2014 about loops being specialcased to not return a value
masak I don't have a pony in that race either 18:47
but rest assured they would return something :P
vendethiel- \\o/ 18:48
masak .oO( to this day george-lazenby remains only a legend, a whisper upon the wind )
vendethiel- One thing that struck me is that it's one of the areas you're willing to deviate from Perl 6 :) 19:16