Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(debug-repl) will fail if immutable top-level variable is shadowed by a local variable #7

Closed
florence opened this issue Sep 19, 2016 · 6 comments

Comments

@florence
Copy link
Contributor

florence commented Sep 19, 2016

In:

#lang racket
(require debug/repl)
(define x 10)
(define (f x)
  (+ x (debug-repl)))

Running (f 10) results in:

namespace-set-variable-value!: assignment disallowed;
 cannot re-define a constant
  constant: x
@AlexKnauth
Copy link
Owner

AlexKnauth commented Sep 19, 2016

This is an interesting failure. Do you have any idea if I can create a namespace with a shadowed version?

@florence
Copy link
Contributor Author

I don't know of one. I tried to make one so that resume function I'm implementing florence@b6c2266 could property reset the namespace, and couldn't figure out a way to do it with namespaces.

Maybe the REPL could use a custom #%top that looks in some hash table that has the information about local variable (basically vect from https://github.com/AlexKnauth/debug/blob/master/debug/repl.rkt#L36 ). This feels really ugly, but then again this is scary reflection land. This would have the side effect of fixing #5.

@AlexKnauth
Copy link
Owner

Oh! Ok, I'll try that this afternoon.

@AlexKnauth
Copy link
Owner

Wait, how do I add a #%top macro to a namespace? There's no namespace-set-syntax-transformer-value! as far as I know, and I don't want to rely on define-syntax being bound to the correct thing in the namespace.

@florence
Copy link
Contributor Author

I would have a separate module that's something like:

#lang racket/base
(provide (rename-out [in:top #%top]))
... an implementation ...

then use dynamic-require to get it into the current namespace.

This still isn't great because it can't fall back to the modules #%top. Not sure of a good way around that...

@AlexKnauth
Copy link
Owner

Fixed by 11ce8f0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants