>
> This is a really cool family of tricks. Time for me to start replacing some
> ::Function specifiers in my argument lists...


I saw in julia base that `Base.Callable`, an alias for Union(Function,
DataType), is used in argument lists.
I'm starting to consider replacing most normal functions by functors. I
can't see any drawbacks for now, and I just found at https://github.com/
JuliaLang/julia/issues/1470 that "There is actually no requirement that new
be called within a constructor" (Jeff), so this may be safe too.

Also in my imap implementation example, the field F is not really needed
for functors (but does not seem to incur overhead), but is used when
extending imap to normal functions, with this (outer) constructor:
imap{X}(f::Function, x::X) = imap{Function, X}(f, x)

Finally, I tested sum(imap(sinc_plus_x, x)) on a more recent computer, on
which it is 7% slower than the hand-written version (same result with
reduce(plus,
0.0, imap(sinc_plus_x, x)) for a functor-aware version of reduce).

Reply via email to