Hey all,

I'm writing a #lang and am trying to raise my own errors instead of having 
racket throw any errors of its own.

One of my constructs, (func name(args) body), defines a function that's able to 
be called afterwards, and it desugars into a pretty regular define statement. 
As a result, I can't do things like

(let () (func a(x) x))
(+ (func a(x) x) 1)
etc ...

because it ends up expanding into a define statement in an expression position, 
which is bad.

While I don't want this to be allowed, I'd like to catch this and throw my own 
errors if this happens. The only way I can really imagine doing this is to 
modify all the functions I have that take in expressions (+ - * / let ...)
and give them contracts that say "Hey, check to make sure your arguments are 
expressions, and if not, throw this syntax error!"

The only problem there is that I can't seem to find any function that will tell 
me if I have an expression or a define. Is there an easy way to check this? 
I.e. a function expression? such that

(expression? #'(+ 1 1)); #t
(expression? #'(define a 1)); #f
(expression? #'(define-syntax-rule (id x) x)); #f


It'd be nice if there was a function like this, but also, if there's an easier 
way to do this, by all means, lemme know!

Thanks in advance.

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to