[erlang-questions] Fwd: encoding packets a style+efficiency question

Anupam Kapoor anupam.kapoor@REDACTED
Wed Jul 27 06:15:59 CEST 2011

sorry, hit a reply, instead of a 'reply-all'.

kind regards

---------- Forwarded message ----------
From: Anupam Kapoor <anupam.kapoor@REDACTED>
Date: Wed, Jul 27, 2011 at 8:54 AM
Subject: Re: [erlang-questions] encoding packets a style+efficiency question
To: Richard O'Keefe <ok@REDACTED>

On Wed, Jul 27, 2011 at 8:08 AM, Richard O'Keefe <ok@REDACTED> wrote:
| Why did you write
| encode_pkt_string(EncodedPkt, [FirstFmt | RestFmt], [FirstVal |
RestVal]) when FirstFmt =:= ?BYTE ->
| instead of
| encode_pkt_string(EncodedPkt, [?BYTE | RestFmt], [FirstVal | RestVal]) ->
| (and similarly with ?STRING and ?RAW)?
oooh nice. i didn't know i could do that ! ignorance is not a good
defence, is it ?

| Come to that, why use ?BYTE ?STRING and ?RAW instead of just plain
| byte, string, and raw?
well, to confess, i was initially thinking of having a bunch of
custom-format specifiers e.g.

   "%B" would represent a byte
   "%S" would represent a string etc.

the user would then specify the "format" of their respective packets,
and get those stamped out via actual encoders for the primitive types.
things would go in the reverse direction during decode operations.

unlike C (vsnprintf and friends), i don't know *how* to do that in
erlang, which is when i wrote what you see in the attached file. having
done that, i realized that there is no need to have 'strings' and
changed those to atoms.

kind regards

In the beginning was the lambda, and the lambda was with Emacs, and
Emacs was the lambda.

More information about the erlang-questions mailing list