[erlang-questions] custom type specifier

Robert Virding <>
Wed May 13 15:57:41 CEST 2009

2009/5/13 Davide Marquês <>

> Hi there!
> Where can I find some indications on how to define a type specifier so in
>> my module I can have some new types like:
>> <<Value:Size/huffman,..>>
>> or
>> <<Value:Size/fibonacci,..>>
>> or
>> <<Value:Size/base64,...>>
>> or any custom encoding method for that matter.
>> My question may seem (and probably is) pretty trivial, but I am new in
>> writting code with erlang and some things are not pretty easy to find if you
>> do not know where to look.
>> I have looked into unicode.erl (in R13B source code) but haven't seen
>> anything relevant to answer my question.
> I'll assume your don't really want to extend the language/compiler to
> support those new type specifiers and only want them *in your modules*. :)
> With that in mind, parse_transform looks like the tool for the job!
> Using it you could specify those new fancy types and have them turned into
> the [existing] 'binary' type on compilation
> (more experience folks, what do ya think?).

I suppose it depends on whether the type specifiers are expected to *do*
anything. If so there are no provisions for adding custom encodings. It is
not trivial to add encodings to the handling of binaries. There might also
be some difficulty in describing what they are supposed to do.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090513/4ebf079f/attachment.htm>

More information about the erlang-questions mailing list