On 2013-07-10, at 10:49 PM, Roman Klochkov wrote:
> Do you think, that Racket will do pure calculations in compile-time?
>
> For example, if I write
>
> (+ x (* 2 3 4) (sin 20))
>
> will it be optimized to
>
> (+ x 24.912945250727628) ?
>
> Or I have to use define-syntax to do it?
I doub
At Thu, 11 Jul 2013 02:45:44 -0400,
Carl Eastlund wrote:
> Racket will do many pure calculations at compile-time, without any work on
> your part. I don't know exactly what it will and won't do. I know the
> Typed Racket optimization coach will help you make use of the extra
> optimizations that
On Thu, Jul 11, 2013 at 1:49 AM, Roman Klochkov wrote:
> Thank you. You answer is very useful.
>
>
> > You have to be careful about duplicating inputs in expanded code.
>
> I thought, that hygiene implies not only cl:gensym, but also once-only. Is
> there something like
> http://common-lisp.net/p
Thank you. You answer is very useful.
> You have to be careful about duplicating inputs in expanded code.
I thought, that hygiene implies not only cl:gensym, but also once-only. Is
there something like
http://common-lisp.net/project/cl-utilities/doc/once-only.html in Racket?
> A lot of the
Roman,
Bear in mind that by expanding (square x) to (square x x), that means if
someone writes
(square (perform-expensive-computation))
then you will expand it to:
(* (perform-expensive-computation) (perform-expensive-computation))
You have to be careful about duplicating inputs in expande
I like to make syntax-optimized functions.
(define-syntax (square stx)
(syntax-case stx (square expt)
[(square (square expr)) #'(expt expr 4)]
[(square (expt expr n)) (if (number? (syntax-e #'n))
#`(expt expr #,(* (syntax-e
#'n) 2))
6 matches
Mail list logo