PL/I Cant create a Upper case function
Others have explained the problems of character conversions,
but the bigger problem is returning strings of unknown size.
It will take some time to understand all the ways that languages
can use to allow returning arguments where the size isn't known
at compile time, and I believe that the answer is different
for different versions of the Fortran standard.
In C, to return a character string it must either be statically
allocated (inconvenient in many cases) or the caller must free()
it (also inconvenient). C makes ******** what other languages
have to do implicitly, that is, allocate and deallocate the
return value at the appropriate time.
PL/I has had varying length character strings from the beginning,
but the maximum length has to be known when they are allocated,
but when is it allocated?
Language designers tend to make the required subroutine calling
sequence relatively simple to allow for a variety of implementations.
Many systems require that, for return values that don't fit in
a register, that the caller supply the space for the return value.
In that case, it needs to be known at compile time, or at least
at call time.
It might be, then, that PL/I requires the maximum length to be
supplied at compile time, but with VARYING length strings the
return value can be any length up to the specified maximum.
Fortran 77 CHARACTER variables, somewhat like the way characters
were done in earlier Fortrans, have a fixed length and are blank
padded. Dummy arguments as far as I can tell have to have a length
specified at compile time. Sometime later the (*) length for
dummy arguments was added.
As far as I can tell, in F2003 a function can be declared with (*)
length, but it must be called from a routine where it is declared
with a non-(*) length.
In any case, a PL/I function can return a VARYING length string
where the length is the length of the RETURN expression. That
length will be used in any expression that uses the return value,
or it can be assigned to a VARYING variable. It might
be that the maximum length needs to be a compile time constant.
-- glen
|