Re: seed problem in a random number generator subroutine
On Thu, 14 Sep 2006 23:43:03 +0000 (UTC), glen herrmannsfeldt
<gah@seniti.ugcs.caltech.edu> wrote:
> Richard E Maine <nospam@see.signature> wrote:
> (snip about mixing scalar and array arguments/dummies)
>
> > It was in a wrapper subroutine, which was supposed to do something like
> > (probably with other arguments also, but this is the critical part).
>
> > subroutine wrapper(x)
> > real x(*)
> > call sub(x)
> > end
>
> Without the real x(*) on a system that used call by value result
> for scalars this wouldn't work for a arrays, but it should work for
> call by reference on most systems that I know about.
>
> There are stories about old C code, (mostly before ANSI C)
> that would use int variables to in place of your x, to pass
> a pointer through to another subroutine. (I believe older
> compilers allowed implicit declaration for int variables.)
"Classical" C (K&R1) allowed _C parameters_ (= Ftn dummy args) to be
implicitly int, and C89 retained this. C99, and C++98, deleted it.
K&R1 and C89 also allow _function_ names to be implicitly declared (as
taking old-style arguments and returning int). C99 and C++98 do not.
And the former but again not the latter allow a variable declaration
to omit the type and default to int:
/* older C */ static x; /* is an int */
and a function definition to omit all specifiers ditto:
/* older C */ f (x) { /* function, of int x, returning int */ }
No C has ever allowed a variable's declaration to be entirely
implicit. I don't believe even (typeless) B or BCPL did.
> It usually works if sizeof(int)==sizeof(char*), which was
> true on many C compilers.
>
> For C, a pointer to a scalar will always work in place
> of an array dimensioned one. It never works in Java.
>
Of course in Java 'array' is actually its own object (in the OO sense)
type, not just an aggregate of the element type.
- David.Thompson1 at worldnet.att.net
|