Eek's Property Syntax
This
old entry in Cedric Beust's (recommended) blog describes the differences of the property syntax in Java, C# and Ruby. So let's do it for Eek. There is one thing to say though, Eek does not make any difference between properties and fields. Everything is the same, and called properties.
Read-Write attributes
Eek knows two variants here. Either you can implement two accessor methods, or you write it like a Java field. In the first case the object does not have any memory associated with it, so you may want to have a private property to store the value. In the second solution, the object will have memory for the property, and accessors for reading and writing are implicitly created. You can still override them later without losing binary compatibility, but you don't have to write them as long as you don't need them. So here's the accessor method version:
public:
String firstName.get()
// some code
firstName.set(String value)
// some code
And this is the field syntax version:
public:
String firstName
Read-Only Attributes
Read-only properties can only exist as accessor methods, so there is no short notation. A true read-only field-like property would not make any sense in Eek. And I don't know a good syntax to define a field-like property with different access permissions for reading and writing.. So read-only properties can eiter be created by defining a 'get' method without 'set' method, or by definint the accessor methods with different access permissions:
public:
String firstName.get()
// some code
private:
firstName.set(String value)
// some code
written at 11:37. (0 Comments, Permalink)