Erlang has a special syntax for (de)constructing structured binary data. This is called "the bit syntax". Here is a code fragment for efficiently parsing the headers out of a IP packet in Erlang: <> = Packet, * ''Adapted from the example in the manual at *** http://www.erlang.org/doc/r7b/doc/extensions/bit_syntax.html#6 ( BrokenLink ) * and not independently tested (don't have an IP packet handy - can someone send me one? ;-))'' (That link is broken; here's one that works: *** http://erlang.org/documentation/doc-5.4.12/doc/programming_examples/bit_syntax.html) *** http://www.erlang.se/euc/00/bit_syntax.html) ---- ''Question:'' Does the erlang bit syntax give any assistance with handling structures that contain pointers? That is, is it possible to take some bits, treat them as an address, and access memory at that address? ''Answer:'' Not without writing an extension to allow you to do that. Accessing an arbitrary memory location is an unsafe process. ---- ''Question'': Does Erlang assume NFS network order? ''Answer'': Network order is the default. ''Question'':Is there a way to override any such default byte ordering in packets? ''Answer'': Yes, you can specify the byte ordering. CeeLanguage (and CeePlusPlus, ObjectiveCee) has a rather similar feature (the BitField), which is less widely used then one might expect, for two reasons: * It is unacceptable for portable code (especially when accessing fields within persistent data structures) because C does not define whether or not the LSB or MSB is mentioned first (this is in addition to any endianality issues). * It is often discouraged for system code (which often need not be portable) as many hardware registers are write-only, have different meanings for read/write, and/or have destructive read--making the ReadModifyWrite implemenation of BitField modifications unsuitable for such registers. The second issue probably doesn't apply to Erlang, but the first clearly does. How are the bits packed in? ---- See related paper http://www.erlang.se/workshop/2004/esmb.pdf ----