Created
July 23, 2009 13:29
-
-
Save fogus/152916 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
{} // map literal syntax | |
() // tuple literal syntax | |
[] // list literal syntax | |
foo // a symbol | |
"foo" // a string | |
foo => bar // a pair | |
:. // a block (similar to progn) | |
= // bind | |
~ // merge | |
<~ // merge bind | |
? // property query | |
foo(42) // a symbol followed by a tuple is a function call | |
foo.fun() // call a method | |
$ // similar to `this` or `self` | |
*/ | |
def foo = {} // start with an empty map | |
foo.n = 42 // put a property | |
foo?n // does foo have property n? | |
foo.n // lookup property n | |
def bar = {() => [print("Hello Cleveland")]} | |
bar() // prints Hello Cleveland | |
bar.() // returns the list `[print("Hello Cleveland")]` | |
bar?() // does this function accept zero args? | |
bar.().first() // returns the symbol `print` | |
def baz = {() => [print($.n)]} | |
baz() // returns special object `notset` | |
baz.n = 138 // sets property `n` | |
baz() // prints 138 | |
def qux = {()=> baz.()} // grab the body of baz's empty arity function | |
qux() // returns special object `notset` (no property `n`) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment