Mercurial > repos > tabletprog
diff samples/reflect.tp @ 270:b74956a2196f
Add a propertiesOf method to the object module that returns the names of things that look like getter messages
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 18 Jul 2014 20:45:50 -0700 |
parents | 123e9468d55e |
children |
line wrap: on
line diff
--- a/samples/reflect.tp Fri Jul 18 19:31:07 2014 -0700 +++ b/samples/reflect.tp Fri Jul 18 20:45:50 2014 -0700 @@ -1,11 +1,28 @@ #{ main <- { - print: (string: (object does: 42 understand?: "+")) . "\n" - print: (string: (object does: 42 understand?: "foobar")) . "\n" - foreach: (object understoodBy: 42) :idx el{ + o <- #{ + foo <- 42 + bar <- 39 + doStuff <- :blah { + foo <- bar * blah + foo + } + qux <- { 1337 } + + <- :right { + foo + right + } + } + print: (string: (object does: o understand?: "+")) . "\n" + print: (string: (object does: o understand?: "foobar")) . "\n" + print: (string: (object sendMessage: "qux" to: o)) . "\n" + print: "Messages understood:\n" + foreach: (object understoodBy: o) :idx el{ print: el . "\n" } - print: (object sendMessage: "hex" to: 42) . "\n" + print: "\nProperties of:\n" + foreach: (object propertiesOf: o) :idx el{ + print: el . "\n" + } 0 } }