RangeNetworks / OpenBTS-UMTS

3G UMTS Data Radio Access Network Node
GNU Affero General Public License v3.0
297 stars 196 forks source link

Idea: Use C++11 Closures for building ASN.1 objects #14

Open SoniEx2 opened 6 years ago

SoniEx2 commented 6 years ago

I don't know how feasible this would be, but currently we use uhh things like this:

ASN::Something mainthing = something;
mainthing.something.present = subthing;
ASN::Subthing *subthing = &mainthing.something.choice.subthing;
subthing->etc = ...;

Now, I personally don't find this very readable. I wonder if it's possible to use something like this instead:

something([] (ASN::Something &mainthing) {
    mainthing.something.present = thing;
    mainthing.something.choice.subthing([] (ASN::Subthing &subthing) {
        subthing.etc = ...;
    });
});

This has many benefits, such as:

(PS: I don't consider myself a C++ developer and I'm not sure if any of this is the right/valid syntax, but since I'm having to work with this it'd be nice if I could help make it better.)