Re: The "leading zero means octal" thing...

Liste des GroupesRevenir à cl tcl 
Sujet : Re: The "leading zero means octal" thing...
De : rich (at) *nospam* example.invalid (Rich)
Groupes : comp.lang.tcl
Date : 06. Jan 2025, 04:03:06
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vlfh5a$1ande$1@dont-email.me>
References : 1 2 3 4
User-Agent : tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Luc <luc@sep.invalid> wrote:
On Sun, 5 Jan 2025 21:04:46 -0000 (UTC), Rich wrote:
 
Luc <luc@sep.invalid> wrote:
I updated my 'seq' code because of this thread:
 
https://wiki.tcl-lang.org/page/seq 
>
And, line one of the proc contains the common Tcl bug of "applying a
string operator" to a tcl list.
 
**************************
 
While I admit that I never took the list to string conversion into
consideration (I am repeat offender at that), you explore certain
possibilities in your exposition that I did take into consideration,
and I decided that those don't matter.
 
Anyone who has ever used seq (or just merely understands it in spite
of never having used it) knows what the input is supposed to be: two
or three integers.
 
I improved on it by adding the ability to produce alphabetic sequences.
 
About your examples, being atypically blunt, no programmer is stupid
enough to input 08 and 08. Even I wouldn't that. Likewise, no programmer
will be stupid enough to input #08. And if anyone actually does that,
they will get the empty string. The code intentionally refuses to
produce output when the input is incorrect.

And, of course, you miss the forest due to focusing on the trees.

For this trivial example, the list to string conversion is not a "big
deal".  The greater point, and the one you should have taken from this,
is that applying string operators willy-nilly to things that are
documented as lists (or that contain lists) creates subtle, data
dependent, bugs that can lie in wait for a very long time before "just
the right data pattern" arrives that triggers the bug.  This often
occurs weeks or months (or longer) after one initially wrote the code,
and it has been working perfectly since then, and then mysteriously, it
fails.  Those bugs can be very troublesome to track down.

By being careful up front with "string operators" for "strings" and
"list operators" for "lists" you can avoid an entire class of subtle,
surprise, bugs that are hard to track down (even more so after you've
long forgotten why you wrote what you wrote).


Date Sujet#  Auteur
4 Jan 25 * The "leading zero means octal" thing...23Kenny McCormack
4 Jan 25 +* Re: The "leading zero means octal" thing...2Janis Papanagnou
5 Jan 25 i`- Re: The "leading zero means octal" thing...1Kenny McCormack
5 Jan 25 +* Re: The "leading zero means octal" thing...2Rich
5 Jan 25 i`- Re: The "leading zero means octal" thing...1Kenny McCormack
5 Jan 25 +* Re: The "leading zero means octal" thing...5Eli the Bearded
5 Jan 25 i`* Re: The "leading zero means octal" thing...4Kenny McCormack
5 Jan 25 i `* Re: The "leading zero means octal" thing...3Kenny McCormack
5 Jan 25 i  +- 'nf' in VIM (Was: The "leading zero means octal" thing...)1Kenny McCormack
5 Jan 25 i  `- Re: The "leading zero means octal" thing...1Janis Papanagnou
5 Jan 25 +- Re: The "leading zero means octal" thing...1Joe Makowiec
5 Jan 25 +* Re: The "leading zero means octal" thing...7Luc
5 Jan 25 i`* Re: The "leading zero means octal" thing...6Rich
6 Jan 25 i `* Re: The "leading zero means octal" thing...5Luc
6 Jan 25 i  +- Re: The "leading zero means octal" thing...1Rich
6 Jan 25 i  `* Re: The "leading zero means octal" thing...3Rich
6 Jan 25 i   `* Re: The "leading zero means octal" thing...2Luc
6 Jan 25 i    `- Re: The "leading zero means octal" thing...1Rich
5 Jan 25 +* Re: The "leading zero means octal" thing...4saito
5 Jan 25 i`* Re: The "leading zero means octal" thing...3Kenny McCormack
6 Jan 25 i `* Re: The "leading zero means octal" thing...2Rich
6 Jan 25 i  `- Re: The "leading zero means octal" thing...1Kenny McCormack
6 Jan 25 `- Re: The "leading zero means octal" thing...1Eric Pozharski

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal