[racket] Compile-time evaluation

From: Roman Klochkov (kalimehtar at mail.ru)
Date: Sun Jul 28 22:25:21 EDT 2013

 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>

Posted on the users mailing list.