Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded? (Greg Hendershott)

2014-01-20 Thread Matthias Felleisen
ntax-local-value ... how is the struct name > overloaded? (Carl Eastlund) >2. Re: Structs and syntax-local-value ... how is the struct name > overloaded? (Greg Hendershott) > > > ------ > >

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded? (Greg Hendershott)

2014-01-20 Thread Sam Tobin-Hochstadt
t;> (define-syntax my-fn 'something) then it works with >>>> >>>>> syntax-local-value but >>>> >>>>> any attempts to use it as a transformer result in illegal syntax. >>>> >>>>> >>>> >>>>

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded? (Greg Hendershott)

2014-01-20 Thread Carl Eastlund
users digest..." >>>> >>>> >>>> [Racket Users list: >>>> http://lists.racket-lang.org/users ] >>>> >>>> >>>> Today's Topics: >>>> >>>>1. Re: Structs and syntax-local-value ...

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded? (Greg Hendershott)

2014-01-20 Thread Scott Klarenbach
how is the struct name >>> overloaded? (Carl Eastlund) >>>2. Re: Structs and syntax-local-value ... how is the struct name >>> overloaded? (Greg Hendershott) >>> >>> >>> --

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded? (Greg Hendershott)

2014-01-20 Thread Carl Eastlund
. Re: Structs and syntax-local-value ... how is the struct name >> overloaded? (Greg Hendershott) >> >> >> ------------------ >> >> Message: 1 >> Date: Mon, 20 Jan 2014 13:00:35 -0500 >> From: Ca

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded? (Greg Hendershott)

2014-01-20 Thread Sam Tobin-Hochstadt
On Mon, Jan 20, 2014 at 6:31 PM, Scott Klarenbach wrote: >> If/when it does matter, instead you could use a hashtable on the side, >> mapping from the procedure to the info. Of course that way, you need >> to use `(lookup thing)` to get the info. > > > Not to mention that it's vastly simpler to do

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded? (Greg Hendershott)

2014-01-20 Thread Scott Klarenbach
> > Message: 1 > Date: Mon, 20 Jan 2014 13:00:35 -0500 > From: Carl Eastlund > To: "Alexander D. Knauth" > Cc: Scott Klarenbach , Racket mailing list > > Subject: Re: [racket] Structs and

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded?

2014-01-20 Thread Greg Hendershott
>> and prop:procedure is how you make a procedure that can also be something >> else. One thing to keep in mind is that there is _some_ overhead. In my recent experience, applying via prop:procedure took roughly 1.6X the time as applying a plain procedure. (This with the variant of prop:procedure

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded?

2014-01-20 Thread Carl Eastlund
Yes, that's exactly it. Carl Eastlund On Mon, Jan 20, 2014 at 10:13 AM, Alexander D. Knauth wrote: > I'm just curious, is this what you mean? > > #lang racket > > (require rackunit > (for-syntax > syntax/parse)) > > (begin-for-syntax > (struct proc-with-info (proc info) #:p

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded?

2014-01-20 Thread Alexander D. Knauth
I'm just curious, is this what you mean? #lang racket (require rackunit (for-syntax syntax/parse)) (begin-for-syntax (struct proc-with-info (proc info) #:property prop:procedure (struct-field-index proc))) (define-syntax thing (proc-with-info (lambda (stx)

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded?

2014-01-19 Thread Carl Eastlund
It sounds like you've got it. A syntax transformer must be a procedure, and prop:procedure is how you make a procedure that can also be something else. So if you want something to be both a syntax transformer and a struct binding, for instance, you need to use prop:procedure and prop:struct-info.

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded?

2014-01-19 Thread Scott Klarenbach
> > That doesn't look like a complete program; what does #'done refer to? And > where did the "val is: " printout go? That's just a quick hack for illustration purposes. #''done is just something to return. (note the two quotes) The output is: val is: ## 'done But your supposition is correct:

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded?

2014-01-19 Thread Carl Eastlund
That doesn't look like a complete program; what does #'done refer to? And where did the "val is: " printout go? But your supposition is correct: posn is always bound as syntax to a self-ctor-checked-struct-info-object. That object works as a syntax transformer; run time references to posn are tr

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded?

2014-01-19 Thread Scott Klarenbach
It's not changing it, I'm just trying to figure out the implementation and understand what I'm seeing. For example, given this: (struct posn (x y)) (define-syntax (test stx) (syntax-case stx () [(_ x) (printf "val is: ~s" (syntax-local-value #'posn)) #''done])) > posn # > (test x) # I'm su

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded?

2014-01-19 Thread Carl Eastlund
If syntax-local-value is returning something other than the value you put in, that's a bug. It shouldn't be wrapping it or changing it in any way. Do you have a program where you bind something via define-syntax that satisfies struct-info?, and get something out via syntax-local-value that doesn't

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded?

2014-01-19 Thread Scott Klarenbach
But I don't see how the same binding can be a transformer and also return something else (like a list, or a checked-struct-info-thing) via syntax-local-value. If I bind my-fn as a transformer, then any other macros that use it with syntax-local-value will receive the transformer procedure back, no

Re: [racket] Structs and syntax-local-value ... how is the struct name overloaded?

2014-01-19 Thread Carl Eastlund
Yes, I believe that the name of a structure defined by "struct" is bound at syntax-time to a value that implements both prop:procedure, so that it can expand to a use of the constructor when used in an expression, and prop:struct-info so that it can be use to look up static information when passed

[racket] Structs and syntax-local-value ... how is the struct name overloaded?

2014-01-19 Thread Scott Klarenbach
How is it that the definition of (struct my-name (x y)) can bind *my-name*both as a # at runtime and a transformer-binding *my-name* that at compile time (via syntax-local-value) produces #.? Or, put another way, how can I define a transformer *my-fn* that produces syntax, but that also exposes hi