Hi. I independently came up with a ProtoBuf-like system, with an
interesting twist I thought I'd share: compile-time lambda functions for
controlling how objects are serialized. Instead of auto-generating class
definition code, my system works with existing classes. Rather than
writing interface code between generated classes and an existing set of
code, you write lambda functions inside the equivalent of .proto files
(.struct files) that describe how the system processes classes that already
exist.
Here's an example of a .struct file:
Object {
property : int | obj.property.id;
}
The lambda function comes after the pipe character; it gets a single
argument, 'obj', which is an instance of Object. At serialization time, it
transforms 'property' from an object reference into an integer. The
general idea is to embedd this with the code. For example:
class Object {
//has an integer
}
ObjectDefinition = [
Object {,
property : int | obj.property.id;',
}
];
In the original design, there were lambda functions for controlling how
deserialization would happen, too, so you might see:
property : int | obj.property.id | get_object_from_id(obj.id);
But these turned out to not be necessary for my use case (I was writing
code in JavaScript, which simplified deserialization given JS's
dynamic--more like, total lack of a--type system).
Anyway, you can find more information here:
https://github.com/joeedh/STRUCT/wiki/Intro-and-Examples
P.S.: this is not an advertisement. In many respects ProtoBuf is superior
to what I've come up with, and frankly I don't have the time to maintain my
own system. I only created it because, at the time I wasn't able to find
an existing solution. If the ProtoBuf developers want to steal my ideas
(please! I hate maintaining things!), they are free to do so.
--
You received this message because you are subscribed to the Google Groups
Protocol Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.