[racket] Compile-time evaluation
Is there simple way to calculate during compilation. Something like #. in Common Lisp.
For example how to do something like
(case ftype
((#.(keyword->g-type 'enum)
#.(keyword->g-type 'flags))
(convert-to-foreign value (g-type->lisp type)))
(#.(keyword->g-type 'double)
(coerce value 'double-float))
(#.(keyword->g-type 'float)
(coerce value 'single-float))
((#.(keyword->g-type 'int)
#.(keyword->g-type 'uint)
#.(keyword->g-type 'long)
#.(keyword->g-type 'ulong)
#.(keyword->g-type 'int64)
#.(keyword->g-type 'uint64))
(round value))
(else value))
where keyword->g-type is a function (-> symbol? exact-integer?).
I don't want to place resulting numbers, because then there will be a lot of "magic numbers" corresponfing to different foreign types.
--
Roman Klochkov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130729/076cea24/attachment.html>