Re: using optional arguments not present (bug)
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: using optional arguments not present (bug)         

Group: comp.lang.fortran · Group Profile
Author: nospam
Date: Nov 30, 2006 16:04

Paul van Delst noaa.gov> wrote:
> Richard E Maine wrote:
>> I don't have a formal writup handy, but the basic requirement is to have
>> an attribute for an optional dummy argument that makes the dummy
>> argument be a local variable if the actual isn't present....
> But doesn't this "delocalise" the local x (i.e. the one that would come
> into existence if no actual argument is present)? A change in one routine
> in a call chain (for testing maybe?) can have an effect all the rest of
> the way down.
>
> E.g. nearly all my procedures have an optional argument "message_log"
> which is passed to a message display routine. If it's not present, output
> is to stdout, otherwise it's output to a file with the name specified in
> the optional arg. If the main routine call has no argument (i.e. the user
> wants all message output to screen), then if there is a "local_if_missing"
> attribute specified at some point, the "down-chain" code would then output
> any messages to a file rather than to screen.

Well, yes. If that's not what you want, don't do it. I'm missing
something here. The proposal isn't to make *ALL* optional arguments act
like that - only the ones that you want to. Why would you specify the
attribute if that's not what you wanted?

If the actual isn't present, then you have a local variable, which acts
in (almost) all ways like any other non-saved local variable. The only
exception is that you can use the present() intrinsic on it.

I disagree with the characterization as "delocalizing". Of course, local
variables can affect things lower in the call tree if they are passed as
actual arguments. That's inherent in all local variables that are so
passed. It is exactly because it is a local variable that it acts that
way. Your "delocalizing" description made it sound to me as though it
somehow affected things higher in the call tree.

Sometimes I have wrapper routines that have no other purpose but to
"fill in" optional arguments like this. The published interface has
optional arguments, but the routine on the bottom doesn't have to worry
about that because the wrapper filled in defaults an dthen called the
lower-level routine with everything there.

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
no comments
diggit! del.icio.us! reddit!

RELATED THREADS
SubjectArticles qty Group
Re: [BUGS] BUG #2685: Wrong charset of server messages on clientmailing.database.pgsql-bugs ·