property syntax strawman

KennyTM~ kennytm at gmail.com
Mon Aug 3 04:24:53 PDT 2009


Michiel Helvensteijn wrote:
> KennyTM~ wrote:
> 
>>>>> auto data = std.file.readText(filename).chomp.split;
>>>> I love that too. Unfortunately, the way the water is moving, it looks
>>>> like we'll lose some or all of that.
>>> That's not really true. Some of those no-parameter functions are just
>>> meant to be read-only properties instead of functions.
>>>
>>> auto data = std.file.textFrom(filename).chomped.split;
>> So to allow omission of the parenthesis of these "read-only properties"
>> we do
> 
> No, it's not "allowing omission", it's "forcing omission". That's what
> properties are.
> 

Ok. So to allow forced removal of parenthesis etc etc.

>> @property string chomped (string x) { ... }
>>
>> ? I don't think Walter's syntax is capable of introducing "properties"
>> to these free methods, but the property attribute can.
> 
> I still think an identifier is either property or function, but not both.
> 
> And judging by the way the wind is blowing, attributes/annotations will not
> be used for properties.
> 

Too bad. Attributes is much cleaner than the equal sign hack.

>> (However, this may make
>>
>> chomped = "abcd"
>>
>> valid, which is not what we want.)
> 
> No, it wouldn't, since it'd be a read-only property. That means you can only
> read, not write.
> 

Unless global properties are disabled. (It should.)



More information about the Digitalmars-d mailing list