[racket] variables within macros
On 21/01/13 05:22, Eli Barzilay wrote:
> (Ah, and that explains the `define/test'. I don't know what's the
> time-frame involved, but something that would be more ambitious would
> be a language where the source code must have enough tests to get
> complete coverage...)
Time frame is the end of the month! This was only ever going to be
"hobby-time" work and, TBH, I wasn't expecting to spend so much time
discussing, exploring and discovering syntax extensions here!
I'm probably not going to have time to get an entry into pltgames for
this; but I assure you, the exercise has been well worth it for me.
The define/test was being developed for runtime defines; but I'm now
wondering whether (given my experience here), a define-syntax-rule/tested
along the same lines wouldn't be a better idea for me.
The other plan was to produce "mock" functions for functions that had
no body. e.g. along the lines of:
(define/tested (add2 x)
; I have been told that these are example values of the function, even
; though I'm not sure/ready to implement it
(test (== (add2 0) 2)
(== (add2 1) 3)
(== (add2 2) 4))
; look ma, no body
)
would then produce ->
(define (add2 . x)
(cond
[(equal x '(0)) 2]
[(equal x '(3)) 3]
[(equal x '(4)) 4]
[else (error "add2: unmocked value")]))
So you have something at least partially usable.
Anyhoo, I'll be progressing this, but slower than "end of Jan".
And who knows? Hopefully I'm better equipped for next month's challenge.
But, if this sounds properly useful to anyone (I'm not sure if racket needs
*more* choice in testing/contracting/typing environments), giz a shout.
Tim
--
Tim Brown <tim.brown at cityc.co.uk> | City Computing Limited |
T: +44 20 8770 2110 | City House, Sutton Park Road |
F: +44 20 8770 2130 | Sutton, Surrey, SM1 2AE, GB |
-----------------------------------------------------------------------|
BEAUTY: What's in your eye when you have a bee in your hand |
-----------------------------------------------------------------------'
City Computing Limited registered in London No. 1767817.
Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE
VAT number 372 8290 34.