Erlang (programming language)/Tutorials/Advanced syntax: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Eric Evers
(New page: There are some strang elemente of erlang syntax, some of which are caused by the need of parallel programming and functional programming. Each if structure must have a true conditional ...)
 
imported>Chris Day
(becuase to because)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{subpages}}
There are some strange elements of erlang syntax, some of which are caused by the
needs of parallel programming and functional programming.


There are some strang elemente of erlang syntax, some of which are caused by the
Each 'if' structure must have a true conditional branch.
need of parallel programming and functional programming.
If a variable is assigned(matched) in one branch of an 'if' or 'case' sturcture and used
 
Each if structure must have a true conditional branch.
If a variable is assigned(matched) in one branch of an if or case sturcture and used
after that structure then the variable must be assigned(matched)
after that structure then the variable must be assigned(matched)
in all the branches.  
in all the branches.  


Guard expressions are restricted to only builtin functions. This is  
Guard expressions are restricted to only builtin functions. This is  
generally not a problem becuase on can precalculate values from non-builtin functions
generally not a problem because one can precalculate values from non-builtin functions
before the guard and then use the value in the guard expression.
before the guard and then use the value in the guard expression.
Restricting functions in guards protects from side effects and may increase  
Restricting functions in guards protects from side effects and may increase  
speed.
speed.

Latest revision as of 00:58, 6 February 2010


There are some strange elements of erlang syntax, some of which are caused by the needs of parallel programming and functional programming.

Each 'if' structure must have a true conditional branch. If a variable is assigned(matched) in one branch of an 'if' or 'case' sturcture and used after that structure then the variable must be assigned(matched) in all the branches.

Guard expressions are restricted to only builtin functions. This is generally not a problem because one can precalculate values from non-builtin functions before the guard and then use the value in the guard expression. Restricting functions in guards protects from side effects and may increase speed.