Redefined procedure call 
Author Message
 Redefined procedure call

In section 10.2 (Type-bound procedures) of the oberon-2 language report
the passage "If r is a receiver parameter declared with type T, r.P^
denotes the (redefined) procedure P bound to the base type of T." leads me
to a few questions for common discussion.

1) Is r.P^ the only legal notation for the call of the procedure P bound
   to the base type of r (in the following named 'super call ')?

I would say no, because r (as a receiver) can be of a pointer type, so
that r^.P^ should also be legal (knowing that r^.x can be abbreviated by
r.x). This raises the (not too serious) question:

2) Are 'complex' designators (e.g. r.a.b[e].P^) legal for a super call?

I tend to say no. If one says yes to 2), then the restriction of r to be a
receiver parameter would be too strong and super calls for any (record
typed) variables/parameters should be legal.

3) What are the main reasons for this restriction and why not cut this?

Another point in this issue is the sentence "Within a redefining
procedure the redefined procedure can be invoked by calling it with the
suffix ^ ..." found in Differences between Oberon and Oberon-2, which
seems a bit more restrictive than the relevant statements in the language
report:

4) If the only legal super call is a call of the redefined procedure
   within the redefining procedure, why it doesn't stand in this clarity
   in the language report?

Any opinions?

Max Spring



Mon, 18 Mar 1996 17:08:03 GMT  
 Redefined procedure call

Quote:

>1) Is r.P^ the only legal notation for the call of the procedure P bound
>   to the base type of r (in the following named 'super call ')?

>I would say no, because r (as a receiver) can be of a pointer type, so
>that r^.P^ should also be legal (knowing that r^.x can be abbreviated by
>r.x). This raises the (not too serious) question:

This cannot be correct, as can be seen if you look at the semantics of the
call. If you have definitions as follows,

TYPE    P0 = POINTER TO T0  ;
        T0 = RECORD ... END ;

PROCEDURE (p:P0) Proc (params) ;
BEGIN ... END Proc;

TYPE    P1 = POINTER TO T1 ;
        T1 = RECORD (T0) ... END ;

PROCEDURE (p1 : P1) Proc (params) ;
BEGIN ....  
      p1^.Proc^(params)
END Proc ;

The super-call clearly isn't legal, because it is a call to a procedure
bound to the base type of the dereference of p1, which is of type T0,
not P0;

Quote:

>2) Are 'complex' designators (e.g. r.a.b[e].P^) legal for a super call?

Only if the last element of the designator list (in your case b[e]) is of
the same type as the receiver of the procedure it is called from.

Quote:
>Another point in this issue is the sentence "Within a redefining
>procedure the redefined procedure can be invoked by calling it with the
>suffix ^ ..." found in Differences between Oberon and Oberon-2, which
>seems a bit more restrictive than the relevant statements in the language
>report:

I tend to agree. I feel that a super-call should not be restricted from
within the specific re-defining procedure.
It would be nice to relax the rules to state that the form obj.Proc^ calls
the version of Proc^ bound to the super-type of obj in all cases - provided
such a call is only made within the module in which the extended type is
defined.

It has to be said, however, that I haven't run across a time when I
actually needed this to be the case.

--
-------------------------------------------------------------------------
Ian Marshall,
Real Time Associates Ltd,          Tel        : (+44)(0)81 656 7333/4/5
Canning House, 59 Canning Road,    Fax        : (+44)(0)81 655 0401

UK                                 Compuserve : 71333,2456      
-------------------------------------------------------------------------



Tue, 19 Mar 1996 01:18:51 GMT  
 Redefined procedure call

:>1) Is r.P^ the only legal notation for the call of the procedure P bound
:>   to the base type of r (in the following named 'super call ')?
:>
:>I would say no, because r (as a receiver) can be of a pointer type, so
:>that r^.P^ should also be legal (knowing that r^.x can be abbreviated by
:>r.x). This raises the (not too serious) question:
:This cannot be correct, as can be seen if you look at the semantics of the
:call. If you have definitions as follows,
:TYPE    P0 = POINTER TO T0  ;
:        T0 = RECORD ... END ;
:PROCEDURE (p:P0) Proc (params) ;
:BEGIN ... END Proc;
:TYPE    P1 = POINTER TO T1 ;
:        T1 = RECORD (T0) ... END ;
:PROCEDURE (p1 : P1) Proc (params) ;
:BEGIN ....
:      p1^.Proc^(params)
:END Proc ;
:The super-call clearly isn't legal, because it is a call to a procedure
:bound to the base type of the dereference of p1, which is of type T0,
:not P0;

I'm afraid this is not correct!
Procecures are never bound to pointer types: The Oberon-2 Language Report
states in 10.2 Type-bound procedures: "Globally declared procedures may be
associated with a _record_ type declared in the same module. The
procedures are said to be bound to the _record_ type. ... The receiver may
be ... a value parameter of type POINTER TO T (where T is a _record_
type). The procedure is bound to the type _T_ ..."
And so the super-call IS legal.

:>
:>2) Are 'complex' designators (e.g. r.a.b[e].P^) legal for a super call?
:
:Only if the last element of the designator list (in your case b[e]) is of
:the same type as the receiver of the procedure it is called from.

From what passages of the language report do you infer that?

Max Spring.



Tue, 19 Mar 1996 19:07:16 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to call redefined procedures ?

2. How to redefine a procedure (extend it) and have nobody notice

3. How to setup a procedure in a DLL that calls a procedure in another DLL

4. Call a procedure from a procedure

5. Calling a procedure with a variable procedure name

6. Procedure that only calls a procedure?

7. calling non-PURE procedures in PURE procedures

8. How to make a procedure call from another procedure

9. Class procedure cannot call another class procedure

10. Postcondition violated on Precursor call to redefined routine

11. recursive command calls / procedure calls

12. Calling Oracle Stored procedures from VA smalltalk

 

 
Powered by phpBB® Forum Software