procedure variables vs. type-bound procedures 
Author Message
 procedure variables vs. type-bound procedures

//
//

Yes and no, I think.  Functionally speaking, a statically
bound method is just a dynamically bound method calling an
unbound procedure.  

But suppose a library writer has put a particular operation
into a type-bound procedure Amanda.  You redefine another TBP
that Amanda calls, but you want to be able to call the *old*
version of Amanda.  

If the library writer has not had the foresight to put this
operation into a regular procedure, then you have to play
games to get the old Amanda.  For example:

TYPE
    Parent = RECORD END;
    Child = RECORD (Parent) END;

PROCEDURE (VAR par : Parent) Amanda;
BEGIN
    (* whatever *)
END Amanda;

PROCEDURE OldAmanda (VAR par : Parent);
BEGIN
    par.Amanda
END OldAmanda;

PROCEDURE (VAR ch: Child) Amanda;
BEGIN
    OldAmanda(ch)
END Amanda;

Unless there is something I'm still missing, this can have a
negative impact on efficiency.  It would be nice to be able to
declare a method to be statically or dynamically bound when
you inherit it.  

The library writer could conceivably avoid this whole mess in
Oberon-2 with some extra work (writing alot of extra unbound
procedures).  Maybe this is really human engineering problem
rather than a language design problem.

M



Sat, 18 Jan 1997 17:02:17 GMT  
 procedure variables vs. type-bound procedures


much deleted

Quote:

>PROCEDURE (VAR ch: Child) Amanda;
>BEGIN
>    OldAmanda(ch)
>END Amanda;

>Unless there is something I'm still missing, this can have a
>negative impact on efficiency.  It would be nice to be able to
>declare a method to be statically or dynamically bound when
>you inherit it.  

Huh?  Why not:

PROCEDURE (VAR ch : Child) Amanda;
BEGIN ch.Amanda^;
END Amanda;

Why go through all the other work?

Quote:
>The library writer could conceivably avoid this whole mess in
>Oberon-2 with some extra work (writing alot of extra unbound
>procedures).  Maybe this is really human engineering problem
>rather than a language design problem.

Huh?

Taylor Hutt, Confused & Dazed
Besides yogurt, what other live things do we humans eat?



Sat, 18 Jan 1997 19:33:13 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Explicit interface of a type-bound procedure bounded to an instance (F2003)

2. type-bound procedures and type extension

3. procedure variables vs. type-bound procedures?

4. Access types vs. Record types as procedure parameters

5. Passing module procedures to external procedures -- type issues

6. Calling a procedure with a variable procedure name

7. Procedure types and dynamic binding

8. questions about type-bound procedures

9. Passing type-bound procedures as arguments?

10. Procedure Types & Variables

11. Type-Extension and Procedure Variables

12. A Type checking/reconstruction procedure for Typed-Prolog

 

 
Powered by phpBB® Forum Software