(j3.2006) zero-sized stuff

Walt Brainerd walt.brainerd
Thu Mar 19 12:16:13 EDT 2015


Again, I agree. But unless you knew it was going to lead
to the wrong answer, I think a usual reading would refer
to the variable c when the statement is first encountered.

So what is wrong with assigning a value to a string of size 0?
What is that sentence supposed to accomplish?
If nothing, why not delete it? At best it is ambiguous; at worst,
it is wrong.

There is a related funny business:

16.6.1(3):
3 An array is defined if and only if all of its elements are defined.

By this definition, an array of size 0 is always defined (similar words
for 0-sized strings). Thus 16.6.2 is redundant. What it should say is
something like: "Because a 0-sized array is always defined, all the
following rules about definition and undefinition to do not apply."
Because it is impossible for such to become undefined.

Yes, we are discussing dancing angels and pin heads, but I like
to have a little fun now and then.

On Wed, Mar 18, 2015 at 5:50 PM, Robert Corbett <robert.corbett at oracle.com>
wrote:

> On 03/18/15 17:35, Walt Brainerd wrote:
> > So if I understand this correctly, with the first assignment
> > character string c gets its length from the expression, but
> > not the value (not that it matters), but with the second
> > assignment statement c does not get a value because it
> > is zero length. I don't see any exception for an allocatable
> > string. Now what am I missing?
> >
> > program f
> > character(len=:), allocatable :: c
> > c = ""
> > print *, len(c), "X"//C//"X"
> > c = "QQQ"
> > print *, len(c), "X"//C//"X"
> > end program f
>
> The question would be if the variable mentioned in the
> last sentence of paragraph 1 of 7.1.2.3 refers to the
> variable before or after it has been deallocated and
> then allocated as described in paragraph 3 of 7.1.2.3.
>
> Bob Corbett
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3
>



-- 
Walt Brainerd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20150319/767a7aaf/attachment.html 



More information about the J3 mailing list