Manu,
Thank you very much for replying. Of course, I have some additional
questions.
> > feature {NONE} -- Initialization
> > make_and_launch
> > -- Create `Current', build and display `main_window',
> > -- then launch the application.
> > do
> > default_create
> > create main_window
> > main_window.show
> > launch
> > end
> >
> > 'main_window' is an attribute of VISION2_APPLICATION:
> >
> > feature {NONE} -- Implementation
> >
> > main_window: MAIN_WINDOW
>
> As pointed out a few month ago in the mailing list the version of
EiffelBuild
> included in EiffelStudio 6.4 does not generate void-safe code. The 6.5
version
> will.
OK, thank you. Sorry I missed this notice. I'll try to pay better
attention!
>
> The reason why we flag the above code as an error is that at the end
of
> `default_create' (defined in the parent classe), we use `Current'
Since I've obviously missed one announcement, can you clear up for me
what the current status of default_create for attached-type entities is?
The ECMA document (section 7.13, fourth bullet point) indicates that
attached type entities can be attached by default, via default_create.
But 'void-safe-eiffel' doesn't mention 'default_create'. Is the 'create'
directive now required for instantiating attached-type entities (IOW,
there is no default creation for attached-type entities)?
> as a consequence
> this is an error to use Current if not all attached attributes are not
yet set. In
> the void-safe version of EiffelVision2, we provide a new routine
> `create_interface_objects' that you have to redefine if inheriting
from an
> EiffelVision class to create your attached attributes before `Current'
is being
> used.
I don't understand why the use of Current in the default_create of
MAIN_WINDOW, inherited from EV_ANY, matters at the line the compiler
flags: 'main_window.show'. All creation procedure instructions are
complete at that point, so 'main_window' should be fully instantiated.
It's an even simpler case than the first example on page 7 of
'void-safe-eiffel' (labeled 'r'), because there are no intervening
instructions. How could 'main_window.show' not be a void safe call at
this point? Or is the compiler really trying to alert me to the previous
line, 'create main_window', which shouldn't be performed in
'make_and_launch', but instead in 'create_interface_objects'? That would
also be surprising, because 'make_and_launch' is just doing what all
creation procedures should do, instantiate attached attributes.
>
> A possible alternative is to mark `main_window' detachable but stable.
The stable
> notion not yet standardized by ECMA but you can use it in a
non-breaking syntax
> manner via the `note' clause:
>
> main_window: detachable MAIN_WINDOW note option: stable attribute end
Peter Horan also suggested making 'main_window' detachable. I appreciate
the suggestion, and I'm certain it would work, but to me it comes across
as a work-around. 'main_window' has to be attached--it wouldn't be much
of a GUI application if the 'main_window' were Void!
So as not to be completely pig-headed, I commented out 'main_window' as
a class attribute, and made it a local entity of 'make_and_launch',
still attached. This time the compiler was happy, no error. But I'd
really appreciate knowing why it's ever an error to instantiate an
attribute, like 'main_window', in a creation procedure.
>
> Now the code above will compile just fine. The stable qualifier
basically says
> that even though it is a detachable attribute, once set it cannot be
unset.
>
> Hope this helps,
> Manu
>