Keyword documentation

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Keyword documentation

tsuraan
Is there a list somewhere of what erlang's keywords/reserved words
are, and what they do?  I just found the other day that query is a
reserved word, which appears to be something archaic.  cond is another
reserved word, whose purpose I can't find, but it seems promising.
I'm sure there's a doc somewhere with erlang's keywords and their
meanings, but I'm not having any luck finding it.

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Keyword documentation

Dale Harvey
The following are reserved words in Erlang:

after and andalso band begin bnot bor bsl bsr bxor case catch cond div end
fun if let not of or orelse query receive rem try when xor

from http://www.erlang.org/doc/reference_manual/introduction.html

On 19 February 2010 06:10, tsuraan <[hidden email]> wrote:

> Is there a list somewhere of what erlang's keywords/reserved words
> are, and what they do?  I just found the other day that query is a
> reserved word, which appears to be something archaic.  cond is another
> reserved word, whose purpose I can't find, but it seems promising.
> I'm sure there's a doc somewhere with erlang's keywords and their
> meanings, but I'm not having any luck finding it.
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:[hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Keyword documentation

tsuraan
> The following are reserved words in Erlang:

Ok, so assuming no definitive list of what they do exists, I guess
I'll start one :)  These are either from the top of my head, or
http://erlang.org/doc/reference_manual/expressions.html .  Any
corrections, completions, clarifications are welcome.

> after
Sets the timeout in a receive block

> and
boolean logic "and"

> andalso
short-circuiting "and"

> band
bitwise "and"

> begin
Start a block, used for grouping expresssions (no idea what use it is)

> bnot
> bor
bitwise "not" and "or"

> bsl
> bsr
Shift bits left and right

> bxor
bitwise "xor"

> case
Beginning of a case statement, sort of like C's switch statement

> catch
Trap an error, converting it into the tuple {'EXIT', ...}.  If no
error occurs, the result of the wrapped function is returned.  Also
used in the try statement.

> cond
?

> div
integer division

> end
Complete a statement (fun, case, try, etc).

> fun
Begin an anonymous function

> if
Erlang's crazy if statement.

> let
?

> not
Logical "not"

> of
Goes between value of case statement and guard clauses

> or
Logical "or"

> orelse
Short-circuiting "or"

> query
Obsolete, something about mneosyne?

> receive
used to get the next message from the process mailbox

> rem
Remainder from integer division (modulus)

> try
New way to trap errors, used with catch and ends with end

> when
Start a guard sequence for receive, function declaration, others?

> xor
Logical xor

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Keyword documentation

caio ariede
What does "cond" and "let" do?

Caio Ariede
http://caioariede.com/


On Fri, Feb 19, 2010 at 2:46 PM, tsuraan <[hidden email]> wrote:

> > The following are reserved words in Erlang:
>
> Ok, so assuming no definitive list of what they do exists, I guess
> I'll start one :)  These are either from the top of my head, or
> http://erlang.org/doc/reference_manual/expressions.html .  Any
> corrections, completions, clarifications are welcome.
>
> > after
> Sets the timeout in a receive block
>
> > and
> boolean logic "and"
>
> > andalso
> short-circuiting "and"
>
> > band
> bitwise "and"
>
> > begin
> Start a block, used for grouping expresssions (no idea what use it is)
>
> > bnot
> > bor
> bitwise "not" and "or"
>
> > bsl
> > bsr
> Shift bits left and right
>
> > bxor
> bitwise "xor"
>
> > case
> Beginning of a case statement, sort of like C's switch statement
>
> > catch
> Trap an error, converting it into the tuple {'EXIT', ...}.  If no
> error occurs, the result of the wrapped function is returned.  Also
> used in the try statement.
>
> > cond
> ?
>
> > div
> integer division
>
> > end
> Complete a statement (fun, case, try, etc).
>
> > fun
> Begin an anonymous function
>
> > if
> Erlang's crazy if statement.
>
> > let
> ?
>
> > not
> Logical "not"
>
> > of
> Goes between value of case statement and guard clauses
>
> > or
> Logical "or"
>
> > orelse
> Short-circuiting "or"
>
> > query
> Obsolete, something about mneosyne?
>
> > receive
> used to get the next message from the process mailbox
>
> > rem
> Remainder from integer division (modulus)
>
> > try
> New way to trap errors, used with catch and ends with end
>
> > when
> Start a guard sequence for receive, function declaration, others?
>
> > xor
> Logical xor
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:[hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Keyword documentation

Jay Nelson-2
In reply to this post by tsuraan
tsuraan wrote:

 > begin
Start a block, used for grouping expresssions (no idea what use it is)

---------------------

Most common uses I've found are in list comprehensions:

[ X || X <- List,  begin FooVal = foo(X), ... complex test using  
FooVal more than once ... end ].

[ begin
        FooVal = foo(X),
        ... complex expression using FooVal more than once ...
   end || X <- List ].



It lets you introduce temporary variables in places where the context  
makes it difficult to reference them.
I do this for documentation purposes sometimes (see R.O.K.s previous  
objection to F local fun var), and when a call to an expensive  
function needs to occur more than once in a decision process.


Also works in binary comprehensions:

<<  << X >> ||  << X >> <= Binary,  begin FooVal = foo(X), ... end >>.

<<  <<(begin FooVal = foo(X), ... end)>> || << X >> <= Binary >>.

The parens are necessary because the expression in the binary  
constructor has to be evaluated and returned as a valid element  
before the binary construction can occur.

The value of a begin ... end construct is the value of the last  
statement.


jay



________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Keyword documentation

tsuraan
> Most common uses I've found are in list comprehensions:
>
> [ X || X <- List,  begin FooVal = foo(X), ... complex test using
> FooVal more than once ... end ].
>
> [ begin
>         FooVal = foo(X),
>         ... complex expression using FooVal more than once ...
>    end || X <- List ].
>
>
>
> It lets you introduce temporary variables in places where the context
> makes it difficult to reference them.
> I do this for documentation purposes sometimes (see R.O.K.s previous
> objection to F local fun var), and when a call to an expensive
> function needs to occur more than once in a decision process.
>
>
> Also works in binary comprehensions:
>
> <<  << X >> ||  << X >> <= Binary,  begin FooVal = foo(X), ... end >>.
>
> <<  <<(begin FooVal = foo(X), ... end)>> || << X >> <= Binary >>.
>
> The parens are necessary because the expression in the binary
> constructor has to be evaluated and returned as a valid element
> before the binary construction can occur.

That's some crazy stuff.  I never would have thought of doing that,
but now that I've seen it...  Thanks a ton!

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]