## 6 Built in functions

### 6.1 Some notes about BIFs

list_to_atom/1
  Since atoms are not garbage collected it is not a good idea to create atoms dynamically in a system that will run continously. Sooner or later the limit 1048576 for number of atoms will be reached with a emulator crash as result. In addition to the bad memory consumption characteristics the function is also quite expensive to execute.
length/1
  is an operation on lists and each time the length is tested the entire list must be traversed. Since length is implemented in C it is quite efficient anyway but it still has linear characteristics. The size/1 function which can be applied on tuples and binaries is for example much more efficient since it only reads a size field in the internal data structure.
setelement/3
  Compared with element/2 that is very efficient and independent of the tuple size setelement/3 is an expensive operation for large tuples (>50 elements) since it implies that all fields must be copied to a new tuple. Therefore it is not recommended to use setelement in recursions involving large tuples.
split_binary/2
  Depending on the situation it is in most cases more efficient to split a binary through matching instead of calling the split_binary/2 function.
  DO

              <<Bin1:Num/binary,Bin2/binary>> = Bin,

  DON'T

              {Bin1,Bin2} = split_binary(Bin,Num),

Copyright © 1991-2002 Ericsson Utvecklings AB