Re: passing parameter by reference?
- From: claird@xxxxxxxxx (Cameron Laird)
- Date: Tue, 29 Nov 2005 02:08:02 GMT
In article <1133224036.299815.300780@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
slebetman@xxxxxxxxx <slebetman@xxxxxxxxx> wrote:
.
.
.
>Actually, yes to a point. Fileevents may not return a complete packet
>and another fileevent on a different socket may trigger. So your
>concerns are valid.
>
>As previous posters have replied, you can use upvar to sort of pass by
>reference.
>
>Personally, for my own web server, I used a global array variable. Just
>use the socket name for the index to the array. For example, you can
>have a global $timeout($channel) to keep track of timeouts and
>$buffer($channel) to buffer incoming data etc.. This way you don't have
>to worry about the second fileevent clobbering your global since each
>fileevent has its own place in the global array.
>
I regard "Fileevents may not return a complete packet and
another fileevent on a different socket may trigger" as
at least doubly confusing:
A. Fileevents are guaranteed to return
a complete packet, in a weak sense
(if the channel is line-delimited,
for example, any fileevent will end
in a newline, 'cept for eof ...);
B. Stock Tcl is singly-threaded, so
a fileevent can trigger only when
the programmer has given control to
the event loop.
I'm fairly sure you know these things, but I suspect naive
readers might misinterpret your description.
I entirely agree that a lot of us index interesting associative
arrays with $channel.
.
- References:
- passing parameter by reference?
- From: Lisa Pearlson
- Re: passing parameter by reference?
- From: Gerald W. Lester
- Re: passing parameter by reference?
- From: Lisa Pearlson
- Re: passing parameter by reference?
- From: slebetman@xxxxxxxxx
- passing parameter by reference?
- Prev by Date: Getting system uptime on Windows
- Next by Date: Re: Combo box command and default value
- Previous by thread: Re: passing parameter by reference?
- Next by thread: Re: passing parameter by reference?
- Index(es):
Relevant Pages
|