I would like to alias some racket
2htdp
functions/macros, so that I can translate them in another language for my children.
Things which are functions I can simply alias with define
. I'm having trouble with the big-bang
structure; If I try to alias on-tick
for instance, everytime I get big-bang: [new-name] clauses are not allowed within big-bang
.
I tried various variants of define-syntax
but I could not make it work so far (that said, I'm a complete racket newbie).
Something like this works (well, ladja
is not defined):
#lang racket
(require 2htdp/universe 2htdp/image)
(big-bang 0
(on-tick (lambda (x) (+ x 1)))
(to-draw (lambda (x) (place-image ladja 150 x (prazni-prostor 300 300))))
(stop-when (lambda (x) (= x 300))))
But this doesn't (triggers the error):
#lang racket
(require 2htdp/universe 2htdp/image)
(define new-name on-tick)
(big-bang 0
(new-name (lambda (x) (+ x 1)))
(to-draw (lambda (x) (place-image ladja 150 x (prazni-prostor 300 300))))
(stop-when (lambda (x) (= x 300))))
I see that big-bang
is a macro, so that explains the issue: I guess I would have to be able to force my macro to be evaluated first, somehow?