On 05/06/07, texts writer <tex...@go...> wrote:
>
> Hello
> ETH compilers doesn't allow dynamic arrays initialization with zero
> length.
> On the opposite, oo2c allows, and I want to find out, Is it supposed
> to be bug or a feature?
I believe I discussed this with Patrik Reali some years back, and we did not
come
to a conclusion. AFAIR, the language report does not rule out arrays of
length 0,
either for dynamically allocated arrays or statically defined arrays.
In my point of view, an empty array is legal and two standard operations on
such an
array are still possible: taking its length (zero) and iterating over it (a
loop not taken).
Personally, I am often using empty arrays to indicate that there a no
results for a
given function. Using NIL for such a case is awkward, because it requires
special
#NIL tests and tends to blow up easily with a deref-of-nil whenever such a
test is
forgotten.
-- mva
I mean, for example ( I know about STRING type in oo2c)
> MODULE test;
> TYPE string = POINTER TO ARRAY OF CHAR;
> VAR s : string;
>
> BEGIN
>
> NEW (s, 0);
> END test.
>
> Personally I like this feature, if it is supposed to be the feature
> Thanks
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> ooc-compiler mailing list
> ooc...@li...
> https://lists.sourceforge.net/lists/listinfo/ooc-compiler
>
|