2016-03-28 13:27:03 +00:00
|
|
|
|
|
|
|
#include 'Stix.st'.
|
|
|
|
|
|
|
|
#################################################################
|
|
|
|
## MAIN
|
|
|
|
#################################################################
|
|
|
|
|
|
|
|
## TODO: use #define to define a class or use #class to define a class.
|
|
|
|
## use #extend to extend a class
|
|
|
|
## using #class for both feels confusing.
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
extend Apex
|
2016-03-28 13:27:03 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
extend SmallInteger
|
2016-03-28 13:27:03 +00:00
|
|
|
{
|
2017-01-06 09:53:40 +00:00
|
|
|
method getTrue: anInteger
|
2016-03-28 13:27:03 +00:00
|
|
|
{
|
|
|
|
^anInteger + 9999.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method inc
|
2016-03-28 13:27:03 +00:00
|
|
|
{
|
|
|
|
^self + 1.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
class TestObject(Object)
|
2016-03-28 13:27:03 +00:00
|
|
|
{
|
2017-01-06 09:53:40 +00:00
|
|
|
dcl(#class) Q R.
|
|
|
|
dcl(#classinst) t1 t2.
|
2016-03-28 13:27:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
class MyObject(TestObject)
|
2016-03-28 13:27:03 +00:00
|
|
|
{
|
2017-01-06 09:53:40 +00:00
|
|
|
dcl(#class) C B A.
|
2016-03-28 13:27:03 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method getTrue
|
2016-03-28 13:27:03 +00:00
|
|
|
{
|
|
|
|
^true.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method getTrue: anInteger
|
2016-03-28 13:27:03 +00:00
|
|
|
{
|
|
|
|
^ anInteger
|
|
|
|
}
|
2017-01-06 09:53:40 +00:00
|
|
|
method getFalse
|
2016-03-28 13:27:03 +00:00
|
|
|
{
|
|
|
|
^false
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method a { ^ 10 }
|
|
|
|
method b { ^ 20 }
|
|
|
|
method c { ^ 30 }
|
2016-03-28 13:27:03 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) a: a b: b c: c
|
2016-03-28 13:27:03 +00:00
|
|
|
{
|
|
|
|
^ a + b + c.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) getBlock
|
2016-03-28 13:27:03 +00:00
|
|
|
{
|
|
|
|
| a |
|
|
|
|
a := 7777777.
|
|
|
|
"
|
|
|
|
^[1 + [^a]].
|
|
|
|
1234567 dump.
|
|
|
|
"
|
|
|
|
|
|
|
|
^[self a: a b: 3 c: ([[[^6] value] value ] value)].
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) main
|
2016-03-28 13:27:03 +00:00
|
|
|
{
|
|
|
|
"
|
|
|
|
| k |
|
|
|
|
|
|
|
|
k := 30.
|
|
|
|
k := k + 10; + 20.
|
|
|
|
k dump.
|
|
|
|
(self a: 1 b: 2 c: 3) dump.
|
|
|
|
[self a: 1 b: 2 c: 3] value dump.
|
|
|
|
[self a: 1 b: 2 c: 3] value dump.
|
|
|
|
[self a: 9 b: 10 c: 11] value dump.
|
|
|
|
|
|
|
|
|
|
|
|
((k = 2) ifTrue: [11111] ifFalse: [2222])dump.
|
|
|
|
|
|
|
|
self getBlock value dump.
|
|
|
|
|
|
|
|
[10 + [^20]] value dump.
|
|
|
|
"
|
|
|
|
|
|
|
|
|
|
|
|
'START OF MAIN' dump.
|
|
|
|
[2 + 3 + 1 + [[[^6] value] value ] value] value dump.
|
|
|
|
## ^(self a: (self new a) b: ([:a :b | a + b] value: 10 value: 20) c: (self new c)) dump.
|
|
|
|
##self getBlock value dump.
|
|
|
|
'END OF MAIN' dump.
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|