[erlang-questions] parameterized modules alternative in chicago boss like use case

Pablo Platt pablo.platt@REDACTED
Mon Jul 4 13:12:36 CEST 2011


exprecs looks interesting.
Not sure how hard it will be to patch erly_dtl to use it.


Thanks



----- Original Message -----
From: Tim Watson <watson.timothy@REDACTED>
To: Pablo Platt <pablo.platt@REDACTED>
Cc: "erlang-questions@REDACTED" <erlang-questions@REDACTED>
Sent: Monday, July 4, 2011 10:53 AM
Subject: Re: [erlang-questions] parameterized modules alternative in chicago boss like use case

> Alternative to pmods in that case could be records, proplist/dict, gen_server.
>
> - records
>
> To use a record, we need to tell the template about the record type.
> {% for p#product in products %}
> That's fine but we can only use the same template for several model types
> if the records of all product types have the same structure:
> {product_type1, {name, price, some_field}}
> {product_type2, {name, price, another_field}}
> We can't 'extend' a record in erlang so we'll have to manually make write the structure of all related records which will be hard in a large application.
>

You could extend (or rewrite) something like
https://github.com/esl/parse_trans/blob/master/doc/exprecs.md to
export a bunch of functions associated with the record. This stuff
works at compile time (using parse transforms) but could be achieved
at runtime with a bit of beam munging.




More information about the erlang-questions mailing list