[TreeDL-users] replacement for 'readonly' keyword
Brought to you by:
all-x
|
From: Alexey D. <de...@is...> - 2005-03-22 08:28:53
|
Hi all,
In the next version of TreeDL I plan to replace 'readonly' keyword
with something more adequate. In fact, there are two important cases
that require keywords.
1. A value of an attribute may be set no more than once.
The second call of set-accessor causes runtime exception.
If attribute is not late, it will be set at node creation time (in constructor).
2. A value of an attribute should not be set, because it is calculated
by get-accessor. In this case, there can be no set-accessor at all,
or if set-accessor exists, it should throw UnsupportedOperationException.
Now 'readonly' keyword used for the first case, but it is slightly confusing.
I prefer to have different keywords for these cases, but can not invent them :)
In fact, the first case can be implemented using custom code for set-accessor,
but the second case is more important - it controls gneration of set-accessor.
-----
There are another case that can be implemented in custom code, but I don't know
strict pattern and therefore don't plan to introduce keyword and translation.
This case always requires custom get-code, so overhead is not very big.
It is lazy attributes, calculated during the first call of get-accessor:
attribute T v
get {
if( v == null ) { v = ...; }
};
With 'lazy' keyword is would be:
attribute lazy T v
get {
v = ...;
};
-----
Well, do you have any proposals for two new keywords?
Regards,
Alexey
-----
Alexey Demakov
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com
|