Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Forked from atg/gist:264006
Created December 26, 2009 20:01
Show Gist options
  • Save ELLIOTTCABLE/264026 to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/264026 to your computer and use it in GitHub Desktop.
foo bar
=> foo['bar']
# assignment (no, this is impossible to handle in userspace without breaking/crippling lookup overloading)
... = ...
# methods (this is just syntactic sugar)
foo.bar
=> foo['isa']['bar']
# Dereference using an expression instead of a string
foo [bar]
=> foo[bar]
# Arrays
# Associative arrays like in PHP. Order matters. This helps with handling named arguments
(1, 'foo', x: (7, 8, 9))
=> [0 => 1, 1 => 'foo', :x => [7, 8, 9]]
# Function calls
foo(...)
=> foo(...)
# Blocks (meaningful indentation). The block is passed as a closure as the item in the arguments array
foo ...
...
=> foo(..., {...})
# Blocks (braces). As above
foo ... {
...
}
=> foo(..., {...})
# These two are preset by the runtime, but they're nothing special - code can reassign them/change them
@ the arguments of a block
^ the enclosing scope
# If a block called 'lookup' is defined in a scope, then that overloads the lookup operator (arguments to lookup are stored in @ as normal).
# For example:
s = lookup: routine
^ [@0] = "hello"
s foo
# Arithmetic operators in descending order of precedence
⇤ Space operator
: ⇥ Definition literal
foo ⇥ Infix methods
** ⇥ Exponentiation
* / ⇥ Multiplication, Division
+ - ⇥ Addition, Subtraction
, ⇥ Array literal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment