Re: Rebinding functions?

2009-06-16 Thread CuppoJava
This post worries me. I've considered rewriting functions as inlining-macros for optimization purposes. But I thought it would be a transparent change. This post shows that it's not a transparent change, and could potentially lead to some very odd looking bugs. What if I wanted to optimize printl

Re: Rebinding functions?

2009-06-16 Thread Michel Salim
On Jun 16, 2:22 pm, Kevin Downey wrote: > you can use apply to avoid in-lining: > > user=> (binding [+ -] (apply + '(5 3))) > 2 > Indeed; this is what my macro ended up doing anyway, since it has to work regardless of the arity of the functions to trace. -- Michel --~--~-~--~~-

Re: Rebinding functions?

2009-06-16 Thread Kevin Downey
you can use apply to avoid in-lining: user=> (binding [+ -] (apply + '(5 3))) 2 On Tue, Jun 16, 2009 at 11:16 AM, Michel S. wrote: > > > > On Jun 16, 1:42 pm, Paul Stadig wrote: >> On Tue, Jun 16, 2009 at 1:38 PM, Michel Salim wrote: >> >> >> >> > It's currently not possible to dynamically reb

Re: Rebinding functions?

2009-06-16 Thread Michel S.
On Jun 16, 1:42 pm, Paul Stadig wrote: > On Tue, Jun 16, 2009 at 1:38 PM, Michel Salim wrote: > > > > > It's currently not possible to dynamically rebind functions: > > > (binding [+ -] (+ 5 3)) ==> 8 ;; not 2 > > > Thanks, > > > -- > > Michel S. > > It is possible to rebind (even core) functio

Re: Rebinding functions?

2009-06-16 Thread Sean Devlin
Yes, people have shown examples on this list where (+ a b) is dramatically faster than (+ a b c) On Jun 16, 1:42 pm, Paul Stadig wrote: > On Tue, Jun 16, 2009 at 1:38 PM, Michel Salim wrote: > > > > > It's currently not possible to dynamically rebind functions: > > > (binding [+ -] (+ 5 3)) =

Re: Rebinding functions?

2009-06-16 Thread Paul Stadig
On Tue, Jun 16, 2009 at 1:38 PM, Michel Salim wrote: > > It's currently not possible to dynamically rebind functions: > > (binding [+ -] (+ 5 3)) ==> 8 ;; not 2 > > Thanks, > > -- > Michel S. > It is possible to rebind (even core) functions, but there are a couple of limitations. One of which is

Rebinding functions?

2009-06-16 Thread Michel Salim
It's currently not possible to dynamically rebind functions: (binding [+ -] (+ 5 3)) ==> 8 ;; not 2 Would this be supported in the future? It would make it easier, for example, to extend the current tracing functionality, e.g. (trace-in-expr [f1 f2] (f1 (f2 10))) ==> (let [oldf1 f1 oldf2 f2]