Skip to content

Instantly share code, notes, and snippets.

@jneen
Created June 16, 2015 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jneen/bfa72a7d07d51249ac76 to your computer and use it in GitHub Desktop.
Save jneen/bfa72a7d07d51249ac76 to your computer and use it in GitHub Desktop.
Tulip evaluation order (DRAFT)

In tulip, a function call is expressed as a sequence of expressions, with parentheses appearing freely:

f arg1 (arg2) (g arg3)

If a function receives fewer arguments than its arity, the result is a curried function expecting the remaining arguments. If it receives more, it consumes its arity and calls the return value with the rest. The order of evaluation for a function call is:

  • The function expression is evaluated
  • Each argument is evaluated
  • The call to the function itself is evaluated
  • Any remaining calls from returned functions are evaluated

Function calls can be composed in chains. A chain is a sequence of function calls separated by >:

f arg1 > g arg2 > h arg3

Here, g arg2 is applied to the result of f arg1, and h arg3 is applied to the result of that. Evaluation order of chains is:

  • The first function call is evaluated
  • For each remaining element of the chain,
    • Evaluate the function call
    • Apply the result to the previous value

A command is a special kind of function that takes zero arguments. It is called with a !, as in my-command!. Calling a command with arguments results in a panic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment