[M3devel] open vs. fixed arrays?

Jay jayk123 at hotmail.com
Tue May 13 15:52:08 CEST 2008




I'm being a bit lazy here. I could experiment more with the compiler and check the green book.  The compiler does not correctly implement:    VAR a : ARRAY [0..0] OF CHAR := ARRAY OF CHAR {'a'};  at least for reasons of alignment.  What is this code supposed to mean?  Is ARRAY OF CHAR {'a'} a constant fixed array with a deduced size of 1?Or a constant open array with a deduced size of 1?I believe it is supposed to be a constant open array.  And then, what is the difference?What are the visible differences?  Between  VAR a : ARRAY [0..0] OF CHAR := ARRAY OF CHAR {'a'};and  VAR a : ARRAY [0..0] OF CHAR := ARRAY [0..0] OF CHAR {'a'}; Can I act on "a" different at runtime between the two?Given that its static type is the same, I doubt it. But I haven't really thought about it.  If there is no visible difference, should the compiler implement it as the second -- probably saving a tiny bit of space.  And if not, is it supposed to generate an open array, and an initializer to do the copy?  A constant likeCONST a = ARRAY OF CHAR{'a'}  is an open array I believe, with visible differences, I think, not sure,so in the unlikely even that a "bigger" change is ok here, it has to be careful of this and other scenarios.  Really, I'm just being a bit slow. I bet these should remain open arrays but somewhere the compiler gets confused and computes the alignment and perhaps size as a fixed array, leading to assertion failures in the compiler, depending on the actual sizes, e.g.:  MODULE Main;<*UNUSED*> VAR a : ARRAY [0..0] OF CHAR := ARRAY OF CHAR {'a'};<*UNUSED*> VAR b : ARRAY OF CHAR := ARRAY OF CHAR {'a'};BEGINEND.  fails an assertion in the compiler, depending on the target -- but I expect all x86/AMD64 targets. Thanks,  - Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20080513/ed6a8ea7/attachment-0001.html>


More information about the M3devel mailing list