Re: can anybody help me to understand SUBROUTINE procedure in FROTRAN language



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.



.



Relevant Pages

  • Re: schoen
    ... but I have been limiting the Central/Middle distinction ... I've been talking about, e.g., MIDDLE English, which refers only to ... I'm talking about FUCKIN' *LANGUAGES AND DIALECTS*, ... Swedish" refers to a stage of Swedish between Old Swedish and Modern ...
    (sci.lang)
  • Re: The monumental stupidity of PIE theorists further illustrated
    ... > But it is still the phonetic environment that triggers > the ... >> distinction. ... Maintenance of contrast is definitely a functional factor in sound ... If half the world's languages get on just fine with no obligatory sing/pl contrast expressed on nouns, why should speakers of language X go out of their way not to lose it? ...
    (sci.lang)
  • Re: "I just came back" vs. "Ive just come back"
    ... distinction. ... Romance languages do. ... a _present_ tense, in the sense that it's talking about a time span ... second language English speakers from all over the world. ...
    (alt.usage.english)
  • Re: Breaking backwards compatibility - good or bad?
    ... languages here - not HUMAN languages. ... Case distinction is but one of the many distinctions and pernickity rules that we have to learn when we learn to program in a language or system that uses it. ... But I find that in practice there are lots of different conventions and I'm often switching from one to another as I work on different scripts written by different people at different times, ...
    (comp.lang.php)
  • Re: Comma Operator Question
    ... All three operands are expressions, ... The distinction between statements and expressions is ... > Something that evaluates to void is a expression? ... and many languages other than C do perfectly well ...
    (comp.lang.c)