actual-formal parameter conflict 
Author Message
 actual-formal parameter conflict

hello,
from this year i'm new to oberon
probably rediculous quastion :
i have, in one module, a procedure like this :
PROCEDURE GetName*(p : <recordtype>; VAR Name : ARRAY 50 OF CHAR)

and in another i use this procedure :

VAR tempname : ARRAY 50 OF CHAR;
...
<ModuleName>.GetName(p, tempname);

I get error 123 : type of actual parameter is not identical with that of
formal parameter.

I can't figure out why not.



Mon, 24 Feb 2003 22:52:42 GMT  
 actual-formal parameter conflict
You can define a type with

TYPE MyArray=ARRAY 50 OF CHAR;

and replace all occurences of "ARRAY 50 OF CHAR"
with "MyArray", then the types are compatible.

Or you can replace "VAR Name : ARRAY 50 OF CHAR"
in your procedure header with "VAR Name : ARRAY OF CHAR".

Hope this helps

Stefan Salewski

Quote:

> hello,
> from this year i'm new to oberon
> probably rediculous quastion :
> i have, in one module, a procedure like this :
> PROCEDURE GetName*(p : <recordtype>; VAR Name : ARRAY 50 OF CHAR)

> and in another i use this procedure :

> VAR tempname : ARRAY 50 OF CHAR;
> ...
> <ModuleName>.GetName(p, tempname);

> I get error 123 : type of actual parameter is not identical with that of
> formal parameter.

> I can't figure out why not.



Tue, 25 Feb 2003 00:14:20 GMT  
 actual-formal parameter conflict


Quote:
> You can define a type with

> TYPE MyArray=ARRAY 50 OF CHAR;

> and replace all occurences of "ARRAY 50 OF CHAR"
> with "MyArray", then the types are compatible.

The reason this works is because Oberon defines name equivalence of types.
That is, two types must have the same name, not just the same structure to
be considered the same.  "Anonymous types" like ARRAY 50 OF CHAR, declared
in a parameter list are, in effect, each given a unique name by the compiler
as it finds them.  Therefore, no two will ever have the same name.

Quote:
> Or you can replace "VAR Name : ARRAY 50 OF CHAR"
> in your procedure header with "VAR Name : ARRAY OF CHAR".

The reason this works is because Oberon supports "open array parameters",
which means that such a parameter, given as an array with no specified
length will accept an array of any length of the given type.  Within the
procedure, you can use the built-in function LEN, to learn the length of the
actual array passed into the function.

Quote:
> Hope this helps

> Stefan Salewski


>> hello,
>> from this year i'm new to oberon
>> probably rediculous quastion :
>> i have, in one module, a procedure like this :
>> PROCEDURE GetName*(p : <recordtype>; VAR Name : ARRAY 50 OF CHAR)

>> and in another i use this procedure :

>> VAR tempname : ARRAY 50 OF CHAR;
>> ...
>> <ModuleName>.GetName(p, tempname);

>> I get error 123 : type of actual parameter is not identical with that of
>> formal parameter.

>> I can't figure out why not.

--
B. Smith-Mannschott    ::    http://n.ethz.ch/student/smithmab/


Tue, 25 Feb 2003 05:48:35 GMT  
 actual-formal parameter conflict

Quote:

> hello,
> from this year i'm new to oberon
> probably rediculous quastion :
> i have, in one module, a procedure like this :
> PROCEDURE GetName*(p : <recordtype>; VAR Name : ARRAY 50 OF CHAR)

> and in another i use this procedure :

> VAR tempname : ARRAY 50 OF CHAR;
> ...
> <ModuleName>.GetName(p, tempname);

> I get error 123 : type of actual parameter is not identical with that of
> formal parameter.

> I can't figure out why not.

This problem is explained in Language FAQ,
http://www.oberon.ethz.ch/faqlang.html
entry number 4. The same arguments apply to arrays.

-Patrik

--

http://www.inf.ethz.ch/personal/reali/
http://www.oberon.ethz.ch/native/

/"\ ASCII-Ribbon Campaign
\ / """"""""""""""""""""
 x  No HTML or WORD in Mails
/ \ HTML is for WEB, Word is for Micro$oft.



Tue, 25 Feb 2003 15:27:10 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Re (2): actual-formal parameter conflict

2. Question about matching actual/formal parameters

3. Modelsim and actual/formal assignments

4. Generic Formal With Discrim Used As Actual - How?

5. Formal vs actual signals in port map statement

6. Changing actual arg via intent(in) formal arg in F90

7. Actual parameter

8. converted types as actual in out parameters

9. Function that knows the names of its actual parameters

10. More on expressions as actual parameters

11. How to get number of actual parameters in subroutine

12. Unrolling of actual parameters from list

 

 
Powered by phpBB® Forum Software