class Association(Magnitude) -> new Association inheriting Magnitude
class Association() -> new Association inheriting Stix
class(#byte) Association() -> new Association class inheriting Stix, but it's byte indexed.
class(#word) Association() -> new Association class inheriting Stix, but it's word indexed.
class(#oop) Association() -> new Association class inheriting Stix, but it's oop indexed. (it can have the variable part on top of the fixed part. response to the 'new: aSize' message)
class(#word) Association(Magnitude) -> new Association class inheriting Magnitude, but it's word indexed.
class Association -> revisit the Association class defined previsously. Revisiting can add new methods.
#include 'Magnitude.st'
#class(#byte) Association(Magnitude)
{
## class variables can be accessed by class methods and instance methods.
## methods of subclasses can also access them.
declare(#class) a b c.
## class instance variable can be accessed inside the class method only.
declare(#class_instance) d, e, f
## All instance variables are protected by default.
declare key, value.
##
## declare(#class) a, b, c. ## class variables
## declare(#class_instance) a, b, c. ## class instance variables
## declare(#instance) a, b, c. ## isntance variables
## declare a,b, c. ## instance variables
## function(#class) ## class method
## function(#instance) ## instance method
## function ## instance method
## var and fun are not keywords. they can be a method name or a variable name.
## Casing is not used to differentiate variable kinds like global local temporary etc.
## other modifiers (EXPERIMENTAL. JUST THINKING).
## declare(#class,#public,#rw) x. x can be accessed by other classes in read-write mode.
## function(#private) xxx xxx is a private method
## function(#class,#private) xxx xxx is private class method.
function(#class) initialize
{
## This is the initilizer for the class object.
## executed when this class is added to the system.
## initialize the class variables and class instance variables.
SIZE := 20.
}
function(#class) key: aKey
{
^self key: aKey value: nil.
}
function(#class) key: aKey value: aValue
{
| ass |
ass := self new.
ass key: aKey value: aValue.
^ass.
}
function key: aKey value: aValue
{
key := aKey.
value := aValue.
}
function key
{
^key
}
function value
{
^value
}
function value: value
{
self->value := aValue
}
function = anAssociation
{
^self->key = anAssociation key.
}
function hash
{
^self->key hash
}
function value: aBlock
{
|a |
a := [ :t1 | t1 value ] with: 10.
^a + 10.
}
}
; message cascading
. steatement terminator or flaoting point if in number and followed by a digit.
^ return
[ ] block
# symbol or array
() grouping
$ character constant
| temporary variable or end of block arguments.
"" comment
'' string
: at the of the keyword or before block argument name.