Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-18 Thread Matthew Flatt
At Thu, 14 Jul 2016 19:07:50 -0400, Alex Knauth wrote:
> 
> > On Jul 14, 2016, at 5:11 PM, Matthew Flatt  wrote:
> > 
> > At Thu, 14 Jul 2016 16:01:52 -0400, Alex Knauth wrote:
> >> Ok, by using `syntax-debug-info` I was able to get somewhere. However, I 
> want 
> >> to make the variables I'm putting into the namespace all immutable. For 
> that I 
> >> thought I could use `define-syntax` within `eval`, but `define-syntax` 
> appears 
> >> to not have any effect:
> >> 
> >> #lang racket/base
> >> (require (for-syntax racket/base))
> >> (define-namespace-anchor a)
> >> (define ns (namespace-anchor->namespace a))
> >> (eval '(define-syntax x (λ (stx) #'333)) ns)
> >> ;; This wasn't an error ... did it work?
> >> (eval 'x ns)
> >> ;. x: undefined;
> >> ; cannot reference an identifier before its definition
> >> ;; Nope.
> >> 
> >> What's going on? Why isn't `(eval '(define-syntax ))` having any 
> >> effect?
> > 
> > I've pushed a repair. It's was a bug in `namespace-anchor->namespace`,
> > which neglected to set a "namespace has become hopeless" bit on the
> > namespace that it returns.
> 
> Oh ok. So if the namespace isn't hopeless, then it knows it doesn't need to 
> preserve transformer bindings, but if it's hopeless it needs to keep 
> everything in case it needs it? Anyway, thanks!
> 
> I've noticed that if it can refer to a module-level immutable variable, 
> `eval` 
> seems to know that it's immutable. So is there any way to define a new 
> variable as immutable in a namespace?

There's not currently an easy way (although it may be possible to bend
`namespace-require/copy` to this purpose).

I think it would make sense to extend `namespace-set-variable-value!`
with an option to install a value as a constant.

-- 
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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-14 Thread mattapiroglu

> I've noticed that if it can refer to a module-level immutable variable, 
> `eval` seems to know that it's immutable. So is there any way to define a new 
> variable as immutable in a namespace?
> 

I believe box-immutable isn't what you're looking for, or would be too obvious 
an answer?

(eval '(define y (box-immutable 1)) ns)

-- 
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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-14 Thread Alex Knauth

> On Jul 14, 2016, at 5:11 PM, Matthew Flatt  wrote:
> 
> At Thu, 14 Jul 2016 16:01:52 -0400, Alex Knauth wrote:
>> Ok, by using `syntax-debug-info` I was able to get somewhere. However, I 
>> want 
>> to make the variables I'm putting into the namespace all immutable. For that 
>> I 
>> thought I could use `define-syntax` within `eval`, but `define-syntax` 
>> appears 
>> to not have any effect:
>> 
>> #lang racket/base
>> (require (for-syntax racket/base))
>> (define-namespace-anchor a)
>> (define ns (namespace-anchor->namespace a))
>> (eval '(define-syntax x (λ (stx) #'333)) ns)
>> ;; This wasn't an error ... did it work?
>> (eval 'x ns)
>> ;. x: undefined;
>> ; cannot reference an identifier before its definition
>> ;; Nope.
>> 
>> What's going on? Why isn't `(eval '(define-syntax ))` having any effect?
> 
> I've pushed a repair. It's was a bug in `namespace-anchor->namespace`,
> which neglected to set a "namespace has become hopeless" bit on the
> namespace that it returns.

Oh ok. So if the namespace isn't hopeless, then it knows it doesn't need to 
preserve transformer bindings, but if it's hopeless it needs to keep everything 
in case it needs it? Anyway, thanks!

I've noticed that if it can refer to a module-level immutable variable, `eval` 
seems to know that it's immutable. So is there any way to define a new variable 
as immutable in a namespace?

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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-14 Thread Matthew Flatt
At Thu, 14 Jul 2016 16:01:52 -0400, Alex Knauth wrote:
> Ok, by using `syntax-debug-info` I was able to get somewhere. However, I want 
> to make the variables I'm putting into the namespace all immutable. For that 
> I 
> thought I could use `define-syntax` within `eval`, but `define-syntax` 
> appears 
> to not have any effect:
> 
> #lang racket/base
> (require (for-syntax racket/base))
> (define-namespace-anchor a)
> (define ns (namespace-anchor->namespace a))
> (eval '(define-syntax x (λ (stx) #'333)) ns)
> ;; This wasn't an error ... did it work?
> (eval 'x ns)
> ;. x: undefined;
> ; cannot reference an identifier before its definition
> ;; Nope.
> 
> What's going on? Why isn't `(eval '(define-syntax ))` having any effect?

I've pushed a repair. It's was a bug in `namespace-anchor->namespace`,
which neglected to set a "namespace has become hopeless" bit on the
namespace that it returns.

-- 
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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-14 Thread Alex Knauth
Ok, by using `syntax-debug-info` I was able to get somewhere. However, I want 
to make the variables I'm putting into the namespace all immutable. For that I 
thought I could use `define-syntax` within `eval`, but `define-syntax` appears 
to not have any effect:

#lang racket/base
(require (for-syntax racket/base))
(define-namespace-anchor a)
(define ns (namespace-anchor->namespace a))
(eval '(define-syntax x (λ (stx) #'333)) ns)
;; This wasn't an error ... did it work?
(eval 'x ns)
;. x: undefined;
; cannot reference an identifier before its definition
;; Nope.

What's going on? Why isn't `(eval '(define-syntax ))` having any effect?

Or is there any other way to define a transformer binding into a namespace?

Alex Knauth

> On Jul 13, 2016, at 8:51 PM, Alex Knauth  wrote:
> 
> Would `syntax-debug-info` help here? Would the `'bindings` option have the 
> information I want?
> 
> Alex Knauth
> 
>> On Wed, Jul 13, 2016 at 6:32 PM, Alex Knauth  wrote:
>>> 
>> At Wed, 13 Jul 2016 14:16:11 -0400, Alex Knauth wrote:
>>> 
>>> Thanks. So defining it as a function won't work. But if I define it as a
>>> macro, can I get more information out of it?

-- 
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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-13 Thread Alex Knauth

> On Jul 13, 2016, at 7:46 PM, Robby Findler  
> wrote:
> 
> I don't think that either of the options I suggested require you to do that.
> 
> The debugger works as a post-expansion process that rewrites the
> program. A language could use a similar approach, but work only for
> the files in that language.
> 
> Robby

Oh, yes. I could do this after expansion. But if I can define it as a macro 
that looks at the lexical context locally that would be so much better (and 
easier) than using a whole-program transformation.

Would `syntax-debug-info` help here? Would the `'bindings` option have the 
information I want?

Alex Knauth

> On Wed, Jul 13, 2016 at 6:32 PM, Alex Knauth  wrote:
>> 
>>> On Jul 13, 2016, at 7:25 PM, Robby Findler  
>>> wrote:
>>> 
>>> You could define a language. Or you could do what DrRacket's debugger is 
>>> doing?
>>> 
>>> Robby
>> 
>> That would would if I was willing to re-define every possible binding form 
>> that could ever be used. But then if I import something like `match`, or 
>> `generic-bind`, or `syntax-parse`, it won't give it the information it needs 
>> to create the repl. I would have to re-define all of those libraries as well.
>> 
>> That's why I would much rather see if I can use the lexically bound 
>> identifiers from the lexical context of the syntax object, if that's 
>> possible.
>> 
>> Alex Knauth
>> 
>>> On Wed, Jul 13, 2016 at 2:33 PM, Alex Knauth  wrote:
 
> On Jul 13, 2016, at 3:28 PM, Matthew Flatt  wrote:
> 
> At Wed, 13 Jul 2016 14:16:11 -0400, Alex Knauth wrote:
>> 
>> Thanks. So defining it as a function won't work. But if I define it as a
>> macro, can I get more information out of it?
> 
> Instead of
> 
> (define (f x y)
> ;; x and y are local variables
> (debug-repl/stx))
> 
> you could create a `define-buggy`
> 
> (define-buggy (f x y)
> ;; x and y are local variables
> (debug-repl/stx))
> 
> where `define-buggy` expands to include references to `x` and `y`,
> perhaps in cooperation with `debug-repl/stx`:
> 
> (define-values (f)
> (lambda (x y)
>   ;; x and y are local variables
>   (debug-repl (hash 'x x 'y y
> 
> Of course, you can also set up a language where `define` means
> `define-buggy` or where `#%module-begin` parses its expanded body.
> The "Debug" button in DrRacket works something like that, but it's
> implemented as an external pass over the output of `expand`, instead of
> as a macro.
 
 But then if there were any local variables introduced by any form that I 
 didn't define as a "buggy" version, those wouldn't be included. Is there 
 any way to get a macro to expand to the `(hash 'x x 'y y)` stuff?
 
 It has to be in the lexical context of the syntax object somewhere, 
 because the original function I made could distinguish between bound and 
 unbound variables. Would there be a way to get a list of all the local 
 variables in the lexical context?
 
 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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-13 Thread Robby Findler
I don't think that either of the options I suggested require you to do that.

The debugger works as a post-expansion process that rewrites the
program. A language could use a similar approach, but work only for
the files in that language.

Robby

On Wed, Jul 13, 2016 at 6:32 PM, Alex Knauth  wrote:
>
>> On Jul 13, 2016, at 7:25 PM, Robby Findler  
>> wrote:
>>
>> You could define a language. Or you could do what DrRacket's debugger is 
>> doing?
>>
>> Robby
>
> That would would if I was willing to re-define every possible binding form 
> that could ever be used. But then if I import something like `match`, or 
> `generic-bind`, or `syntax-parse`, it won't give it the information it needs 
> to create the repl. I would have to re-define all of those libraries as well.
>
> That's why I would much rather see if I can use the lexically bound 
> identifiers from the lexical context of the syntax object, if that's possible.
>
> Alex Knauth
>
>> On Wed, Jul 13, 2016 at 2:33 PM, Alex Knauth  wrote:
>>>
 On Jul 13, 2016, at 3:28 PM, Matthew Flatt  wrote:

 At Wed, 13 Jul 2016 14:16:11 -0400, Alex Knauth wrote:
>
> Thanks. So defining it as a function won't work. But if I define it as a
> macro, can I get more information out of it?

 Instead of

 (define (f x y)
  ;; x and y are local variables
  (debug-repl/stx))

 you could create a `define-buggy`

 (define-buggy (f x y)
  ;; x and y are local variables
  (debug-repl/stx))

 where `define-buggy` expands to include references to `x` and `y`,
 perhaps in cooperation with `debug-repl/stx`:

 (define-values (f)
  (lambda (x y)
;; x and y are local variables
(debug-repl (hash 'x x 'y y

 Of course, you can also set up a language where `define` means
 `define-buggy` or where `#%module-begin` parses its expanded body.
 The "Debug" button in DrRacket works something like that, but it's
 implemented as an external pass over the output of `expand`, instead of
 as a macro.
>>>
>>> But then if there were any local variables introduced by any form that I 
>>> didn't define as a "buggy" version, those wouldn't be included. Is there 
>>> any way to get a macro to expand to the `(hash 'x x 'y y)` stuff?
>>>
>>> It has to be in the lexical context of the syntax object somewhere, because 
>>> the original function I made could distinguish between bound and unbound 
>>> variables. Would there be a way to get a list of all the local variables in 
>>> the lexical context?
>>>
>>> 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.
>>
>> --
>> 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.
>

-- 
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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-13 Thread Alex Knauth

> On Jul 13, 2016, at 7:25 PM, Robby Findler  
> wrote:
> 
> You could define a language. Or you could do what DrRacket's debugger is 
> doing?
> 
> Robby

That would would if I was willing to re-define every possible binding form that 
could ever be used. But then if I import something like `match`, or 
`generic-bind`, or `syntax-parse`, it won't give it the information it needs to 
create the repl. I would have to re-define all of those libraries as well.

That's why I would much rather see if I can use the lexically bound identifiers 
from the lexical context of the syntax object, if that's possible.

Alex Knauth

> On Wed, Jul 13, 2016 at 2:33 PM, Alex Knauth  wrote:
>> 
>>> On Jul 13, 2016, at 3:28 PM, Matthew Flatt  wrote:
>>> 
>>> At Wed, 13 Jul 2016 14:16:11 -0400, Alex Knauth wrote:
 
 Thanks. So defining it as a function won't work. But if I define it as a
 macro, can I get more information out of it?
>>> 
>>> Instead of
>>> 
>>> (define (f x y)
>>>  ;; x and y are local variables
>>>  (debug-repl/stx))
>>> 
>>> you could create a `define-buggy`
>>> 
>>> (define-buggy (f x y)
>>>  ;; x and y are local variables
>>>  (debug-repl/stx))
>>> 
>>> where `define-buggy` expands to include references to `x` and `y`,
>>> perhaps in cooperation with `debug-repl/stx`:
>>> 
>>> (define-values (f)
>>>  (lambda (x y)
>>>;; x and y are local variables
>>>(debug-repl (hash 'x x 'y y
>>> 
>>> Of course, you can also set up a language where `define` means
>>> `define-buggy` or where `#%module-begin` parses its expanded body.
>>> The "Debug" button in DrRacket works something like that, but it's
>>> implemented as an external pass over the output of `expand`, instead of
>>> as a macro.
>> 
>> But then if there were any local variables introduced by any form that I 
>> didn't define as a "buggy" version, those wouldn't be included. Is there any 
>> way to get a macro to expand to the `(hash 'x x 'y y)` stuff?
>> 
>> It has to be in the lexical context of the syntax object somewhere, because 
>> the original function I made could distinguish between bound and unbound 
>> variables. Would there be a way to get a list of all the local variables in 
>> the lexical context?
>> 
>> 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.
> 
> -- 
> 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.

-- 
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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-13 Thread Robby Findler
You could define a language. Or you could do what DrRacket's debugger is doing?

Robby

On Wed, Jul 13, 2016 at 2:33 PM, Alex Knauth  wrote:
>
>> On Jul 13, 2016, at 3:28 PM, Matthew Flatt  wrote:
>>
>> At Wed, 13 Jul 2016 14:16:11 -0400, Alex Knauth wrote:
>>>
>>> Thanks. So defining it as a function won't work. But if I define it as a
>>> macro, can I get more information out of it?
>>
>> Instead of
>>
>> (define (f x y)
>>   ;; x and y are local variables
>>   (debug-repl/stx))
>>
>> you could create a `define-buggy`
>>
>> (define-buggy (f x y)
>>   ;; x and y are local variables
>>   (debug-repl/stx))
>>
>> where `define-buggy` expands to include references to `x` and `y`,
>> perhaps in cooperation with `debug-repl/stx`:
>>
>> (define-values (f)
>>   (lambda (x y)
>> ;; x and y are local variables
>> (debug-repl (hash 'x x 'y y
>>
>> Of course, you can also set up a language where `define` means
>> `define-buggy` or where `#%module-begin` parses its expanded body.
>> The "Debug" button in DrRacket works something like that, but it's
>> implemented as an external pass over the output of `expand`, instead of
>> as a macro.
>
> But then if there were any local variables introduced by any form that I 
> didn't define as a "buggy" version, those wouldn't be included. Is there any 
> way to get a macro to expand to the `(hash 'x x 'y y)` stuff?
>
> It has to be in the lexical context of the syntax object somewhere, because 
> the original function I made could distinguish between bound and unbound 
> variables. Would there be a way to get a list of all the local variables in 
> the lexical context?
>
> 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.

-- 
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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-13 Thread Alex Knauth

> On Jul 13, 2016, at 3:28 PM, Matthew Flatt  wrote:
> 
> At Wed, 13 Jul 2016 14:16:11 -0400, Alex Knauth wrote:
>> 
>> Thanks. So defining it as a function won't work. But if I define it as a 
>> macro, can I get more information out of it?
> 
> Instead of
> 
> (define (f x y)
>   ;; x and y are local variables
>   (debug-repl/stx))
> 
> you could create a `define-buggy`
> 
> (define-buggy (f x y)
>   ;; x and y are local variables
>   (debug-repl/stx))
> 
> where `define-buggy` expands to include references to `x` and `y`,
> perhaps in cooperation with `debug-repl/stx`:
> 
> (define-values (f)
>   (lambda (x y)
> ;; x and y are local variables
> (debug-repl (hash 'x x 'y y
> 
> Of course, you can also set up a language where `define` means
> `define-buggy` or where `#%module-begin` parses its expanded body.
> The "Debug" button in DrRacket works something like that, but it's
> implemented as an external pass over the output of `expand`, instead of
> as a macro.

But then if there were any local variables introduced by any form that I didn't 
define as a "buggy" version, those wouldn't be included. Is there any way to 
get a macro to expand to the `(hash 'x x 'y y)` stuff?

It has to be in the lexical context of the syntax object somewhere, because the 
original function I made could distinguish between bound and unbound variables. 
Would there be a way to get a list of all the local variables in the lexical 
context? 

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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-13 Thread Matthew Flatt
At Wed, 13 Jul 2016 14:16:11 -0400, Alex Knauth wrote:
> 
> > On Jul 13, 2016, at 11:22 AM, Matthew Flatt  wrote:
> > 
> > At Wed, 13 Jul 2016 11:10:30 -0400, Alex Knauth wrote:
> >> 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? 
> > 
> > No, there's no way to dynamically access a location that corresponds to
> > a local variable. Every reference to a local variable must be apparent
> > in a fully expanded expression; the compiler doesn't support access
> > after the fact.
> 
> Thanks. So defining it as a function won't work. But if I define it as a 
> macro, can I get more information out of it?

Instead of

 (define (f x y)
   ;; x and y are local variables
   (debug-repl/stx))

you could create a `define-buggy`

 (define-buggy (f x y)
   ;; x and y are local variables
   (debug-repl/stx))

where `define-buggy` expands to include references to `x` and `y`,
perhaps in cooperation with `debug-repl/stx`:

 (define-values (f)
   (lambda (x y)
 ;; x and y are local variables
 (debug-repl (hash 'x x 'y y

Of course, you can also set up a language where `define` means
`define-buggy` or where `#%module-begin` parses its expanded body.
The "Debug" button in DrRacket works something like that, but it's
implemented as an external pass over the output of `expand`, instead of
as a macro.

-- 
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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-13 Thread Alex Knauth

> On Jul 13, 2016, at 11:22 AM, Matthew Flatt  wrote:
> 
> At Wed, 13 Jul 2016 11:10:30 -0400, Alex Knauth wrote:
>> 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? 
> 
> No, there's no way to dynamically access a location that corresponds to
> a local variable. Every reference to a local variable must be apparent
> in a fully expanded expression; the compiler doesn't support access
> after the fact.

Thanks. So defining it as a function won't work. But if I define it as a macro, 
can I get more information out of it?

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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-13 Thread Matthew Flatt
At Wed, 13 Jul 2016 11:10:30 -0400, Alex Knauth wrote:
> 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? 

No, there's no way to dynamically access a location that corresponds to
a local variable. Every reference to a local variable must be apparent
in a fully expanded expression; the compiler doesn't support access
after the fact.

-- 
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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-13 Thread Alex Knauth

> On Sun, Jul 10, 2016 at 8:29 PM, Alex Knauth  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  
> 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.


Re: [racket-users] identifier-out-of-context when trying to make a debug-repl

2016-07-10 Thread Robby Findler
I don't think those variables are in the namespace that eval is using.

Robby


On Sun, Jul 10, 2016 at 8:29 PM, Alex Knauth  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?
>
> #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.

-- 
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.