marius311 / Memoization.jl

Easily and efficiently memoize any function, closure, or callable object in Julia.
MIT License
96 stars 2 forks source link

Make work on inner constructors #15

Closed marius311 closed 2 years ago

marius311 commented 3 years ago

Ref https://discourse.julialang.org/t/implementing-singleton-design-pattern/61704/5

marius311 commented 2 years ago

The example there seems to work now, not sure exactly what did it.

using Memoization

@macroexpand mutable struct Repository
    nrows::Integer          # Max number of rows that can be drawn.
    ncols::Integer          # Max number of cols that can be drawn.
    rep                     # Repository of random numbers in [0,1)
    @memoize Repository() = new(0,0,[0])
end