Re: can anybody help me to understand SUBROUTINE procedure in FROTRAN language
- From: cri@xxxxxxxx (Richard Harter)
- Date: Fri, 18 May 2007 20:10:13 GMT
On Fri, 18 May 2007 09:50:02 -0700, "osmium" <r124c4u102@xxxxxxxxxxx>
wrote:
"Richard Harter" wrote:
On Thu, 17 May 2007 17:16:01 -0700, "osmium" <r124c4u102@xxxxxxxxxxx>
wrote:
"CBFalconer" wrote:
IIRC, a FORTRAN subroutine is a function that returns a value.
Functions that do not return a value are referred to as procedures.
This is an artificial distinction not present in modern languages.
Actually it is a very valuable distinction, and present in the
better languages. These are not necessarily the latest languages.
I prefer the distinction but I can't see that it has any actual _value_,
even for documentation. If a function was forbidden to have side effects
it
would be different matter. Tell us more about this value of which you
speak.
One way to express the difference is that in code a function invocation
represents a value whereas a subroutine/procedure represents a command.
You cannot put a subroutine call in an expression; you can a function
call.
(Modulo various language eccentricities.) C has backdoor procedures via
void functions. Void "functions" cannot be on the RHS (AFAIK - there may
be something weird in the language specs) whereas ordinary functions can
be.
Subroutines are necessarily impure; functions can be pure and in some
languages are required to be pure.
Since procedures and functions are used differently the documentation
needs must reflect the difference.
First of all, I know CBFalconer posts on comp.lang.c so I read his response
with that in mind. I inferred that he meant that C would be a better
langauge if it had a new keyword, "procedure", to replace the idiom where a
function returning void is used in lieu of a procedure But I must admit
that I am not really good at mind reading.
Ah. We now have a multitude of questions in play. The OP wanted to know
about subroutines in fortran. Other questions include the value of the
procedure/function distinction generally, the value of the distinction in
functional languages (which Harrop seems to feel are the only 'real'
languages) and its potential value in C.
Actually C does something a bit off the wall; everything is a function but
you can always ignore the returned result (if any) and use it as a
procedure. Would it be better if it did have procedures? (All answers
moot since it ain't agonna happen.) You know, it might. There are classes
of functions, printf and fprintf come to mind, that have returns that are
almost always ignored. The whole (void) business is a bit of a croc.
.
- Follow-Ups:
- References:
- can anybody help me to understand SUBROUTINE procedure in FROTRAN language
- From: vijay thakur
- Re: can anybody help me to understand SUBROUTINE procedure in FROTRAN language
- From: Jon Harrop
- Re: can anybody help me to understand SUBROUTINE procedure in FROTRAN language
- From: CBFalconer
- Re: can anybody help me to understand SUBROUTINE procedure in FROTRAN language
- From: Richard Harter
- can anybody help me to understand SUBROUTINE procedure in FROTRAN language
- Prev by Date: Re: can anybody help me to understand SUBROUTINE procedure in FROTRAN language
- Next by Date: Re: can anybody help me to understand SUBROUTINE procedure in FROTRAN language
- Previous by thread: Re: can anybody help me to understand SUBROUTINE procedure in FROTRAN language
- Next by thread: Re: can anybody help me to understand SUBROUTINE procedure in FROTRAN language
- Index(es):
Relevant Pages
|