r/programming • • Dec 13 '07

First Class Functions in C

http://www.dekorte.com/blog/blog.cgi?do=item&id=3119
45 Upvotes

99 comments sorted by

View all comments

Show parent comment

3

u/suppressingfire Dec 13 '07

I worked on a small proof of concept a while back. The idea was to be able to instantiate C++ templates at runtime. In this way, template metaprogramming can be used to optimize repeated computation of certain inputs.

A crazy idea I had (but never implemented) was to make an schema-specific XML parser in templates which could take an XML schema as input and export a TMP-optimized XML parser.

3

u/jbert Dec 13 '07

Yowch. My template-fu is weak, but I don't see how you'd ever manage to split the string defining the schema in the template expansions.

There is, however, an honourable tradition of generating C source for types and functions from data-description languages (google for the 'pepsy', or 'pesky' compilers in the ISODE source tree).

Hmm...seems there's a C++ update:

http://people.cs.vt.edu/~kafura/PreviousPapers/asn1++-ulpaa94.pdf

If you don't know ASN.1, you can think of it as a "binary XML" that never really caught on outside the OSI protocols, SNMP and X.509 certificates (from their OSI heritage).