Skip to content

Instantly share code, notes, and snippets.

@zah
Created November 4, 2011 11:38
Show Gist options
  • Select an option

  • Save zah/1339159 to your computer and use it in GitHub Desktop.

Select an option

Save zah/1339159 to your computer and use it in GitHub Desktop.
New closure syntax
new closure syntax:
do (formal args): block
# passing a closure as a last argument of a nkCall or nkCommand
command "Foo" do (args: string):
code
code
code
btn.click do (e: TClickEvent):
code
code
code
traverseTree(tree) do (node: PNimrodNode):
code
code
code
# could also be a Coroutine but other similar examples exist
# passing a closure without arguments still uses the old short-hand syntax
inGuiThread:
code
code
code
inThread(t):
code
code
code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment