annotate samples/reflect.tp @ 377:93c28eee141e default tip

Merge
author Michael Pavone <pavone@retrodev.com>
date Sat, 15 Aug 2015 22:45:33 -0700
parents b74956a2196f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
266
75dc7161c1ca Added object module which provides some basic reflection capabilities
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #{
75dc7161c1ca Added object module which provides some basic reflection capabilities
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 main <- {
270
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
3 o <- #{
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
4 foo <- 42
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
5 bar <- 39
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
6 doStuff <- :blah {
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
7 foo <- bar * blah
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
8 foo
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
9 }
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
10 qux <- { 1337 }
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
11 + <- :right {
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
12 foo + right
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
13 }
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
14 }
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
15 print: (string: (object does: o understand?: "+")) . "\n"
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
16 print: (string: (object does: o understand?: "foobar")) . "\n"
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
17 print: (string: (object sendMessage: "qux" to: o)) . "\n"
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
18 print: "Messages understood:\n"
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
19 foreach: (object understoodBy: o) :idx el{
266
75dc7161c1ca Added object module which provides some basic reflection capabilities
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 print: el . "\n"
75dc7161c1ca Added object module which provides some basic reflection capabilities
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 }
270
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
22 print: "\nProperties of:\n"
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
23 foreach: (object propertiesOf: o) :idx el{
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
24 print: el . "\n"
b74956a2196f Add a propertiesOf method to the object module that returns the names of things that look like getter messages
Michael Pavone <pavone@retrodev.com>
parents: 268
diff changeset
25 }
266
75dc7161c1ca Added object module which provides some basic reflection capabilities
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 0
75dc7161c1ca Added object module which provides some basic reflection capabilities
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27 }
75dc7161c1ca Added object module which provides some basic reflection capabilities
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 }