byKey and byValue: properties or methods?
Jose Armando Garcia
jsancio at gmail.com
Tue Jan 17 08:55:30 PST 2012
On Tue, Jan 17, 2012 at 4:48 AM, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> I hate I must ask this:
>
> int[string] aa;
> foreach (k; aa.byKey) { ... }
>
> or
>
> int[string] aa;
> foreach (k; aa.byKey()) { ... }
>
If it is any help, Scala libraries use by convention that methods that
have a side should be called with '()' while methods that don't have a
side effect should be called without the '()'. In scala this translate
to:
aa.sideEffectWhenCalled()
aa.noSideEffect
which looks as follow in the definition:
def sideEffectWhenCalled() = { ... }
def noSideEffect = { ... }
I think that this translate really well to D's property. Photos can
try to implement the policy that read properties shouldn't have side
effects (externally observable side effect). The language doesn't need
to enforce but it would be nice if Photos would follow it.
Thoughts? Thanks,
-Jose
>
>
> Thanks,
>
> Andrei "I told you" Alexandrescu
More information about the Digitalmars-d
mailing list