IRC channel logs
2024-03-20.log
back to list of logs
<sneek>This system has been up 1 week, 1 day, 1 hour, 24 minutes <freakingpenguin>Hi Guile! I want to write a macro that takes a function name, then creates a new top-level definition with a modified name (e.g. foo*). I'm having trouble figuring out how to modify the name. <dthompson>freakingpenguin: I would advice not doing that but you're code is missing datum->syntax around the symbol-append <freakingpenguin>dthompson: Fair, I'll probably wind up doing it with functions in the end but now I'm curious. <freakingpenguin>So (define-public ((datum->syntax (symbol-append ...))))? That seems to still have the issue where define is given "(stuff)" and not "stuff", and it still complains about pattern variables if I #,. <freakingpenguin>I thought the pattern variables were weird mini syntax objects. What the heck are they? <dthompson>they can be converted to syntax objects via syntax-quote and friends <dthompson>syntax-case is an odd language but it will start making sense eventually <freakingpenguin>I've not touched match often, does that mean when you move a list through a pattern matcher it loses type information in some capacity? <dthompson>you can think of syntax-case as a pattern matcher for syntax objects <dthompson>I dunno if this helps but it's cool that you can just use syntax-case for whatever: (syntax-case (datum->syntax #f 'foo) () (name #'(list 'name))) <dthompson>like you can just eval this in your repl, completely outside of a macro, and it works <freakingpenguin>I think my problem is I was thinking in terms of (match), not (case). <freakingpenguin>Match binds the pattern variables to their value, but it weirds me out that if (syntax (foo bar)) gives a list of syntax objects, when running syntax-case we need to wrap the pattern variables in (syntax). Shouldn't it already be one? <dthompson>no because syntax bindings are different, they aren't regular variables <dthompson>if it worked as you said, then you couldn't freely reference pattern variables in a syntax-quote form <dthompson>like in my example above I could do #'(list 'name) without having to do anything special to the pattern variable 'name' <dthompson>and it makes the use of ellipsis convenient, etc. <freakingpenguin>Also, nice article on Guile optimizations! You are what I aspire to achieve. :)