Uly's Journal

UlyCO

Books

Comics

Cooking

Journal

Coffee

Roasting

Resume

Valhallacon 2009

Erlang Notes

Erlang's my latest hobby project. Well, that and yaws, which is a web framework for Erlang. Erlang is very different, so I'm going to start to note some the things that either caused me startlement or were difficult to figure out, so I can refer back to them. The veracity of these notes should be held in some doubt, as I've just started to get my feet wet.

The '=' operator is a patternmatch, and only assigns if the variable is unbound. Variables can only be bound once. This is wacky, but it means you can do stuff like '[A,B,C] = [1,2,3]' to assign C to 3 if A already is set to 1 and B is already set to 2. Oh, and variables have start with either an uppercase letter or an underscore.

As near as I can tell, a variable can only be bound in the shell or inside a function. A function can only be defined inside a module, and a module needs to be defined in a file, it can't be defined in the shell.

A string such as "hello" is actually a list of five elements, where each element is one of the characters. If you have what would appear to be integers in a list, such as '[50,55]', don't be fooled, those are actually character values. If you interpolate that list as a string, you get '27', because 50 is the decimal value for 2, and 55 is the decimal value for 7.

In yaws, each '⟨erl&rang⟨/erl&rang' section is its own module. The out/1 function is automatically exported. If you need to refer between them, you can explicity name the module with '⟨erl module=whatever⟩'. If you do so, it appears that any other functions you define in that module are automatically exported.

previous || next

Privacy Policy 
All material Copyright © 2003–2009 Ulysses Somers, except where otherwise noted.