I had the same reaction to surprise #1: it is a new CAP. The compiler
seems to be saying that a local detachable variable, properly set at the
point of a call, makes the call void safe. (Does that mean we've
discovered a 2nd CAP? And does that make us famous?)
>What does the compiler say if you do 'item.call(Void)'?
The compiler is happy with that. Surprise #2 was my mistake, I know now
what I did wrong.
Surprise #3 shouldn't have been a surprise either, you're right. I guess
the only true surprise was the compiler allowing a call to a detachable
entity outside the one official CAP.
--- In
[hidden email], Peter Horan <peter.horan@...>
wrote:It's also happy with this little one-class application, compiled
(I'm pretty sure) with the same options (complete void safety, full
class checking, types attached by default):
>
> David Jenkins wrote:
> > Here is a snippet from a class I am trying to make void safe:
>
> > set_attributes_using_font_constants
> > -- Set all attributes relying on font constants to the
current
> > -- value of the associated constant.
> > local
> > f: detachable EV_FONT
> > t: detachable TUPLE
> > do
> > ...
> > loop
> > f := font_constant_retrieval_functions.i_th
> > (font_constant_set_procedures.index).last_result
> > create t.default_create
> > t.put (f, 1) -- surprise #1
> > font_constant_set_procedures.item.call (t) -- surprise #2
> > t := Void -- surprise #3
>
> f and t are local variables. No one can interfere with them.
>
> After creation, `t' is guaranteed to exist - no side effect can
interfere. It is a CAP, I think. So, no surprise at #1. And because `t'
is detachable, assignment of Void is allowed - no surprise at #3.
>
> As for surprise #2, my guess is that because the instruction is not
immediately after create, `t' could be Void. But, I am not sure about
this reasoning. What does the compiler say if you do 'item.call(Void)'?
> --
> Peter Horan Faculty of Science and Technology
> peter@... Deakin University
> +61-3-5221 1234 (Voice) Geelong, Victoria 3217, AUSTRALIA
> +61-4-0831 2116 (Mobile)
>
> -- The Eiffel guarantee: From specification to implementation
>