Silly Ada Generic Package Management? -
i have started using ada, , i'm finding generic package declarations rather silly. maybe i'm not doing right, i'm looking better options.
take @ below example.
package std_code_maps new ada.containers.map(key_type => std_code_type; element_type => ada.strings.unbounded.unbounded_string); std_code_map : std_code_maps.map; -- . . . procedure do_something item : ada.strings.unbounded.unbounded_string; begin item := std_code_maps.element(std_code_maps.first(std_code_map)); -- item -- . . . end do_something; it cleaner able write std_code_map.first.element instead of godforsaken std_code_maps.element(std_code_maps.first(std_code_map));
obviously i'm doing wrong -- think. i'm repeating phrase std_code_map @ least thrice on there. i'm verbosity , everything, code i'm writing seems bad , silly me.
i wondering if there solution doesn't require rename package package map renames std_code_maps; of course shorten code don't want on each , every procedure entry. think std_code_map.first.element simpler. can done in ada 2012?
note: using unbounded_string package default difficult. did standard library designers give thought ridiculous , overly long package hierarchy?
thanks reading this, , potentially helping me out. i'm new ada.
gnat gpl 2012 , 2013, , fsf gcc 4.7 , 4.8, support new container indexing scheme of ada 2012, means can write
item := std_code_map ({some cursor}); and can -gnat05 switch force ada 2005 mode! (which has bug).
ada 2005 allows call primitive function of tagged type using object.function notation, provided first operand of tagged type; can write std_code_map.first shorthand std_code_maps.first (std_code_map).
putting these together, can write
item := std_code_map (std_code_map.first); which quite short!
Comments
Post a Comment