Tk Library Source Code

View Ticket
Login
Ticket UUID: 1229352
Title: add unget to queues
Type: RFE Version: None
Submitter: dvrsn Created on: 2005-06-28 22:18:40
Subsystem: struct Assigned To: andreas_kupries
Priority: 8 Severity:
Status: Closed Last Modified: 2005-10-01 06:48:50
Resolution: Closed By: andreas_kupries
    Closed on: 2005-09-30 23:48:50
Description:
It would be useful to have an 'unget' operation
available for queues, having the functionality of
inserting items at the head of the queue.  The main
purpose for this would be exception handling:


while {[$q length] > 0} {
    if {[catch {
        set i [$q get] 
        process-item $i
    }]} {
        $q unget $i
    }
}

The same functionality can easily be achieved using
peek initially and then using get to discarding the
item in success cases, but to me handling it as an
exceptional case reads cleaner.
User Comments: andreas_kupries added on 2005-10-01 06:48:49:
Logged In: YES 
user_id=75003

Accepted.