[Issue 8743] Add support for memoizing class methods
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Oct 2 03:17:28 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8743
--- Comment #10 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-10-02 03:17:42 PDT ---
(In reply to comment #9)
> (In reply to comment #8)
> > (In reply to comment #6)
> > > This mixin template is useful. A disadvantage is that it doesn't follow the API
> > > (usage) of the Phobos memoize. So maybe it needs a different name, like
> > > memoizeMethod, or something.
> >
> > Yes. I couldn't make it have the same syntax because of the requirement of the
> > `this` reference.
>
> Also I'm unsure about recursive calls.
And I think I've uncovered yet another bug:
class A
{
int slowFunc(int a, int b)
{
int result;
/* Error: function expected before (), not mixin memoize!(slowFunc)
fastFunc; */
if (a > 1)
return fastFunc(a-1, b);
return result;
}
mixin memoize!slowFunc fastFunc;
}
If I replace 'return fastFunc(a-1, b);' with 'return this.fastFunc(a-1, b)' it
works.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list