Re: 0-length fields
On 7 Nov 2006, Cyril Zorin wrote:
> My point is that we should not litter the API with paranoid checks for
> "None" just because someone is feeling "inconvenienced" to write an
> if-statement. If Yann wants calls to be more permissive, he can wrap
> them himself. There is no reason to modify hachior core because of
> this silly issue.
I think I did not make my point clear : my problem with the required guard is
not (how) to write it. My problem is that having a 0-length field or no field
at all are completely different things (and both useful). I don't need some
syntactic sugar to wrap some construction I could write myself, I need support
for what seems a missing feature (0-length fields).
> On the semantic side of things, what's the point of having a field of
> size 0? Fields of size 0 don't exist, so they should not be presented
> by the parser.
I agree they don't have a physical existence because you don't need space to
store void. But from a logical point of view, they do exist (why wouldn't
they ?). If I consider a random method from a random class, does it make sense
to ask for the set of exceptions it may throw ? I think it does, but from your
point of view, I would be required to ask first if it throws at least one.
I mean, in every single language I can think about, arrays are not required to
have a strictly positive size :). Sure it would be possible to deal with them
that way, but what good would it be ?
It seems to me a better practice to *always* deal with an array (maybe without
elements in it) than dealing with either an array for 1+ elements or
nothing. The main reason is that it enables you to follow the spec directly, no
(Continue reading)