Hi,
is it possible to define a macro that does one thing when
it's in operator position and another when it's not?
I want to define a macro `with-vectors` that transforms this:
(with-vectors (v)
(v 0)
(set! (v 0) 'foo)
(some-procedure v))
into this:
(begin
(vector-ref v 0)
(vector-set! v 0 'foo)
(some-procedure v))
So far I have this:
(define-syntax with-vectors
(syntax-rules ()
((_ (id ...) exp ...)
(let-syntax ((id* (syntax-rules ()
((_ idx) (vector-ref id idx)))) ...)
exp ...))))
But that obviously only works for the first case: (v 0).
Regards,
Tobias