ralph
1/12/2012 4:33:00 AM
On Wed, 11 Jan 2012 16:13:16 -0800, Karl E. Peterson <karl@exmvps.org>
wrote:
>BeeJ explained on 1/11/2012 :
>> default method of the class.
>> This allows you to omit the member name.
>
>Evil, defined.
lol
I never found the concept of a default method all that evil.
It is just one of those things that seemed a good idea within the
context of the times and had to be tried at least once in a high-level
language*.
There are three closely related reasons for a default properties.
1) It allows one to treat the object as a simple abstraction.
For example, a "Textbox" is a gimmick for managing text, thus what is
more natural than ...
TextboxA = "This is the string"
ResultText = TextboxA
2) It allows the same abstraction no matter what the actual
method/property might be 'called'. For example ...
TextboxA = "A string" ' TextboxA.Text
LabelA = "A string" ' LabelA.Caption
SomeObj = "A string" ' SomeObj.Value
[The language is sematically the same for the same abstraction.]
3) It allows for precise dereferencing when using the Dictionary
Lookup operator (the bang "!" operator) on simple and nested
collections.
Back then simpler abstractions and simpler constructs equaled simpler
coding, or so the thinking went. Only time and experience demonstrated
that maybe it wasn't such a good idea after all. lol
-ralph
[* Actually it was tried with several languages/platforms.]