#%top provides fallback behavior at compile time, but only in expression 
positions. I think what you want can be done by doing this:

- Under the hood, make variables immutable and have their values be boxes.
- Have (set! x:id expr) and (define x:id expr) both expand to (box-set! x 
expr). This is an expression rather than syntax, so x should expand to (#%top 
x) if x is unbound
- Have #%top somehow magically figure out if it should make a new box or reuse 
an existing one for the identifier it's given.

I'm guessing the syntax you're looking at allows something like this:

function foo(a, b):
  if a < b:
    c = "blah!"
  c = "bloo!"

The outlined expansion strategy would likely produce this:

(define (foo a b)
  (when (< a b)
    (box-set! (#%top c) "blah!"))
  (box-set! (#%top c) "bloo!"))

Then #%top somehow needs to figure out that the proper scope to put c in is the 
function scope of the foo function. Block scope doesn't make much sense here, 
as how else would you get assignment statements where the order isn't known 
until runtime? You could likely do something where `define` surrounds its body 
with some code that sets what the current scope is, maybe by creating a 
free-id-table. At that point however you're doing scope management work 
yourself, so I'm not sure this is a good approach.

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