Iterators for D
Charles D Hixson
charleshixsn at earthlink.net
Tue Nov 7 15:40:40 PST 2006
Walter Bright wrote:
> Bill Baxter wrote:
>> Sean Kelly wrote:
>>>> The problem is if the iterator is an actual pointer, there is no
>>>> .value property for a pointer.
>>
>> Well, they could. It's up to Mr. Compiler Writer if a pointer has a
>> value property or not.
>
> Consider the following struct:
>
> struct Foo
> {
> int value;
> }
>
> Foo* p;
>
> p.value;
>
> Is p.value the entire contents of Foo (as it would be for a proposed
> .value property) or just Foo.value? "value" is a pretty common field name.
Maybe that's why Ada used "`" as a property marker rather than
"."? Of course there's the Python approach...naming it __value__.
A suitable solution might be to name it "valueof". That's a
much less common field name. The problem is that this is
something used quite frequently, so one would want it to be
short. Perhaps "V"? Then one would write
struct Foo
{ int value;
}
Foo* p;
p.value;
p.V;
and have two distinct forms. (Yes, V is used occasionally as
a variable name...but pretty rarely.)
More information about the Digitalmars-d
mailing list