Re: The best way to copy a list?

Liste des GroupesRevenir à cl tcl 
Sujet : Re: The best way to copy a list?
De : et99 (at) *nospam* rocketship1.me (et99)
Groupes : comp.lang.tcl
Date : 19. Jun 2025, 02:40:29
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <102vpqe$3g259$1@dont-email.me>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird
On 6/18/2025 5:19 AM, Colin Macleod wrote:
Mark Summerfield <m.n.summerfield@gmail.com> posted:
>
I'm coming to Tcl from Python & Go. In Python saying `a = [1, 2, 3]` and
then `b = a` makes `b` a _reference_ to `a` rather than an independent
variable. Now I realise that Tcl doesn't do it that way and that `set a
$b` works fine.
 When I had to do some Python for work, after being familiar with Tcl,
I was quite shocked to find that Python shares values in that way! 😲
 
Me too!
This python feature goes against my favorite rule of language design:
"The principle of least astonishment"
I'd have to say that python gets a low score on that one!
especially how with a=b, you don't even know the type (and thus immutability) of b without looking elsewhere, which can lead to some nasty runtime surprises.

Date Sujet#  Auteur
18 Jun 25 * The best way to copy a list?8Mark Summerfield
18 Jun 25 +- Re: The best way to copy a list?1Harald Oehlmann
18 Jun 25 `* Re: The best way to copy a list?6Ashok
18 Jun 25  `* Re: The best way to copy a list?5Mark Summerfield
18 Jun 25   +- Re: The best way to copy a list?1Harald Oehlmann
18 Jun 25   +* Re: The best way to copy a list?2Colin Macleod
19 Jun 25   i`- Re: The best way to copy a list?1et99
18 Jun 25   `- Re: The best way to copy a list?1Christian Gollwitzer

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal