This site contains older material on Eiffel. For the main Eiffel page, see http://www.eiffel.com.

NICE Language Committee: ms-anch-call

From Michael Schweitzer
Date: Sat, 16 Apr 94 15:08:37 +0200
To: bertrand@eiffel.com
Subject: MS-ANCH-CALL
Cc: tynor@atlanta.twr.com
Content-Length: 2113
X-Lines: 63
Status: RO

-----------------------------------------------------------
Key   : MS-ANCH-CALL
Title : Feature calls and anchored types
-----------------------------------------------------------

I have two questions about feature calls and anchored types:

Question 1:

Suppose a routine 'r' has the following declaration

        r (arg1 : ANY; arg2 : like arg1) is ...

Suppose further that we have a call

        r (a, 1)

where 'a' is of type ANY. This is legal, since the
first actual argument is of type ANY and therefore
conforms to the type of the first formal argument and the
second actual argument has type INTEGER which con-
forms to the type of the first actual argument (ANY).
But the type of the second formal argument is anchored and
thus the routine 'r' expects that the second actual
argument is of reference type.

Therefore our implementation first converts the integer
into an INTEGER_REF and then passes a reference to this
object as second argument. Is this correct?

Question 2:

Suppose a function 'f' has the following declaration

        f (arg : ANY) : like arg is ...

Suppose further that we have a call

        f (1)

Here the same mechanism is applied: the integer '1' is
first converted into an INTEGER_REF and then a reference
to that object is passed as actual argument. But our
implementation assumes now, that the type of the result
will be an INTEGER_REF or a _reference_ type conforming
to INTEGER_REF. It is not prepared to get an INTEGER
as result. Again, the result type is anchored and should
therefore be a reference type. Is this correct?

I hope that the answer to both questions is 'YES', because
anchored types are always reference types and an attachment
of a basic type to a reference type should always convert
the basic type to it's _REF-version first.

If you think that my interpretation is correct, Bertrand may
perhaps consider including an example or comment in ETL which ex-
plains this special case, since for the 'everyday' Eiffel
programmer it might not be that obvious.
-----------------------------------------------------------

Best regards,
    Michael