Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,71 @@
|
|||
( ---------------- zen object orientation -------------- )
|
||||
|
||||
[ immovable
|
||||
]this[ swap do ]done[ ] is object ( --> )
|
||||
|
||||
[ ]'[ ] is method ( --> [ )
|
||||
|
||||
[ method
|
||||
[ dup share
|
||||
swap put ] ] is localise ( --> [ )
|
||||
|
||||
[ method [ release ] ] is delocalise ( --> [ )
|
||||
|
||||
|
||||
( -------------- example: counter methods -------------- )
|
||||
|
||||
( to create a counter object, use:
|
||||
"[ object 0 ] is 'name' ( [ --> )" )
|
||||
|
||||
[ method
|
||||
[ 0 swap replace ] ] is reset-counter ( --> [ )
|
||||
|
||||
[ method
|
||||
[ 1 swap tally ] ] is increment-counter ( --> [ )
|
||||
|
||||
[ method [ share ] ] is report-counter ( --> [ )
|
||||
|
||||
|
||||
( -------------------- demonstration ------------------- )
|
||||
|
||||
say 'Creating counter object: "mycounter".' cr cr
|
||||
[ object 0 ] is mycounter ( [ --> )
|
||||
|
||||
say "Initial value of mycounter: "
|
||||
report-counter mycounter echo cr cr
|
||||
|
||||
say "Incrementing mycounter three times." cr
|
||||
3 times [ increment-counter mycounter ]
|
||||
|
||||
say "Current value of mycounter: "
|
||||
report-counter mycounter echo cr cr
|
||||
|
||||
say "Localising mycounter." cr cr
|
||||
localise mycounter
|
||||
|
||||
say " Current value of mycounter: "
|
||||
report-counter mycounter echo cr cr
|
||||
|
||||
say " Resetting mycounter." cr
|
||||
reset-counter mycounter
|
||||
|
||||
say " Current value of mycounter: "
|
||||
report-counter mycounter echo cr cr
|
||||
|
||||
say " Incrementing mycounter six times." cr
|
||||
6 times [ increment-counter mycounter ]
|
||||
|
||||
say " Current value of mycounter: "
|
||||
report-counter mycounter echo cr cr
|
||||
|
||||
say "Delocalising mycounter." cr cr
|
||||
delocalise mycounter
|
||||
|
||||
say "Current value of mycounter: "
|
||||
report-counter mycounter echo cr cr
|
||||
|
||||
say "Resetting mycounter." cr
|
||||
reset-counter mycounter
|
||||
|
||||
say "Current value of mycounter: "
|
||||
report-counter mycounter echo cr cr
|
||||
Loading…
Add table
Add a link
Reference in a new issue