[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mapping data



On Tue, Dec 09, 2003 at 06:54:32PM +0100, Roger Price wrote:
> > One of the barriers to using lightweight languages for many low-level
> > tasks is the difficulty in interfacing with data from an outside source.
> > ... It would be cool to be able to define a grammar for the data
> > (probably with functions to validate and perform unavoidable
> > transformations) that could interact directly with the runtime system.
> 
> Is Zephyr the sort of thing you're thinking of? The prototype supported
> C, ML, Java and C++.  The authors say it compares very favourably with
> ASN.1.

Thanks for the link!  I only skimmed the paper, but it appears to be
fairly specific to describing abstract syntax trees for compilers.
It is meant for describing the program itself and includes
functionality to pickle and unpickle intermediate code for exchange
between compiler passes written in the languages you indicated.

Interesting stuff, but I'm more concerned with run-time or
compile-time capabilities for programs written in the language, and
for arbitrary data structures rather than a fairly specific domain.

One could use this as a starting point, but for that it suffers from
the same problems XML or other serialization formats have: it is
only useful if you have control over the layout of the stored data.
Taking your type system and mapping it to an output stream is easy;
mapping an input stream to your type system is harder.

What I have in mind is something that would let you define a type:

type 'a BinaryTree = Branch of 'a BinaryTree * 'a * 'a BinaryTree
                   | Leaf

and then define a translator of some kind that lets me treat a range
of memory as a BinaryTree.  The translator would swizzle pointers on
the fly and guarantee memory safety so I could use it just like I
would a BinaryTree created within the language.

Object-oriented databases are the closest thing I can think of in
that they are fairly transparent, but they control the data layout.
I suppose object-oriented databases are just a special case of a
more general system that I'd like to see.

- Russ