Suggestion: declaring multiple interleaved constant sequences

new topic     » topic index » view thread      » older message » newer message

One thing I have long bemoaned is the inability to declare multiple corresponding sequence constants in a clear and simple manner. I usually end up doing something like this:

sequence fields_ = {}, 
         descs_ = {} 
procedure addfield(string field, string desc) 
    fields_ = append(fields_,field) 
    descs_ = append(descs_,desc) 
end procedure 
addfield("signature","(Should be \"Mod\\0\")") 
addfield("size","size (in bytes)") 
constant fields = fields_, 
         descs = descs_ 

I think it would be rather nice if we could just do this:

constant {fields,descs} = {"signature"|"(Should be \"Mod\\0\")", 
                           "size"|"size (in bytes)"} 

The expression on the rhs is just another way of writing

    {{"signature","size"}, 
     {"(Should be \"Mod\\0\")","size (in bytes)"}} 

Obviously such a change would [have to] apply equally to all general [sequence] expression (and sub-expression) handling, not just constant declarations, and of course there would need to be the same number of '|' present in each and every one of the (multi-)element definitions, if you want to avoid a compilation error that is.

Any thoughts? Has this suggestion already been made, and implemented, and if not, why not?blink

Pete

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu