rails/rails — comment on commit 36253916b0b788d6ded56669d37c96ed05c92c5c
File:  line 0
By jrochkind:

Rather than ||=, I recommend:

unless defined? @_iVar

to memoize nil/false too. This approach also gives you the ability to
un-memoize one method at a time, which I think memoizable did not. It
does not give you the ability to bulk unmemoize everything in an
instance however. Not sure what you mean by 'keep cached return values
seperate from instance state.'

But anyway, if you are interested in Memoizable, why not take the code
and make it into it's own gem and take on the maintenance? That's
probably what I'd do with Concern if Rails removed it, I absolutely
depend on Concern. On the other hand, I've had pretty bad performance
problems with Memoizable, myself, and learned not to use it in my own
code already a while ago.

On Dec 20, 2011, at 6:01 AM, José Valim wrote:

> Memoizable implementation:
>
> https://github.com/rails/rails/blob/36253916b0b788d6ded56669d37c96ed05c92c5c/activesupport/lib/active_support/memoizable.rb
>
> Concern implementation:
>
> https://github.com/rails/rails/blob/36253916b0b788d6ded56669d37c96ed05c92c5c/activesupport/lib/active_support/concern.rb
> #L107
>
> They are very different things in terms of software complexity and
> how they
> affect your code. The reason why Memoization is being removed is
> exactly
> because it is **too complex** for something you can easily achieve
> in Ruby.
>
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/rails/rails/commit/36253916b0b788d6ded56669d37c96ed05c92c5c
> #commitcomment-809033