new validity rule integrated into 6.5 release candidate which invalidates correct code

4 messages Options
Embed this post
Permalink
helmut.brandl

new validity rule integrated into 6.5 release candidate which invalidates correct code

Reply Threaded More More options
Print post
Permalink
The release candidate of EiffelStudio requires that each source of a
conversion must be an attached type.

This rule is unnecessarily strong. It invalidates code which is not
invalid from a semantical point of view.

An example:


class
        REF [G]
create
        make
convert
        make ({G})   -- validation error reported here

feature {NONE} -- Initialization

        make (an_item: G)
                do
                        item := an_item
                ensure
                        item_set: item = an_item
                end

feature -- Access

        item: G

end


The usual validity rules for attached/detachable types shall be
sufficient. It should be perfectly valid to use REF as an encapsulation
for a void reference.

What is this new validity rule good for? Without the convert clause the
code is accepted. But the accepted code is semantically equivalent to
the not accepted code.

Regards
Helmut



Emmanuel Stapf

RE: new validity rule integrated into 6.5 release candidate which invalidates correct code

Reply Threaded More More options
Print post
Permalink
> This rule is unnecessarily strong. It invalidates code which is not
> invalid from a semantical point of view.

You can make it work by simply updating your convert clause to read:

convert
        make ({attached G})

.

This is because the working draft of the Eiffel specification requires that either
the SOURCE or the TARGET listed in the Type_list of the conversion clause has to
be attached.

Regards,
Manu

------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------  
helmut.brandl

Re: new validity rule integrated into 6.5 release candidate which invalidates correct code

Reply Threaded More More options
Print post
Permalink
Thanks for the answer. Unfortunately it doesn't answer my question. I
think I understand the "how" of the rule.

What I don't understand is the "why" of the rule. It makes Eiffel
unnecessarily restrictive. I cannot use the cited REF class to
encapsulate void references any more.

Usually there should be a good reason for a validity rule. Do you know
the reason for this rule?

Helmut



Emmanuel Stapf [ES] wrote:

>> This rule is unnecessarily strong. It invalidates code which is not
>> invalid from a semantical point of view.
>
> You can make it work by simply updating your convert clause to read:
>
> convert
> make ({attached G})
>
> .
>
> This is because the working draft of the Eiffel specification requires that either
> the SOURCE or the TARGET listed in the Type_list of the conversion clause has to
> be attached.
>
> Regards,
> Manu
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
Emmanuel Stapf

RE: new validity rule integrated into 6.5 release candidate which invalidates correct code

Reply Threaded More More options
Print post
Permalink
> What I don't understand is the "why" of the rule. It makes Eiffel
> unnecessarily restrictive. I cannot use the cited REF class to
> encapsulate void references any more.

Yes it can, see my previous email with a suggested modification.
 
> Usually there should be a good reason for a validity rule. Do you know
> the reason for this rule?

It doesn't make sense to have:

a: detachable STRING
ref: TEST [detachable STRING]

ref := a

without ensuring the source `a' is attached, but we also wanted to make sure the
target will also be guaranteed to be attached. For that reason we ensured that
TARGET in a `to' conversion should be attached. Also conversion applies if the
type of the source matches the type in the Type_list which is only the case if the
type is attached, thus the requirement on SOURCE as well.

Feel free to contact ECMA for more in depth discussion as you seem interested in
changing the specification. As a reminder, the purpose of this group is to discuss
the use of Eiffel Software products and libraries (see http://groups.eiffel.com).

Regards,
Manu

------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------