[erlang-questions] run-time record limitations
Fri Jan 16 12:49:29 CET 2009
Unfortunately you cannot get away from the fact that records have to be defined at compile time. You can do some trickery on records based on the fact that they really are ordered tuples where the first element is the record name as an atom. What you cannot do is change the order of keys or the length of a record, this will make all code referencing that record consider it to be another record or just an anonymous tuple.
An example of record mangling, which might give you some ideas: http://stackoverflow.com/questions/62245/merging-records-for-mnesia
----- "deepblue" <cktgatb@REDACTED> wrote:
> Im developing an Erlang system and having reoccurring problems with
> the fact that record's are compile time pre-processor macros
> and that they cant be manipulated at runtime... basically Im working
> with a property pattern, where properties are added at run-time to
> objects on the front-end (AS3). Ideally I would reflect this with a
> list on the Erlang side, since its a fundamental datatype, but then
> using records in QLC [to query ETS tables] would not be possible
> to use them I have to specifically say which record property I want
> query over... I have at least 15 columns in the larges table, so
> listing them all in one huge switch statement (case X of) is just
> plain ugly.
> does anyone have any ideas how to elegantly solve this? maybe some
> built-in functions for creating tuples with appropriate signatures
> use in pattern matching (for QLC)?
> erlang-questions mailing list
More information about the erlang-questions