IN open array parameters

From: [at]} <ftkachov{>
Date: Mon, 20 Nov 2000 12:38:48 +0300 (MSK)

Hi!

I think there's a glitch with formal/actual parameters rules in Component Pascal.
The glitch is minor but
since it causes some overhead in a computationally intensive problem,
I'd like to point it out.

I think the glitch in the language definition is that
IN, OUT and VAR parameters are all treated as variable parameters.

But if IN parameters are not allowed to be modified inside the procedure,
I see no point in treating them as variable.
Semantically, IN parameters seem to be intended to optimize value parameters, so
it seems more appropriate to group IN parameters with value parameters in regard of
compatibility rules for formal/actual parameters.

------------------
The problem was encountered in the following setting:

Suppose we have a procedure with an IN open array parameter,
with elements of an abstract type T.

I need to call the procedure several times,
in each call the elements of the actual array parameter may be different extensions of T.

I cannot directly substitute those arrays in place of the formal parameter because
the parameters must be "array compatible". So I must either define my actual arrays
to have elements of the abstract type T (which requires pesky
type tests in other parts of the algorithm),
or define a special ARRAY OF T, explicitly copy my arrays into it, and use it as
the actual parameter.
(Then I have to pay attention to the length of T as my arrays may vary in length.)

If I drop IN, the parameter becomes value,
and then I just substitute the actual arrays in place of the formal parameter
and everything works -- except that the array is copied, whence an overhead.

One way or another, there is an overhead without any benefit.
--------------------------------------------------------------

May be I am missing something?


Best,
Fyodor Tkachov
---------------------------
Russian Academy of Sciences

P.S.
Component Pascal is still by far the best tool for my applications
(heavy mathematics in nature, symbol manipulation in type,
supercomputer in scale).

Cheers,
FT
--------------------------------------------

To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
   blackbox-request{([at]})nowhere.xy

To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.

Send any problem reports or questions related to this email list to the list owner at
   owner-blackbox{([at]})nowhere.xy
Received on Mon Nov 20 2000 - 09:38:48 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:27:45 UTC