Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: e2e49d6c02927cc3a74bb687198f2eb6bf64090d
Ticket: 1913876fffffffffffffffffffffffffffffffff
Get weird error during [chan seek], using [chan create]
User & Date: andreas_kupries on 2008-03-15 00:19:43
Changes

  1. icomment:
    Logged In: YES 
    user_id=75003
    Originator: NO
    
    Ok. Your 'write' command is still not returning the number of bytes written, but incorrectly an empty string.
    This causes an error to be stashed into the tip 219 areas, when 'write' is invoked.
    
    Why is this returned for seek, but not for puts?
    
    In your example the 'puts' is not invoking the 'write' procedure. 'write' is invoked when the channel is flushed, and your [puts] doesn't cause that. Tcl's IO system buffers things up, default is to flush when a buffer is full, or, on interactive stuff, when a full line is written.
    
    However, for [seek] to work properly it the I/O core has to flush outstanding writes, so it does.
    At that point the 'write' is invoked, causes the error, which is then returned by [seek].
    If you don't do the seek the flush happens on [close], and [close] returns the error.
    
    What you are seeing now is how Tcl I/O core can defer stuff until it is has to be done.
    It allows for errors to appear in places which seem to be odd at first glance.
    I.e. with reflected channel you can get a very deep peek into the internals of Tcl's IO system.
    
    
    
  2. login: "andreas_kupries"
  3. mimetype: "text/plain"
  4. username: "andreas_kupries"