Memoize and protected functions

David Nadlinger see at klickverbot.at
Sat May 12 04:33:08 PDT 2012


On Saturday, 12 May 2012 at 09:08:30 UTC, John Chapman wrote:
> Functions you want to memoize have to be visible to 
> std.functional.memoize, so it only works with public functions.

This is an artifact of the way access protection for alias 
parameters is currently implemented – when accessing 
(»resolving«) an alias parameter, protection attributes are 
checked in the same way as if you just wrote the symbol name, 
i.e. in the scope of the module where e.g. memoize is defined.

In my opinion, this is a … uhm … _questionable_ design 
decision, even more so than the fact that private module members 
are not at all private to that module (as they are still taken 
into account for overload resolution). Several other issues, e.g. 
being unable to std.concurrency.spawn() private functions, are 
also caused by this.

David




More information about the Digitalmars-d mailing list