Fixing const arrays
Regan Heath
regan at netmail.co.nz
Wed Dec 14 05:30:05 PST 2011
On Wed, 14 Dec 2011 13:27:57 -0000, Regan Heath <regan at netmail.co.nz>
wrote:
> On Wed, 14 Dec 2011 02:36:43 -0000, Michel Fortin
> <michel.fortin at michelf.com> wrote:
>
>> On 2011-12-13 23:08:43 +0000, Andrei Alexandrescu
>> <SeeWebsiteForEmail at erdani.org> said:
>>
>>> We could have inferred property intention from the code pattern,
>>> without requiring any keyword. That solution (which was discussed and
>>> rejected in this newsgroup) was miles ahead from the drivel of
>>> @property we have now.
>>
>> By "code patterns", you mean something like this?
>>
>> struct Foo
>> {
>> int getBar();
>> void setBar(int);
>> }
>>
>> void main()
>> {
>> Foo foo;
>> int a = foo.bar; // calls getBar()
>> foo.bar = a; // calls setBar(a)
>> }
>
> Why not something similar to C# syntax...
>
> struct Foo
> {
> int bar // <- does DMD do lookahead? detect { instead of ; here and
> trigger "property" parsing
> {
> get
> {
> return this; // <- 'this' meaning the 'bar' member
> }
> set
> {
> this = value; // <- 'this' meaning the 'bar' member, 'value'
> meaning the RHS of the "£instance.bar = <value>" statement
> }
> }
> }
>
> Regan
Apologies, there was a typo/mistake in the 'get' above. :)
Regan
--
Using Opera's revolutionary email client: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list