?

Log in

No account? Create an account

Lastly, something geeky - Journal of Omnifarious

Jun. 2nd, 2003

04:35 pm - Lastly, something geeky

Previous Entry Share Next Entry

I wish LJ had an 'inspired' mood. It's a mood that I'm in frequently enough that it's absence bothers me. You could have a little penguin with a floating lightbulb as the icon.

Well, I've been slowly making my way through Modern C++ Design, and I encountered an interesting idea I'd never seen before. I was reading chapter 3 on typelists, where all of my experience with lisp was serving me well in understanding just how all the compile-time template expanion stuff was working.

Then I ran across an idea for building data structures out of typelists. I was floored. I realized I could use the idea to build automatic code for translating a data structure to a standard format, send it somewhere, and read it back in,. Lots of code in networking applications is concerned with transforming the in-memory representation of something to a format that you can send to something else. Here was a method I could use to generate all that code for me!

*boing* Now I'm all excited, and inspired. I want to try it out. :-)

</lc-cut>

Current Mood: inspired
Current Music: They Might Be Giants - See The Constellation

Comments:

From:rosencrantz319
Date:June 2nd, 2003 02:42 pm (UTC)
(Link)
(Reply) (Thread)
[User Picture]
From:elkman
Date:June 2nd, 2003 08:24 pm (UTC)
(Link)
Hmm. That sounds really useful, especially since the application I work on does a lot of marshaling/un-marshaling. If I had a C++ object with a bunch of data members, could I build a typelist so the object could be marshaled/unmarshaled easily? What's involved in building a typelist over and above just building a class?
(Reply) (Thread)
[User Picture]
From:omnifarious
Date:June 2nd, 2003 11:29 pm (UTC)
(Link)

Well, the problem is that the marshalled and unmarshalled data would have to look like the kind of structure you'd get out of a typelist. That structure doesn't look a lot like a traditional structure you'd find in C++ code, though the basic types are all the same. I guess I'm saying that it's something that's difficult to apply to existing data structures.

Now, if you were willing to do a bit of refactoring and build that data structures that needed to be marshalled and unmartialled around this construct, access to the data would be as efficient as access to struct members, and only a little more awkward. It would all be type safe, and would involve some template trickiness, but no macros, so all the names involved would be nicely inside namespaces and things.

The technique is a bit hard to explain without showing a bunch of code. And, also, I don't know exactly what that code would look like right now, just that it could be written. I'd have to play around a bit to actually write it.

(Reply) (Parent) (Thread)
[User Picture]
From:omnifarious
Date:June 5th, 2003 11:32 pm (UTC)
(Link)

I posted a new entry on this with some sample code.

If you could convince them to, I could come to your company and explain the concept and how to build it to as many people as they wanted. For a price of course. :-)

(Reply) (Parent) (Thread)