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 26 March 2015.
04:32 vendethiel joined 05:52 vendethiel joined 06:44 vendethiel joined 07:18 vendethiel joined 08:16 vendethiel joined 09:15 vendethiel joined 11:50 vendethiel joined 12:47 vendethiel joined 15:15 vendethiel joined 17:33 vendethiel joined
masak I thought of something today that I'd like to discuss here. 21:14
I see all these systems for creating or manipulating ASTs. most of them create variable references by naming the variable with a string.
first I realized that this means that you could synthetically create a piece of code like `my $x; { say $x; my $x }` -- which is forbidden in Perl 6 (and 007) if you enter it as text. 21:15
probably any hardening mechanism ought to look for that case and flag it up as an error. but I'm not as sure that it's an error synthetically. need to think more about it. 21:16
but then I thought -- what if we ditch this sloppy referring-using-strings mechanism altogether? 21:17
many things have been made nicer in Perl 6 by ditching similar mechanisms.
two cases I can think of right away are:
(a) regexes; no longer strings, but first-class languages. in particular, when you inject one into another, it's done with proper scoping etc 21:18
(b) types. Parrot made the mistake to deal with everything as strings. that's one of its fatal mistakes, IMO. 6model fixes that. now types are proper objects in a MOP.
so my question is, given this, would it be beneficial to think of variables that we want to refer to in an AST as *handles* that we either have already because we got them when declaring the variable, or we can query for them (by using a string and lookup, but that's the only time) ? 21:20
my own intuition says that this is a good idea, but that it'd take a few iterations of the API to make it feel "natural" to use.
one kinda cool side effect of it is -- anonymous/gensym variables. 21:21
in text, we name the variable and that name becomes the textual handle to use later. in the synthetic Qtree, our object handle would be our handle to use later, and we don't technically need to bother with a variable name. 21:22
'night 21:31