If I had my way

Jonathan M Davis jmdavisProg at gmx.com
Tue Dec 13 10:13:38 PST 2011


On Tuesday, December 13, 2011 12:14:37 Michel Fortin wrote:
> On 2011-12-13 16:57:33 +0000, Jonathan M Davis <jmdavisProg at gmx.com> said:
> > On Tuesday, December 13, 2011 06:40:40 Michel Fortin wrote:
> >> On 2011-12-13 04:25:33 +0000, Jonathan M Davis <jmdavisProg at gmx.com> 
said:
> >>> For arrays, all you need to do is have the first argument be an
> >>> array,
> >>> and that works great for arrays, but arrays don't have much in the
> >>> way
> >>> of functions built in, so there's no conflict.
> >> 
> >> Actually, there's still an open issue with array-member syntax and
> >> @property used together.
> > 
> > How so? If it's a property function, not a member function (which
> > couldn't use array-member syntaxt anyway), and it takes an array as its
> > first argument, then it _must_ be called with array-member syntax
> > without parens. If it isn't a property, then you could call it with or
> > without array-member syntax, but you have to use parens. I don't see
> > any conflict there.
> 
> The problem is that the definition of an array-member property getter
> is the same thing as the definition of a module-level property setter.

I forgot about that, though I never liked the idea of module-level properties 
in the first place.

> > Now, I don't know what -property is doing with it at the moment, but I
> > don't see how it could work any other way.
> 
> Currently I think you can do this:
> 
> import std.range;
> 
> int[] array = [1, 2];
> int x = array.front; // fine
> int y = (front = a); // ???
> 
> And also you can't define array-member property setters because they
> take three arguments and three argument property functions are not
> allowed.

You mean calling a property function on an element in an array? I would only 
have expected that to work if the element type had such a property. I wouldn't 
ever have expected you to be able to declare a property for arrays which 
allowed you to call it as a property on the array's elements.

> And also, in case of conflict, currently you can write
> `std.range.front(array)` to disambiguate, but how does that work with
> @property enforcement, probably not that well?

Disambiguate with what? With a module-level property? As it stands, I expect 
that module-level properties which are arrays just wouldn't work.

- Jonathan M Davis


More information about the Digitalmars-d mailing list