On Sun, Sep 27, 2015 at 11:33:26AM +0000, Tim Gallant wrote: > Hi All, > > I'm attempting to create a mustache template parser using the irregex > library. I have the following code: > > (irregex-fold > '(: open-tag (*? (~ #\>)) close-tag) > ... ) > > open-tag and close-tag are variables I have defined in scope. SREs have > their own keywords defined so it just barfs saying open-tag/close-tag > aren't valid keywords.
Hi Tim, This is to be expected; you're quoting the expression, after all. Because the entire expression is quoted, it'll see the _symbol_ open-tag, rather than the value of the identifier represented by that symbol. Basically, you have: (irregex-fold (list ': 'open-tag (list '*? (list '~ #\>)) 'close-tag) ...) While you want: (irregex-fold (list ': open-tag (list '*? (list '~ #\>)) close-tag) ...) The above code would work, but it's rather ugly, so there's a shortcut: instead of quoting the expression, you can quasiquote the expression. This adds an "escape hatch" so you have a quoted list with values that you can selectively have evaluated: (irregex-fold `(: ,open-tag (*? (~ #\>)) ,close-tag) ...) This just says that open-tag and close-tag should be evaluated: it should use the _value_ of the identifier instead of the literal symbol. I hope my explanation was clear to you. It's a bit tricky to explain :) Cheers, Peter
signature.asc
Description: Digital signature
_______________________________________________ Chicken-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-users
