Waldek Hebisch wrote:
Sure it's allowed to. But GPC choses not to do so for normal subranges. I think in most cases that's preferable since often subranges are not declared to reduce storage (at the cost of performance), but to declare proper array indices etc.
It is very debatable: AFAIKS gpc have no way to reduce storage requirements of standard-compliant code except if packing is used. Since packing involves breaking alignment rules it usually have big impact on performance. Reducing storage for subranges usually have very moderate impact on runtime and in realictic programs reduced memory usage may fully compensate for extensions and truncation (many benchmarks run in very small memory so they prefer bigger size).
"packed subranges" as well as `Integer (n)' or `ShortInt' etc. (all non-standard, I know) should provide this, without breaking alignment (such as packed records and arrays would).
Frank Heckenbach wrote:
This could be changeg, e.g., to:
TypeOfSize (Integer, n)
I think better syntax would be:
type foo = Integer attribute(Size(n),...);
differences are:
- attribute suggest much more general use (I think it could
work for general extensions) 2) IMHO at the end of type it need to be only contextually reserved so someting like:
type attribute = Integer attribute(Size(5)); foo = attribute attribute(Volatile);
This might be a good idea. Actually, GPC allows `attribute' for variables already (though with a `;' before -- maybe it would be better to drop it if it doesn't cause problems), and it should be possible to also allow it for types.
Still, if it turns out that packed subranges are suitable, do we need this at all?
Frank