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.
02:49 ilbot3 joined
masak backlogs 08:41
Ven: IIUC, the splicing you're doing is something like "flatten this array into the quasi", yes? 08:42
Ven: the closest thing I've come to thinking about such things is that there should maybe be a looseness/forgiveness between things like ArgumentList and List 08:43
09:21 Ven joined
Ven masak: no, it's not flattening 09:21
the first "obvious" thing to try would be ,,fields. with the macro called as in: (defstruct! s a b c), then fields is (a b c) 09:22
so, the issue with ,,fields is that the generated code would be ,(a b c) – it sees it as a function!
.oO( Homoiconicity gone wrong )
09:23
so I need to requote it, that is ,',fields
(I'm not too sure what you mean by flattening – ,@ ?)
masak yeah, probably meant that
I still have trouble sometimes reading Lisp quasi/unquoting syntax :) 09:24
seems frankly a lot of Lisp's syntax, proportionally, is spent on quasis and unquoting :P
Ven very true. say fields is '(a b c), then `(progn ,fields) gives (progn (a b c)) 09:26
however `(progn ,@fields) is (progn a b c) 09:27
masak right
with you so far
and it *really* helps to see examples like that -- thank you :)
Ven there's no such thing in our syntax that I'm aware of, which I could assimilate it with
masak in 007's syntax? 09:28
let's put together a use case so we can look at it in terms of 007
I mean, "flattening" might simply not be a thing in 007 because 007 does not do sexprs
oh! but you were talking about re-quoting, not flattening... :) 09:29
the ,', thing
Ven yes. but I think this ,', trick is mostly needed because of how lisp quasiquotes work.
(as in: no hygiene)
masak that's my suspicion too
wonder how the same thing manifests in Scheme, then?
Ven ,fields would not find a "fields" variable, since it'd only look into current-quasiquote-minus-one 09:30
(since each quasiquote level has its own lexical scope "level")
masak oh, right 09:32
not even sure how to render that as a 007 thought :)
Ven Right. 09:56
One question still. 10:00
quasi { quasi { x } } – how to unquote this one?
unquote(unquote(a)) ?
masak I feel like fielding that one to TimToady
but according to his WoG from way back, you can only unquote once in such a situation, and it goes "all the way out" 10:01
Ven augh.
masak guess you can do more precise things using synthetics
Ven ?
masak new Q::Identifier { ... } and the like 10:02
Ven ah, yes
(which reminds me that I started to work a bit on 007 regex, but with work+projects for school as a teacher+projects for school as a student, I just don't have the time for now) 10:03
masak I might task-steal that soon 10:04
as soon as I have the tuits :)
a few cool macro things are blocking on `is parsed`, which is blocking on more fleshed-out regexes
Ven well, is there any use to a not-fully-unquoted splice?
masak dunno 10:07
Ven I was thinking of *code walking* (*gasp!*) 10:10
masak go on... 10:11
Ven I was re-reading 50 years of lisp, as I mentioned earlier, and stumbled on codewaling as part of this
walking*, sorry 10:12
masak nodnod
Ven the way CL does it is by injecting macros instead of manual code-walking
so, in no particular order:
1) how hard would that be for us with our strict lexical rules?
2) does having an actual AST to manipulate (where we know what is what) make it easier to manipulate it correctly than the simplicity lisp has? 10:13
masak re 2, yes, possibly
Ven case in point for 2): (let ((x x)) x) => if you want to code-walk, you should only replace the 2nd x with whatever it is you want, nothing else
masak re 1, how hard would what be? injecting macros? or code walking?
Ven not sure, I'm going to off on 2) for now
masak I have an issue for code walking: github.com/masak/007/issues/26 10:14
nothing in theory to prevent us trying it out today in 007
Ven so, continuing – if we can inject a "lexical reference"(?), this is a non-issue in 007
masak could you elaborate on "lexical reference"?
Ven yes, I'm just slow at typing P) 10:15
masak sounds related to the .frame that identifiers have in 007
Ven because if we do code-walking, inject('x', macro :: { 5 }, quasi { my x = OUTER::x; { my x = OUTER::x; say x; } }) will only replace the first OUTER::x 10:16
by the very definition of our lexical scopes
(or { quasi x }, I guess. I suppose OUTER::x isn't the best way to examplify it, but it's the closest I have to (let ((x x)) x) in CL...)
what's to be seen here is that there's a very clear difference between *code walking* ("ast walking" in our case, which is the style most of my pseudo-007 gists use) 10:18
and *replacing an identifier to be a macro in some AST slice* (which is closer to what macrolet is)
but if "my macro" works, I think `macrolet` already exists in 007 10:19
masak I'm trying to follow the example, but I'm confused 10:21
let's focus on "will only replace the first OUTER::x"
why? :)
Ven because that's how lexical scope works. inject('x', something) ("macrolet") creates a "my x". The subsequent ones don't refer to the same variable – the same lexical "reference"/variable 10:24
masak ok, I provisionally buy that 10:37
Ven so, the (let ((x x)) x) case that's so hard to work with in Lisp doesn't exist for us. Hygiene! 10:38
masak :) 10:44
Ven Code-walking like I usually do in my pseudo-007 gist doesn't seem to offer the same kind of safety however 10:53
masak did you check issue #26? any thoughts? 11:01
Ven looks somewhat like the one I "use" 11:05
masak \\o/ 11:06
Ven *looks for gists* 11:07
gist.github.com/vendethiel/bff772fc084ca88bb253 11:08
one of those 11:09
masak nodnod 11:53
cog_ does any of you has read Lisp in Small Pieces ? Is it any good ? Written by a Fench guy apparently. Cocorico !! 15:08
oops ven not there :( 15:09
masak I've read about a third of it 15:16
it's pretty good
it has all-5 reviews on amazon. I can kind of see why 15:19
they also point out that it ain't a beginners' book
I agree with that
I remember liking the early discussions about continuations (in ch3 or so), while my brain was also melting
sheesh. news.ycombinator.com/item?id=13754064 15:22
oops, ww :)
(except that macros will maybe make you a 100x programmer!) :P 15:23
cog_ yea, the subject is vast. Also, it seems that the new trend is to blend macros with type theory. Scala has many papers way over my head. My height does not help here :( 17:16
19:29 Ven joined