> On Sun, Jul 10, 2016 at 8:29 PM, Alex Knauth <alexan...@knauth.org> wrote:
>> I'm doing a weird thing. I'm trying to use the lexical information from a 
>> `(quote-syntax here #:local)` syntax object to access local variables. It 
>> can distinguish between bound and unbound identifiers, because it raises 
>> normal unbound identifier errors unbound ones.
>> 
>> But for the bound ones, I'm getting identifier-out-of-context errors such as
>> 
>> . x: identifier used out of context
>>  context...:
>>  matching binding...:
>>  matching binding...:
>>  context at layer 1...:
>>  matching binding at layer 1...:
>>  matching binding at layer 1...: in: x
>> 
>> It looks like this is because it sees a binding in the syntax object, but 
>> the name isn't in the namespace?
>> 
>> Is that right? Is there a way to fix it?

> On Jul 10, 2016, at 9:36 PM, Robby Findler <ro...@eecs.northwestern.edu> 
> wrote:
> 
> I don't think those variables are in the namespace that eval is using.
> 
> Robby

Ok. Is there a way to set up a namespace that would have those local variables? 
Would a `(#%variable-reference)` help here? Or is there a way to get all of the 
identifiers from the lexical context of a syntax object? 

Alex Knauth

>> 
>> #lang racket/base
>> 
>> (require syntax/strip-context)
>> 
>> ;; debug-repl/stx : Syntax -> Any
>> ;; This should use the lexical information from stx to set up a repl
>> ;; that can access local variables for debugging. It currently fails
>> ;; with identifier-out-of-context errors.
>> (define (debug-repl/stx stx)
>>  (define old-eval (current-eval))
>>  (define (ev e)
>>    (old-eval (replace-context stx e)))
>>  (parameterize ([current-eval ev])
>>    (read-eval-print-loop)))
>> 
>> (define (f x y)
>>  ;; x and y are local variables
>>  (debug-repl/stx (quote-syntax here #:local)))
>> 
>> (f 1 2)
>> 
>> Alex Knauth

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to