Re: Bug in spinbox
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: Bug in spinbox

From: bgd <bgd73@verizon.net>
Date: Sun Feb 26 2006 - 14:56:50 CET

"Adrian Ho" <tcl@03s.net> wrote in message
news:an78d3-2n9.ln1@rover.03s.net...
> On 2006-02-26, bgd <bgd73@verizon.net> wrote:
>> "Ulrich Schöbel" <ulrich@outvert.com> wrote in message
>> news:pan.2006.02.25.21.33.49.509055@outvert.com...
>>
>> Should it be
>> foreach x {e B Y} y {day mon year} {
>> set [set y] [clock format [clock seconds] -format %$x]
>> }
>
> No. Your code can return incorrect results if run during, say, 31 Dec
> 2006 23:59:59. Depending on when your Tcl instance processes each of
> the three [clock seconds] commands, it could return any of the following:
>
> day=31 mon=December year=2006
> day=31 mon=December year=2007
> day=31 mon=January year=2007
> day=1 mon=January year=2007
>
> Only the first and last are (obviously) acceptable, and Ulrich's code
> will *always* return either of the two.
>
> More importantly, Ulrich's code is *obviously correct*. Anyone with
> basic Tcl experience can see that it takes a single timestamp, formats
> it into a list-compatible string, and uses [foreach] to assign the
> string-list's elements into the appropriate variables.
>
> The logic in your code, however, is so obfuscated that I:
>
> * spent at least a minute inspecting it to determine that the logic
> was at least similar to Ulrich's,
>
> * actually felt the need to run your code in a tclsh to assure myself
> that my reasoning was correct, and
>
> * only realized 5 minutes later that there's at least twelve corner
> cases each year (ie. the last second of every month) for which your
> code can return incorrect results
>
> As a demonstration of just how flexible Tcl is, I applaud your attempt,
> but frankly, if any of my co-workers tried to put something like that
> in their code, I'd kick their posteriors with a steel-toed boot. IMO,
> there's no place for that sort of contortion in a production environment.
>
> - Adrian
Aren't you friendly. Take it to Mr.Ousterhout...
Do you know who that is ?
RTFM
>>>> foreach {day mon year} [clock format [clock seconds] -format "%e %B
>>>> %Y"]
The above code is so obviously incorrect it jumped at me. 3 variables same
value. I say no more.
As far as time changing a second after you get it...... In the name of God
Allmighty...... Time does in fact keep moving along.
If you'd like to box it out to relieve a bit of pressure unrelated, I'll let
you throw first.
Have A nice Day, and clean your damn bifocals.
Received on Sun Apr 30 02:16:01 2006