- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For an optional dummy variable one can use explicit names:
call sub(x,A=1,C=2)
...
subroutine sub(x,A,B,C)
real,optional:: A,B,B
real x
...
Is there a way to force the caller to use the named method?
Thanks,
Tim H
call sub(x,A=1,C=2)
...
subroutine sub(x,A,B,C)
real,optional:: A,B,B
real x
...
Is there a way to force the caller to use the named method?
Thanks,
Tim H
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not that I can think of.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here's a practical one:
Jugoslav
type RS4UU9OPOM98GHEJ390O0O0O end type RS4UU9OPOM98GHEJ390O0O0O subroutine sub(x,OO00UI764IOPLELMS89OQA,A,B,C) real:: x type(RS4UU9OPOM98GHEJ390O0O0O), optional:: OO00UI764IOPLELMS89OQA real, optional:: a, b, c ...See the point? :-)))))))
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, that's diabolical!
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
DUHHHH!
Is an empty type even allowed. Guess I'm missing it entirely!!!
Slowly yours,
Dumbo
Is an empty type even allowed. Guess I'm missing it entirely!!!
Slowly yours,
Dumbo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, actually. But you could insert some dummy component.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please correct me if I'm wrong, but....
In Jugoslav's example, he uses the fact that any ambiguity among optional arguments forces the caller to be explicit. A caller is extremely unlikely to define a variable of that excruciating type (I can't bear to type the name), therefore, they must explicitly name the remaining arguments.
As you had asked, the result is that the user must always call the routine with the arguments explicitly named.
In Jugoslav's example, he uses the fact that any ambiguity among optional arguments forces the caller to be explicit. A caller is extremely unlikely to define a variable of that excruciating type (I can't bear to type the name), therefore, they must explicitly name the remaining arguments.
As you had asked, the result is that the user must always call the routine with the arguments explicitly named.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's not ambiguity, per se. Jugoslav's technique makes it difficult for the programmer to pass the second argument - they would have to declare a variable of the proper type. Note, however, that the type IS visible to the caller - it has to be - so if the programmer was determined, they could do it.
Since the second argument is optional, it may be omitted. But if it is omitted, the language requires that all following arguments be passed using the keyword name. Also, CVF disallows using consecutive commas (an extension) when calling a routine that has an explicit interface.
Steve
Since the second argument is optional, it may be omitted. But if it is omitted, the language requires that all following arguments be passed using the keyword name. Also, CVF disallows using consecutive commas (an extension) when calling a routine that has an explicit interface.
Steve

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page