Re: [racket] Lazy syntax class attributes

2013-05-31 Thread Sam Tobin-Hochstadt
On Fri, May 31, 2013 at 4:42 PM, Ryan Culpepper wrote: > > Note, however, that the syntax class now uses #:attr instead of #:with. > That's the main usability issue I'm worried about with this change. > Following with-syntax's lead, a #:with clause automatically converts its > right-hand side to s

Re: [racket] Lazy syntax class attributes

2013-05-31 Thread Ryan Culpepper
On 05/31/2013 02:47 AM, Eric Dobson wrote: I'm working on code (TR optimizer) that needs to match some expressions and then compute an attribute based on the expression. I would like to abstract this out as a syntax class. Example is below: #lang racket (require syntax/parse) (define-syntax-cla

Re: [racket] syntax-parse, macros, and literal-sets

2013-05-31 Thread Ryan Culpepper
This might answer some of your questions: http://macrologist.blogspot.com/2011/09/syntax-parse-and-literals.html Ryan On 05/31/2013 02:30 AM, Eric Dobson wrote: Ok given the complexities of literal-sets and hygiene, I think I will avoid them if I can. The issue is that I cannot seem to get th

Re: [racket] Lazy syntax class attributes

2013-05-31 Thread Matthias Felleisen
You would have to implement laziness for attributes manually -- I think. But I don't have time to play with code and get an example to work right now. -- Matthias On May 31, 2013, at 11:00 AM, Eric Dobson wrote: > That seems like a a workable amount of overhead, but I'm not sure what > you ar

Re: [racket] Lazy syntax class attributes

2013-05-31 Thread Eric Dobson
That seems like more syntax in the use than just #`(complicated #,((attribute e.v))), which I can get with just thunking the computation. The thunk it self can manipulate a promise to make sure the effects only happen once. I'm pretty sure I could use a rename transformer struct property and a cha

Re: [racket] Lazy syntax class attributes

2013-05-31 Thread J. Ian Johnson
You could also make a compile-time macro that will introduce several identifier macros to your syntax-class pattern right-hand-sides like (define-lazy-syntax-class blah (pattern pat #:lazy-wrap [complicated (e.v ...)] rhs ...) ...) => ;; generate ((force-e.v ...) ...) (define-syntax-class bla

Re: [racket] Lazy syntax class attributes

2013-05-31 Thread Eric Dobson
That seems like a a workable amount of overhead, but I'm not sure what you are suggesting the v attribute to be bound as. It might have not been obvious from my my example that its value depends on the slow computation, so unless pattern variables can be mutated I'm not sure how force-all can chang

Re: [racket] Lazy syntax class attributes

2013-05-31 Thread Matthias Felleisen
Can you prefix the #'(complicated ..) expression with a form that forces all lazy computations so that complicated itself remains the same? (let () (force-all) #'(complicated (form e.v))) where force-all is defined via a begin in the slow syntax class? -- Matthias On May 31, 2013, at 2:4