C question
John Ruschmeyer
john at moncol.UUCP
Fri Apr 19 00:52:21 AEST 1985
>From: kjm at ut-ngp.UUCP (Ken Montgomery)
>Message-ID: <1617 at ut-ngp.UUCP>
>
>From: lspirkov at udenva.UUCP (Goldilocks)
>>In article <> jack at boring.UUCP (Jack Jansen) writes:
>>>
>>>procedure p(var i:integer):integer;
> ^^^
>>>begin
>>> p := i;
>>> i := i+1;
>>>end (* p *);
>>>
>>
>>you obviously don't know your pascal! a function returns
>>something. a procedure doesn't.
>>
>> Goldi
>
>The 'var' keyword has the effect that the value of 'i' is assigned
>to the corresponding actual parameter in the calling routine at the
>termination of the called routine.
What goldi was referring to was this:
>procedure p(var i:integer):integer;
^^^^^^^^
The part I have highlighted is used in a FUNCTION declaration to declare
the type of the value returned. The type of values returned by a PROCEDURE
is declared by the 'var' as you pointed out.
The correct declaration is:
procedure p(var i:integer);
I don't have the original article handy, but it almost looks like someone
was trying to perform the illegal:
function p(var i:integer):integer;
which would be an attempt at declaring a function which returns two values.
I pray that somewhere there isn't a compiler which would accept that.
(Ooh, ick!)
--
Name: John Ruschmeyer
US Mail: Monmouth College, W. Long Branch, NJ 07764
Phone: (201) 222-6600 x366
UUCP: ...!vax135!petsd!moncol!john ...!princeton!moncol!john
...!pesnta!moncol!john
Silly Quote:
"Ah, but what is a dream but reality without a backbone?"
More information about the Comp.lang.c
mailing list