Perl 6 - the future is here, just unevenly distributed

IRC log for #6macros, 2015-08-17

| Channels | #6macros index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
04:11 masak :)
04:11 masak I think you'll have to explain that last one a bit.
04:14 masak also, I see faux_combinator (I looked at the Perl version) parsing a few things, but I'm pretty sure I'm not seeing the whole picture.
09:18 vendethiel hahaha, I certainly was too lazy to write docs 15 times
09:19 vendethiel I just did that because I was bored without internet
09:19 vendethiel commuting&
11:38 Ven joined #6macros
12:01 Ven joined #6macros
13:45 Ven joined #6macros
13:46 Ven masak: ping me when you're here :)
14:00 masak I'm here, but backlogging/jetlagged.
14:00 masak well, except when I'm not here :P
14:08 Ven joined #6macros
14:38 * Ven waves at masak
14:38 Ven alright
14:39 Ven I forgot to check irclog
14:39 masak :)
14:39 Ven so - yeah. nothing to see more to this project than what I've done
14:40 Ven I just wanted to "check" if I was able to code something like this in X languages
14:40 Ven (they had to be dynamically typed, mostly)
14:40 masak nice :)
14:40 Ven that's pretty much my first perl5 program, btw, so I'd love any comment on that
14:41 Ven I very much like the racket DSL, if you read the tests
14:41 Ven that looks like a DSL I'd love to be able to emulate "everywhere"
14:42 masak I feel like you are telling me these things, but I have next to no context to evaluate them in, so I don't know what to do with them.
14:43 Ven ;)
14:43 Ven I'm getting to it.
14:43 Ven https://github.com/faux-combinator/racket/blob/master/tests/parser.rkt#L19
14:43 masak I'm usually good at remembering stuff, so I'm going to assume that I'm *actually* missing a lot of context, and not having memory loss. :)
14:43 Ven that's an example usage of the DSL.
14:43 masak ok
14:43 Ven make-parser is a very simple thunking macro
14:43 Ven that evaluates the thunk with a parameter (parameters = dynamic variables in racket) set as a new parser
14:44 Ven in perl6-with-masak's-macros, it'd be something like:
14:44 Ven (from your THUNK blogpost)
14:45 Ven sub make-parser(THUNK $fn) { -> $tokens-to-parse { my $*parser = Parser.new(tokens => $tokens-to-parse); $fn(); }; }
14:45 Ven basically. it just wraps around a lambda that expects the tokens to be passed
14:45 Ven (That's what I store `make-parser`'s return value and call it later)
14:46 Ven that lambda will create a new parser instance, and install it in the dynamic scope for the thunk call
14:46 masak aha
14:46 Ven the implementation is easy enough: https://github.com/faux-combinator/racket/blob/master/parser.rkt#L23-L31
14:48 Ven `expect` is the only call that doesn't thunk.
14:48 Ven all the other will thunk
14:49 Ven `maybe` will save the tokens, call its thunk, and restore the tokens on failure
14:50 Ven sub maybe(THUNK $fn) { my @tokens = $*parser.tokens.clone; return $fn(); CATCH { default { $*parser.tokens = @tokens; return Nil; } } }
14:50 Ven something like this
14:50 Ven and then, everything is implemented on top of this
14:55 Ven so, that's a nice DSL (at least, I think so), and I think it'd basically be implementable with your THUNK proposal
14:55 Ven (all the "define-syntax-rules" in parser.rkt are just thunking, IIRC)
14:58 Ven the only think missing from your proposal would be the splatted, THUNK *@thunks version, I think.
15:00 masak ok
15:00 masak I'm not sure I see how to make it feel "p6ish"
15:00 masak but I will think about it
15:00 Ven well, we have grammars
15:01 Ven that's why I didn't code a perl6 version of that code anyway.
15:01 Ven I just want to show that it's actually a big step
15:01 Ven well, it's not like you had no idea anyway..;)
15:02 masak :)
15:03 Ven I'm wondering a lot about define-syntax-rules
15:03 Ven it might be a good way "forward" to solve some of our problems (with regards to parsing and all), but it's a very hard thing to do
15:03 Ven *especially* in perl6's context
15:03 Ven the part I linked to you yesterday
15:03 Ven https://github.com/faux-combinator/racket/blob/master/helpers.rkt#L12
15:04 Ven first off, I need to define what "it" is: https://github.com/faux-combinator/racket/blob/master/helpers.rkt#L6-L8
15:04 Ven that means "it" will be replaced by *something* at the syntax transformation level
15:04 Ven if it's used outside, it'll error with the given lambda
15:05 masak ok
15:05 Ven that's the way to introduce names to break hygiene in racket
15:06 Ven if they are reused by other construct
15:06 Ven code produced by a macro in racket uses #', which is a shortcut for (syntax ...), like ' is (quote ...)
15:06 Ven another way to do this is to "install" syntax, lexically:
15:06 Ven https://github.com/vendethiel/brain.rkt/blob/master/helpers.rkt#L34-36
15:07 Ven here, I'm crafting an identifier for the getter, and installing it in the macro's lexical scope
15:11 Ven note:
15:12 Ven the NAME is introduced. it's just "registered" by the... compiler, or whatever. and, then I can use it
15:22 Ven joined #6macros
15:41 Ven joined #6macros

| Channels | #6macros index | Today | | Search | Google Search | Plain-Text | summary