No, you don't need to cache it yourself. The compiler will freely copy
immutable values, and there isn't anything you can do to stop it. Most
of these copies will not be heap-allocated, but those that are cannot
be intercepted.

Memoize.jl turns up a google result, but we don't have a standard
memoization feature.


On Tue, Feb 25, 2014 at 6:59 AM, andrew cooke <[email protected]> wrote:
> To what extent does the system cache / reuse immutable instances?
>
> For example, I have a zero(...) function that returns zero for a particular
> (immutable) numeric type.  Do I need to cache that myself, or will the
> system somehow intern values and re-use the same instance?
>
> Bonus question - is there a macro(?) that can be applied to a function and
> which automatically adds LRU caching of the result by argument with weak
> references?
>
> Thanks,
> Andrew
>

Reply via email to