← Back to team overview

ooc-dev team mailing list archive

properties syntax

 

Hi,

When looking at property syntax I find it a bit error prone because we have
twice the same variable name 
for variable itself and for its getter/setter method.


// Current implementation
class SecretKeeper {

String secret;

func secret 
{
// here's our getter do stuff
// no need to return, it's done for us automatically
}

// here's our setter: we leave it empty cause we have nothing special to do
before setting.
func secret(=secret);

}

So I am proposing some alternatives even if we agree that some proposal are
impossible to implement. I just want to 
open the debate and force people to give news ideas and opinions : 


//Proposal 1 : inspired by .NET
class SecretKeeper {

String _secret;

string Secret
{
get { return m_secret; }
set { m_secret = value; }
}

}


//Proposal 2: inspired by .NET 3.0 and automatic properties

class SecretKeeper {
string secret{ get; set; }
}


//Proposal 3 : AUTOGENRATED - inspired by Objective C
class SecretKeeper {
@property (nonatomic, retain) String secret;
}

//Proposal 4 : AUTOGENRATED _ inspired by .NET

class SecretKeeper  {
[property:readwrite]
String secret;

}

Proposal 3 and 4 generated properties in the output files and property
delcaration is implicit.

Give your opinions...






Follow ups