TIP 565: Gracefully ignore non-existent tags in canvas raise/lower

Login
Author:         Francois Vogel <[email protected]>
State:          Final
Type:           Project
Vote:           Done
Created:        10-Feb-2020
Post-History:   
Keywords:       Tk canvas
Tcl-Version:    8.7
Tcl-Branch:     bug-3552805fff

Abstract

This TIP proposes to let the .canvas raise and .canvas lower do nothing gracefully when receiving non-existing tagOrIds respectively as aboveThis and belowThis arguments.

Rationale

Ticket 3437816fff pointed out that .canvas raise $tagOrId1 $tagOrId2 and .canvas lower $tagOrId1 $tagOrId2 were not symmetrical in their error cases management: the former returned an error when $tagOrId2 does not exist, but the latter did not. This was fixed in 2011 by making the latter return the same error as the former.

This change broke some software in the wild, see for instance this Debian ticket or that Tk ticket.

In the wake of the "Do nothing gracefully" reform, aka TIP #323, the present TIP proposes to remove the error when calling .canvas raise/lower with a non-existent "aboveThis"/"belowThis" tag.

Note that the current behavior is inconsistent anyway:

    package require Tk
    .c create line 0 0 10 10 -tags aline
    # inconsistent error spitting
    .c lower aline noline   ; # error: tagOrId "noline" doesn't match any items
    .c lower bline aline    ; # no error
    # ditto for raise instead of lower:
    .c raise aline noline   ; # error: tagOrId "noline" doesn't match any items
    .c raise bline aline    ; # no error

With the present TIP implemented, no error would be raised for any of the four above lines.

Implementation

See the bug-3552805fff branch, aka tip-565.

This branch targets 8.7.

Copyright

This document has been placed in the public domain.