Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can if be a proper function rather than a special form

I finally started learning functional languages (emacs lisp) and it makes explicit distinction between functions and special forms such as flow control , for example if.

Is there a fundamental/theoretical reason why special forms are distinct from functions? do any languages provide functional if?

Thanks

like image 893
Anycorn Avatar asked Feb 10 '10 22:02

Anycorn


1 Answers

With eager evaluation the distinction is required, languages with lazy evaluation (i.e. Haskell) if et al. can be functions.

Eager evaluation: The function's arguments are evaluated before calling the function, and only the results are passed to the function.

Lazy evaluation: A function's arguments evaluated if and only if they are accessed.

like image 190
gimpf Avatar answered Sep 23 '22 15:09

gimpf