Re: Confusing Cursor Positions

Eric Bezault <ericb-D6Qt/9opevxWk0Htik3J/[email protected]>
Newsgroups gmane.comp.lang.eiffel.gobo.general
Organization Gobo
Message-ID <[email protected]>
Brian Heilig wrote:
> 
> The wording of some of the cursor positions is a little confusing to 
> me. Can someone clarify please? Here is `cursor_after' and 
> `cursor_before'
> 
> cursor_after (a_cursor: like new_cursor): BOOLEAN is
>     -- Is there no valid position to right of `a_cursor'?
> 
> This implies to me that if the condition is true, then `a_cursor' 
> might be at the last position. If the cursor is at the last position 
> then it is at a valid position, but there is no valid position to the 
> right.
> 
> cursor_before (a_cursor: like new_cursor): BOOLEAN is
>     -- Is there no valid position to left of `a_cursor'?
> 
> Likewise this implies to me that `a_cursor' might be at the first 
> valid position. However `cursor_off' is defined in DS_BILINEAR as
> 
> cursor_off (a_cursor: like new_cursor): BOOLEAN is
>     -- Is there no item at `a_cursor' position?
>   do
>     Result := cursor_after (a_cursor) or cursor_before (a_cursor)
>   end
> 
> which shows that if `a_cursor' is after or before, then it can not be 
> at a valid position. This seems confusing to me and it is not clear 
> from the contract.

The terminology used in Gobo is explained in the book
"Reusable Software" from Bertrand Meyer I think (I cannot
check in my copy because I'm currently abroad). Valid
positions for the cursor are positions where the cursor
can be. And the cursor can be before the first item and
after the last item. Therefore these are valid positions.
But as soon as the cursor is after the last item, you
cannot move it any further right. The cursor is off if
it is not on an item (therefore it is either before the
first item or after the last item). But the cursor is
nevertheless in a valid position. Note that according
to the various assertions a cursor can never be moved
to an invalid position.

> In my opinion a better comment for cursor_after 
> and cursor_before would be ...
> 
> cursor_after (a_cursor: like new_cursor): BOOLEAN is
>     -- Is `a_cursor' after all valid items?
> 
> cursor_before (a_cursor: like new_cursor): BOOLEAN is
>     -- Is `a_cursor' before all valid items?
> 
> ... or something like that.

What does it mean for an item to be invalid?

-- 
Eric Bezault
mailto:ericb-D6Qt/9opevxWk0Htik3J/[email protected]
http://www.gobosoft.com



To Post a message, send it to:   [email protected]
To Unsubscribe, send a blank message to: [email protected] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/gobo-eiffel/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.