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

NICE Language Committee: ms-once-type

From Michael Schweitzer
Date: Sat, 16 Apr 94 15:09:11 +0200
To: bertrand@eiffel.com
Subject: MS-ONCE-TYPE
Cc: tynor@atlanta.twr.com
Content-Length: 1524
X-Lines: 57
Status: RO

-----------------------------------------------------------
Key   : MS-ONCE-TYPE
Title : Types allowed for once functions.
-----------------------------------------------------------

Discussion:

It is not allowed that the type of a once function is a
formal generic. The reason is obvious (as explained in ETL);
example:

        class C [G]

            r : G is once ... end

        end -- class C

        e1 : C [STRING]
        e2 : C [INTEGER]

        ...

        e1.r        -- Returns a STRING
        e2.r        -- Also returns a STRING but is expected
                    -- to return an INTEGER.

I think that the same problem occurs if the type of a
once function _involves_ any formal generic parameters, as in

        r : LIST [G]

Here the first call (and therefore all subsequent calls)
may return a LIST [STRING], regardless of the actual generic
types in the second, third, etc. call.

Furthermore, if the type of a once function is 'like anchor'
or uses an anchored type (i.e ARRAY [like anchor]) the same
problem occurs, since the result type is determined by the
first call.

Conclusion:

Variation of type (through genericity or anchoring) makes
no sense for the result of a once function since, by de-
finition, the type is determined once and for all by the
first call.

Proposal:

I therefore propose that the type of a once function may
not contain any formal generic parameters or anchored
types.
-----------------------------------------------------------

Best regards,
    Michael