antarestrader / sapphire

The Sapphire Programming Language [WIP]
GNU General Public License v3.0
1 stars 0 forks source link

Boolean operators need to short circuit #52

Open antarestrader opened 9 years ago

antarestrader commented 9 years ago

&& and || need to short circuit when the first operand is sufficient to determine the final value.

This may take some reworking as currently all calls are call-by-value.

antarestrader commented 9 years ago

A thought last night: Create a value "Macro" and understand that a call to a macro should receive functions whose evaluation results in the needed value.

When eval (Apply ...) finds a macro rather then a function, it creates functions out of each argument expression and passes those in as the arguments.

example:

defmacro "||" (a,b)
  aa = a() # evaluate a
  if aa then aa else b()  # evaluate and return b only if a is falsy