Re: Optional arguments (again) on Sun

Salvatore <sfilippone@xxxxxxxxxxx> wrote:

On Feb 19, 4:03 pm, nos...@xxxxxxxxxxxxx (Richard Maine) wrote:
Salvatore <sfilipp...@xxxxxxxxxxx> wrote:
Ah. yes, I was missing the small print on the SIZE description,

[that dim must not be an optional dummy argument]

The reason for that small print is that having dim changes the rank of
the result.

However, according to my copy of M&R,

"size(array,[dim=]) returns a scalar default integer that is the size
of the array array or extent along dimension dim .... "

so it would seem that your explanation, while certainly appropriate
for LBOUND/UBOUND, is at least surprising here where there seems to
be no such change of rank.

Good point. I just reacted to the bit about dim not being optional
bcause that's usually the reason for that kind of restriction. Hmm. Now
that you mention it, why is there such a restriction for size()?... And
checking further, where is it that this alleged restriction is found? I
can't find any such thing or figure out why there would be one. Did I
just miss it, or is it not actualy there. Anyone have a citation from
the standard on this (not from M&R or any other source - though I don't
off-hand see this one in skimming the latest MR&C either)?

On the point in your other posting:

The funny thing is that in my original code (not the one I first
posted here) the size(arg,dim=dim) was inside an IF (PRESENT(DIM)),
presumably it was hard for the compiler to figure out it was safe in
that case.

If there is a restriction (which I'm not convinced that there is), then
it wouldn't be that detailed. There are lots of restrictions for things
that don't have the envisioned problem in special cases. Nonetheless,
the restrictions still apply. In a case like UBOUND, which does have the
mentioned restriction, the restriction does not read "unless the
compiler can figure out that it is ok". So it really doesn't matter
whether or not the compiler can figure out that it is ok. What would be
too complicated here would be precisely elaborating a virtually infinite
number of special cases for all kinds of things like that throughout the

Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain