Does racket have something like guile’s procedure-source function, e.g.:
(define (plus-one x) (+ 1 x))
(procedure-source plus-one) –> (quote (+ 1 x))
I’m trying to make something akin to a debugging tool for beginning students, in which they can see partial or complete evaluations of a particular function while they play with its behavior in a 2htdp/universe. So I could use a macro for this case, except in their program I’d still like the definition to look exactly as usual, so I can’t just have them quote it in the first place and eval it later, unless I redefine define… which might be okay, but I’d appreciate pointers on how best to do it.
The problem you’re running into is due to a Beginner Student Language restriction: normally, higher-order functions are a syntactic error in the language, because beginners shouldn’t know about them yet.
There’s a way to opt-out of this. Your procedure-source can be labeled as one of the exceptions to this restriction, by using provide-higher-order-primitive, which is specifically meant to cooperate with BSL.
Here’s what your library looks like with it:
BSL programs that use this should be able to use procedure-name and procedure-source fine.