records in text files or configuration

Fredrik Thulin <>
Thu Aug 5 22:38:27 CEST 2004

On Thursday 05 August 2004 11.37, Richard Carlsson wrote:
> On Thu, 5 Aug 2004, Fredrik Thulin wrote:
> > Is there a way to define a record in my application and then use
> > that record in my 'erl -config' file or in a plain text file that I
> > read using file:consult() or something similar? 
> The #name{f1=X1,...,fn=Xn} notation is just syntactic sugar for
> tuples on the form {name, X1, ..., Xn}, so even if you use record
> syntax to create the entries and write them to a file, that file
> will simply contain
>  [{db, one, foo},
>   {db, two, bar}].
> If you read this back with consult(File), you can of course
> again use the record syntax for working with the read entries
> - as long as you haven't modified the record definition since
> you wrote them to the file. It could be a good idea to specify
> an explicit, stable, external data format, that is separated
> from the internal representation, if this is to be used for
> something serious.

Thank you for your answer. The flexibility to be able to modify the 
record (like adding elements to it) in the future, as well as not 
having to enter data for all elements was what I was after.

I guess I'll have to invent myself some kind of plain text format that 
is reasonably easy to modify and still easily parseable. Too bad, I'll 
have to deal with quoting and stuff which would otherwise have been 
handled for me.


More information about the erlang-questions mailing list