Mercurial > repos > tabletprog
diff samples/oper_impl.tp @ 122:9820ecd4eed4
Add support for implementing operators on user defined objects
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 03 Aug 2013 00:13:09 -0700 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/oper_impl.tp Sat Aug 03 00:13:09 2013 -0700 @@ -0,0 +1,20 @@ +#{ + pair <- :a b { + #{ + first <- a + second <- b + + <- :other { + pair: first + (other first) second + (other second) + } + } + } + + main <- { + foo <- pair: 5 7 + bar <- pair: 9 23 + baz <- foo + bar + print: ((baz first) string) . "\n" + print: ((baz second) string) . "\n" + 0 + } +}