Re: [racket-users] Re: catch and bind an unbound id in a macro

2019-04-21 Thread zeRusski
On Saturday, 20 April 2019 23:55:50 UTC+1, Stephen Chang wrote: > > fwiw, I think here is a working version along the lines of your > original attempt. > I see what you did there. This is both icky (as requested) and cute :0 Thanks, it's actually illuminating -- You received this message b

Re: [racket-users] Re: catch and bind an unbound id in a macro

2019-04-20 Thread Stephen Chang
fwiw, I think here is a working version along the lines of your original attempt. #lang racket (require (for-syntax syntax/parse)) (define-syntax set/define (syntax-parser [(_ h k v) #:when (with-handlers ([exn:fail:syntax:unbound? (lambda _ #f)]) (local-expand #'h 'expre

Re: [racket-users] Re: catch and bind an unbound id in a macro

2019-04-20 Thread Shu-Hung You
identifier-binding returns #f for top-level bindings. I believe make-base-eval is evaluating expressions at top-level. On Sat, Apr 20, 2019 at 4:56 PM Ryan Kramer wrote: > > Below is a short example showing that identifier-binding doesn't seem to work > quite right with Scribble's make-base-eval

Re: [racket-users] Re: catch and bind an unbound id in a macro

2019-04-20 Thread Alexis King
The third argument to identifier-binding, top-level-symbol?, controls the result of identifier-binding when the identifier is bound to a top-level binding (and both the REPL and sandboxed evaluators are kinds of top-level evaluation). The docs elaborate this way: > The result is (list source-id)

[racket-users] Re: catch and bind an unbound id in a macro

2019-04-20 Thread Ryan Kramer
Below is a short example showing that identifier-binding doesn't seem to work quite right with Scribble's make-base-eval. It works fine with make-evaluator from racket/sandbox. I'm not sure why this is, but using syntax-local-value instead works everywhere. (Implementation here: https://github

[racket-users] Re: catch and bind an unbound id in a macro

2019-04-19 Thread Ryan Kramer
For what it's worth, Matthias' original answer has solved an issue I had. I was using identifier-binding for something very similar and it worked fine, except in my scribble examples. I had example 1 define foo, but then example 2 (with the same evaluator) would not "see" foo via identifier-bin