Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"The Computer made me do it."


devel / comp.lang.tcl / looking for [dict equal]

SubjectAuthor
* looking for [dict equal]Petro Kazmirchuk
+- looking for [dict equal]Schelte
+- looking for [dict equal]saitology9
+* looking for [dict equal]Luc
|`* looking for [dict equal]Rich
| +* looking for [dict equal]Petro Kazmirchuk
| |`- looking for [dict equal]Rich
| `* looking for [dict equal]Ralf Fassel
|  `* looking for [dict equal]Luc
|   +* looking for [dict equal]Ralf Fassel
|   |`* looking for [dict equal]Harald Oehlmann
|   | `- looking for [dict equal]Rich
|   `- looking for [dict equal]Rich
`- looking for [dict equal]Oleg Nemanov

1
looking for [dict equal]

<0436611c-cd52-448b-9582-217287942da7n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10093&group=comp.lang.tcl#10093

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a0c:f3c9:0:b0:4bb:cf03:d5b0 with SMTP id f9-20020a0cf3c9000000b004bbcf03d5b0mr50507562qvm.36.1667991428150;
Wed, 09 Nov 2022 02:57:08 -0800 (PST)
X-Received: by 2002:a37:bd87:0:b0:6fa:50a0:db20 with SMTP id
n129-20020a37bd87000000b006fa50a0db20mr30133894qkf.425.1667991427979; Wed, 09
Nov 2022 02:57:07 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 9 Nov 2022 02:57:07 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=193.163.1.59; posting-account=yD4T_QoAAAAzNGigQobo9AtcgLgheZii
NNTP-Posting-Host: 193.163.1.59
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com>
Subject: looking for [dict equal]
From: petro.ka...@gmail.com (Petro Kazmirchuk)
Injection-Date: Wed, 09 Nov 2022 10:57:08 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1286
 by: Petro Kazmirchuk - Wed, 9 Nov 2022 10:57 UTC

I need to compare 2 dicts disregarding order of keys (just equal/not equal), preferably without unnecessary generation of string representations. Can't believe it's not in the core :(
I'd prefer to import it from Tcllib or other standard package rather than copy-paste from the Wiki
thanks in advance!

Re: looking for [dict equal]

<nnd$4f7dd361$5041265f@c3ff69072b9300b7>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10094&group=comp.lang.tcl#10094

  copy link   Newsgroups: comp.lang.tcl
Date: Wed, 9 Nov 2022 13:14:33 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.0.2
Subject: Re: looking for [dict equal]
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com>
From: nos...@wanadoo.nl (Schelte)
In-Reply-To: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$4f7dd361$5041265f@c3ff69072b9300b7>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe006.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 21
Injection-Date: Wed, 09 Nov 2022 13:14:33 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1907
 by: Schelte - Wed, 9 Nov 2022 12:14 UTC

On 09/11/2022 11:57, Petro Kazmirchuk wrote:
> I need to compare 2 dicts disregarding order of keys (just equal/not equal), preferably without unnecessary generation of string representations. Can't believe it's not in the core :(
> I'd prefer to import it from Tcllib or other standard package rather than copy-paste from the Wiki
> thanks in advance!

Because Tcl is not typed, it is not possible to have a general [dict
equal] command. Maybe some dict entries are dicts themselves. Then you
would want those to also disregard the order of their keys. If some of
them are lists, you may care about the order or not. Is 0x2A equal to
42? Things like that are impossible to be inferred from only the data.

So, as the developer of the code with knowledge of what the different
entries may contain, you will just have to loop over one dict, check
that it exists in the other dict and then perform the appropriate
comparisons. Of course the first step is to compare the dict sizes.

Schelte.

Re: looking for [dict equal]

<tkgi3k$smi$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10095&group=comp.lang.tcl#10095

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!a5rWVvs5S5ZXUwkNcVnRMw.user.46.165.242.75.POSTED!not-for-mail
From: saitolo...@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: looking for [dict equal]
Date: Wed, 9 Nov 2022 10:48:02 -0500
Organization: Aioe.org NNTP Server
Message-ID: <tkgi3k$smi$1@gioia.aioe.org>
References: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="29394"; posting-host="a5rWVvs5S5ZXUwkNcVnRMw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.3.2
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: saitology9 - Wed, 9 Nov 2022 15:48 UTC

On 11/9/2022 5:57 AM, Petro Kazmirchuk wrote:
> I need to compare 2 dicts disregarding order of keys (just equal/not equal), preferably without unnecessary generation of string representations. Can't believe it's not in the core :(
> I'd prefer to import it from Tcllib or other standard package rather than copy-paste from the Wiki
> thanks in advance!

Well, since EIAS, you can just compare them directly:

if {$dict_1 eq $dict_2} {...}

To disregard the ordering of the keys, you can sort them first:

if {[lsort -dict -index 0 $dict_1] eq [lsort -dict -index 0 $dict_2]} {...}

Re: looking for [dict equal]

<20221109151744.0e36b05d@lud1.home>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10096&group=comp.lang.tcl#10096

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!nS+j7MG3oyuwd9d+furJmA.user.46.165.242.75.POSTED!not-for-mail
From: no...@no.no (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: looking for [dict equal]
Date: Wed, 9 Nov 2022 15:17:44 -0300
Organization: Aioe.org NNTP Server
Message-ID: <20221109151744.0e36b05d@lud1.home>
References: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="37771"; posting-host="nS+j7MG3oyuwd9d+furJmA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Newsreader: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu)
X-Notice: Filtered by postfilter v. 0.9.2
 by: Luc - Wed, 9 Nov 2022 18:17 UTC

One may be shocked (or not really) to learn that I know nothing about
dicts. I used to write Tcl every day and hang around the wiki and
chat room often in the oughts, a long time ago. Then I stepped away
from Tcl and the community for personal reasons...

Until now.

When I left the scene, dict was a pretty new addition and I never got
around to learning it. I just read the man page and found it very
confusing. I don't see how it's much different from a list. Looks like
it's a list-like array or an array-like list. Whatever. I need to put
some time aside to study it carefully.

With that said, in my ignorance, I suppose you can traverse the entire
content of a dict, can't you? It would seem useless to me if you can't.
So it must be possible and not even very difficult to write a proc
that will "gut" or "disassemble" a dict in multiple parts that can then
be compared directly with the counterparts of another dict, one to one.
A little bit like comparing two directories, each one with multiple
subdirectories and files.

Maybe you can even use md5sum to compare those "gutted" parts.

It's an idea. But I think I've made it clear that I don't understand
how dicts work, so pardon me if the idea is not good -- if possible
at all.

--
Luc
>>
**************************
On Wed, 9 Nov 2022 02:57:07 -0800 (PST), Petro Kazmirchuk wrote:

> I need to compare 2 dicts disregarding order of keys (just equal/not
> equal), preferably without unnecessary generation of string
> representations. Can't believe it's not in the core :( I'd prefer to
> import it from Tcllib or other standard package rather than copy-paste
> from the Wiki thanks in advance!

Re: looking for [dict equal]

<tkh8oj$b1p1$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10097&group=comp.lang.tcl#10097

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: looking for [dict equal]
Date: Wed, 9 Nov 2022 22:14:43 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <tkh8oj$b1p1$1@dont-email.me>
References: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com> <20221109151744.0e36b05d@lud1.home>
Injection-Date: Wed, 9 Nov 2022 22:14:43 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="ba37e23923212b2ccffb30998cde8819";
logging-data="362273"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8kXaw6eA7Smvm+W1CK+En"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:XNy476Pxzj5YjiZ3VK/99bgD//8=
 by: Rich - Wed, 9 Nov 2022 22:14 UTC

Luc <no@no.no> wrote:
> When I left the scene, dict was a pretty new addition and I never got
> around to learning it. I just read the man page and found it very
> confusing. I don't see how it's much different from a list. Looks like
> it's a list-like array or an array-like list. Whatever. I need to put
> some time aside to study it carefully.

One way of viewing it is as an array with "ordering" -- the ordering
being the insertion order of the keys.

The big difference between dicts and array's is that arrays as they
were built way back in the beginning of Tcl, are logically collections
of variables (each array entry is as if it was a separate variable
underneath).

That is why you can't use $array to get all of the contents of an
array, and why you can't use $array to pass an entire array into a proc
as a parameter. You have to pass the name of the array, and then use
upvar to link the passed in name to a variable within the proc.

Dicts are arrays that do not have that restriction of being
"collections of variables". Because of that, one can do "puts $dict" to
obtain the string representation of the dict on an output channel, and
one can use $dict to pass a dict to a proc as a parameter, instead of
having to pass in the name of the dict.

Now, one could argue that the 'definition' of arrays could have also
changed to allow $array to retreive the string rep., and to allow
passing entire arrays into a proc via $array syntax. My *guess* as to
why that was not done is doing so was likely seen as to much of a risk
of a breaking change to very old Tcl syntax, so the definiton of arrays
was unchanged and [dict] was added.

> With that said, in my ignorance, I suppose you can traverse the entire
> content of a dict, can't you? It would seem useless to me if you can't.

You can.

> So it must be possible and not even very difficult to write a proc
> that will "gut" or "disassemble" a dict in multiple parts that can then
> be compared directly with the counterparts of another dict, one to one.

For your own dicts that you create in your own programs, yes, this is
quite possible. Because you know what each leg of the tree is supposed
to be.

But creating a generic "equal" procedure, that operates on any two
arbitrary dicts from any coder's piece of code, is what is not
possible. Because any value could itself be another dict, or a plain
list, or just a string. But because Tcl is typeless, there is no way
for a generic Tcl "dict equals" to know, when encountering "this might
be a dict here" whether that is just a string of characters, a list of
six words, or a dict with three keys and three values. More often than
not, the distinction won't matter, but there will be enough instances
where the distinction does matter than a generic 'dict equals' can't be
created that works for all possible inputs.

> A little bit like comparing two directories, each one with multiple
> subdirectories and files.

Except, imagine that you can't know when you encounter something at
level 3, whether it is a file or a directory. If you don't know which
are directories, you don't know which ones to further descend into.
That's the problem with a generic 'dict equals' intended to work on any
possible input.

Re: looking for [dict equal]

<1356b0a3-5a8d-4934-8f34-85a8e4c0db18n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10099&group=comp.lang.tcl#10099

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:4d03:0:b0:3a5:1b18:7747 with SMTP id w3-20020ac84d03000000b003a51b187747mr48420178qtv.538.1668070221196;
Thu, 10 Nov 2022 00:50:21 -0800 (PST)
X-Received: by 2002:a05:622a:1ba5:b0:3a4:ffd9:22d8 with SMTP id
bp37-20020a05622a1ba500b003a4ffd922d8mr51092817qtb.356.1668070221047; Thu, 10
Nov 2022 00:50:21 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Thu, 10 Nov 2022 00:50:20 -0800 (PST)
In-Reply-To: <tkh8oj$b1p1$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=193.163.1.59; posting-account=yD4T_QoAAAAzNGigQobo9AtcgLgheZii
NNTP-Posting-Host: 193.163.1.59
References: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com>
<20221109151744.0e36b05d@lud1.home> <tkh8oj$b1p1$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1356b0a3-5a8d-4934-8f34-85a8e4c0db18n@googlegroups.com>
Subject: Re: looking for [dict equal]
From: petro.ka...@gmail.com (Petro Kazmirchuk)
Injection-Date: Thu, 10 Nov 2022 08:50:21 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1373
 by: Petro Kazmirchuk - Thu, 10 Nov 2022 08:50 UTC

Thank you all for responses. Now I understand why there's no generic [dict equal]
yet another thing to reinvent in my code :-( alongside assert, sleep, vwait with timeout and endless argument parsing

Re: looking for [dict equal]

<ygatu375b4h.fsf@akutech.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10100&group=comp.lang.tcl#10100

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralf...@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: looking for [dict equal]
Date: Thu, 10 Nov 2022 11:58:54 +0100
Lines: 32
Message-ID: <ygatu375b4h.fsf@akutech.de>
References: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com>
<20221109151744.0e36b05d@lud1.home> <tkh8oj$b1p1$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net RDxIl/EpaPkceCTqh0gIMg5DWulVj2anv6NjAzViFPC8cVLyE=
Cancel-Lock: sha1:rIz2VTwdKQo9y8rLBFiJtnLEYos= sha1:ziUd/Rk4gCkLlTzYaxZpifwjmuw=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Thu, 10 Nov 2022 10:58 UTC

* Rich <rich@example.invalid>
| Luc <no@no.no> wrote:
| > A little bit like comparing two directories, each one with multiple
| > subdirectories and files.
>
| Except, imagine that you can't know when you encounter something at
| level 3, whether it is a file or a directory. If you don't know which
| are directories, you don't know which ones to further descend into.
| That's the problem with a generic 'dict equals' intended to work on any
| possible input.

For example:

% set a [dict create val1 [list val11 val12]]
val1 {val11 val12}

% set b [dict create val1 [dict create val11 val12]]
val1 {val11 val12}

% set c [dict create val1 "val12 val12"]
val1 {val11 val12}

'a' has a *list* as value for the key, 'b' has a *dict* as value for the
same key, 'c' a *string*. They all have the same string representation,
but are they *equal*?

For files and directories you have [file isdirectory] and [file isfile],
but that info is not easily available for the dict elements (and
probably not even reliably, considering "dict set a val1 val11 val13" is
possible).

R'

Re: looking for [dict equal]

<tkisjq$i5cn$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10102&group=comp.lang.tcl#10102

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: looking for [dict equal]
Date: Thu, 10 Nov 2022 12:59:38 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <tkisjq$i5cn$1@dont-email.me>
References: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com> <20221109151744.0e36b05d@lud1.home> <tkh8oj$b1p1$1@dont-email.me> <1356b0a3-5a8d-4934-8f34-85a8e4c0db18n@googlegroups.com>
Injection-Date: Thu, 10 Nov 2022 12:59:38 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="cb137c1dce65bd9b035a161c79d8bb82";
logging-data="595351"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8tYu6fdhK6oPoJnnyCerg"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:Jr/SZCxXrRnCuNIVuIAmjR+dG2I=
 by: Rich - Thu, 10 Nov 2022 12:59 UTC

Petro Kazmirchuk <petro.kazmirchuk@gmail.com> wrote:
> Thank you all for responses. Now I understand why there's no generic
> [dict equal]

> yet another thing to reinvent in my code :-( alongside assert, sleep,
> vwait with timeout and endless argument parsing

For 'asssert' there is the 'error' command and/or 'return -code error'.

For argument parsing, one option is to use 'cmdline' from Tcllib (if
you do not yet have Tcllib installed, then I recommend you do so, it
contains a lot of ready made pieces).

For a blocking sleep, plain 'after' works just fine. But if you
instead want a sleep that does not otherwise block the event loop then
yes there is a little work there.

vwait with timeout is just vwait with a background after to 'unwait'
the vwait if the timeout expires. Better done as a namespace ensemble
or an actual object just to keep the necessary variables isolated.

You will want to be careful of the 'nested vwait' issue:

https://wiki.tcl-lang.org/page/vwait

Re: looking for [dict equal]

<3c56ed5c-57f6-47dd-bab0-bc58b2ee0914n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10105&group=comp.lang.tcl#10105

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:1cc7:b0:4af:6573:c056 with SMTP id g7-20020a0562141cc700b004af6573c056mr59313670qvd.103.1668086823322;
Thu, 10 Nov 2022 05:27:03 -0800 (PST)
X-Received: by 2002:ac8:5893:0:b0:3a5:822b:e370 with SMTP id
t19-20020ac85893000000b003a5822be370mr19330586qta.11.1668086823150; Thu, 10
Nov 2022 05:27:03 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Thu, 10 Nov 2022 05:27:02 -0800 (PST)
In-Reply-To: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=194.190.114.28; posting-account=RPJNegoAAAAUgD_yLdrci9D1ZtZ1oI0L
NNTP-Posting-Host: 194.190.114.28
References: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3c56ed5c-57f6-47dd-bab0-bc58b2ee0914n@googlegroups.com>
Subject: Re: looking for [dict equal]
From: oleg.o.n...@gmail.com (Oleg Nemanov)
Injection-Date: Thu, 10 Nov 2022 13:27:03 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2287
 by: Oleg Nemanov - Thu, 10 Nov 2022 13:27 UTC

среда, 9 ноября 2022 г. в 13:57:10 UTC+3, Petro Kazmirchuk:
> I need to compare 2 dicts disregarding order of keys (just equal/not equal), preferably without unnecessary generation of string representations. Can't believe it's not in the core :(
> I'd prefer to import it from Tcllib or other standard package rather than copy-paste from the Wiki
> thanks in advance!

You can't compare 2 dicts without additional info from the side about every value type(is this a leaf element - string, for example; or this is a dict).
If you create a dict with "dict create" and "dict set" commands, then you can try to derive a type info with help of ::tcl::unsupported::representation.

It would be better if tcl has no shimmering, but instead has explicit routines to stringify and parse values, imho.
Implicit data type convertion(shimmering) is the cause of hardly findable bugs.

May be, sometime in the future we will get something like tcl strict mode(turnable by some option) for turning off shimmering.

Re: looking for [dict equal]

<20221110124924.29bcc23b@lud1.home>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10107&group=comp.lang.tcl#10107

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!nS+j7MG3oyuwd9d+furJmA.user.46.165.242.75.POSTED!not-for-mail
From: no...@no.no (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: looking for [dict equal]
Date: Thu, 10 Nov 2022 12:49:24 -0300
Organization: Aioe.org NNTP Server
Message-ID: <20221110124924.29bcc23b@lud1.home>
References: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com>
<20221109151744.0e36b05d@lud1.home>
<tkh8oj$b1p1$1@dont-email.me>
<ygatu375b4h.fsf@akutech.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="38748"; posting-host="nS+j7MG3oyuwd9d+furJmA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Newsreader: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu)
X-Notice: Filtered by postfilter v. 0.9.2
 by: Luc - Thu, 10 Nov 2022 15:49 UTC

On Thu, 10 Nov 2022 11:58:54 +0100, Ralf Fassel wrote:

> For example:
>
> % set a [dict create val1 [list val11 val12]]
> val1 {val11 val12}
>
> % set b [dict create val1 [dict create val11 val12]]
> val1 {val11 val12}
>
> % set c [dict create val1 "val12 val12"]
> val1 {val11 val12}
>
> 'a' has a *list* as value for the key, 'b' has a *dict* as value for the
> same key, 'c' a *string*. They all have the same string representation,
> but are they *equal*?
>
> For files and directories you have [file isdirectory] and [file isfile],
> but that info is not easily available for the dict elements (and
> probably not even reliably, considering "dict set a val1 val11 val13" is
> possible).
>
> R'

For the strict sake of comparison, I would treat all occurrences of
[llength $list] <= 1 as strings.

Or maybe treat all non-space strings as [list $string].

About the dicts, I don't know. I still don't know how they really work
until I reserve some time to study them adequately.

Of course, there is a 99.9% probability that you are right and I am wrong.

I'm just very stubborn. It can be a valuable trait in certain situations.

--
Luc
>>

Re: looking for [dict equal]

<ygapmdu69x4.fsf@akutech.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10108&group=comp.lang.tcl#10108

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralf...@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: looking for [dict equal]
Date: Thu, 10 Nov 2022 17:39:35 +0100
Lines: 15
Message-ID: <ygapmdu69x4.fsf@akutech.de>
References: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com>
<20221109151744.0e36b05d@lud1.home> <tkh8oj$b1p1$1@dont-email.me>
<ygatu375b4h.fsf@akutech.de> <20221110124924.29bcc23b@lud1.home>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net yHa3S4mX/6Eo+9aq3GvVMg8Pj4wx2fO7+P6kui03GWDaPWvzQ=
Cancel-Lock: sha1:yuoPPfaMT9MrxGqL81Nxfp7ihtA= sha1:JVv0gks+2pDY00/NXn/cEdsMGTc=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Thu, 10 Nov 2022 16:39 UTC

* Luc <no@no.no>
| About the dicts, I don't know. I still don't know how they really work
| until I reserve some time to study them adequately.

Always a good idea :-) I don't know the internals of dicts either, but
Rich has listed the advantages when using them instead of arrays up-thread.

| I'm just very stubborn. It can be a valuable trait in certain situations.

I wouldn't call that stubborn in this context. If you're honestly
trying to understand what this is all about, that's a Good Thing¹ IMHO.

R'
---
¹ http://www.catb.org/~esr/jargon/html/G/Good-Thing.html

Re: looking for [dict equal]

<tkjaf9$j6n8$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10109&group=comp.lang.tcl#10109

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: wortka...@yahoo.com (Harald Oehlmann)
Newsgroups: comp.lang.tcl
Subject: Re: looking for [dict equal]
Date: Thu, 10 Nov 2022 17:56:09 +0100
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <tkjaf9$j6n8$1@dont-email.me>
References: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com>
<20221109151744.0e36b05d@lud1.home> <tkh8oj$b1p1$1@dont-email.me>
<ygatu375b4h.fsf@akutech.de> <20221110124924.29bcc23b@lud1.home>
<ygapmdu69x4.fsf@akutech.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 10 Nov 2022 16:56:10 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="88e854af85c1c4a511a99eb7a46af50f";
logging-data="629480"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/DbDQEmjKLS2ksqMGJbq36"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.4.2
Cancel-Lock: sha1:WVN1R0AOqdPbrCGjgYPxRq6bqS8=
Content-Language: en-GB
In-Reply-To: <ygapmdu69x4.fsf@akutech.de>
 by: Harald Oehlmann - Thu, 10 Nov 2022 16:56 UTC

Am 10.11.2022 um 17:39 schrieb Ralf Fassel:
> * Luc <no@no.no>
> | About the dicts, I don't know. I still don't know how they really work
> | until I reserve some time to study them adequately.
>
> Always a good idea :-) I don't know the internals of dicts either, but
> Rich has listed the advantages when using them instead of arrays up-thread.
>
> | I'm just very stubborn. It can be a valuable trait in certain situations.
>
> I wouldn't call that stubborn in this context. If you're honestly
> trying to understand what this is all about, that's a Good Thing¹ IMHO.
>
> R'
> ---
> ¹ http://www.catb.org/~esr/jargon/html/G/Good-Thing.html

To guess the type of a list value, you may look what the pdict does with
values:

https://wiki.tcl-lang.org/page/pdict%3A+Pretty+print+a+dict?R=0&O=pdict&W=

Look at the line:
[string match "value is a dict*"\
[tcl::unsupported::representation $val]]

Enjoy,
Harald

Re: looking for [dict equal]

<tkjf1l$jihp$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10110&group=comp.lang.tcl#10110

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: looking for [dict equal]
Date: Thu, 10 Nov 2022 18:14:13 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <tkjf1l$jihp$1@dont-email.me>
References: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com> <20221109151744.0e36b05d@lud1.home> <tkh8oj$b1p1$1@dont-email.me> <ygatu375b4h.fsf@akutech.de> <20221110124924.29bcc23b@lud1.home>
Injection-Date: Thu, 10 Nov 2022 18:14:13 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="cb137c1dce65bd9b035a161c79d8bb82";
logging-data="641593"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SdYC3FrtWbPayDh4un5hG"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:y9VYot2HO4nqGV2JDTpoB3IOpWY=
 by: Rich - Thu, 10 Nov 2022 18:14 UTC

Luc <no@no.no> wrote:
> On Thu, 10 Nov 2022 11:58:54 +0100, Ralf Fassel wrote:
>
>> For example:
>>
>> % set a [dict create val1 [list val11 val12]]
>> val1 {val11 val12}
>>
>> % set b [dict create val1 [dict create val11 val12]]
>> val1 {val11 val12}
>>
>> % set c [dict create val1 "val12 val12"]
>> val1 {val11 val12}
>>
>> 'a' has a *list* as value for the key, 'b' has a *dict* as value for the
>> same key, 'c' a *string*. They all have the same string representation,
>> but are they *equal*?
>>
>> For files and directories you have [file isdirectory] and [file isfile],
>> but that info is not easily available for the dict elements (and
>> probably not even reliably, considering "dict set a val1 val11 val13" is
>> possible).
>>
>> R'
>
>
> For the strict sake of comparison, I would treat all occurrences of
> [llength $list] <= 1 as strings.
>
> Or maybe treat all non-space strings as [list $string].

Whereupon you delve into the philosophical discussion of what it means to
be "equal" and the reason Javascript has both == and === operators for
different flavors of equality.

Is any "thing" (list, dict string) "equal" if its string representation
is equal? Some will say yes, some will say no.

For those that say no, they will want equal to mean: if the thing is a
list, then each of its individual elements are "equal" (to the same
recursive definition they use for "equal"). But those same folks would
say that a list of four elements is not equal to a dict of two keys and
two values, even if the "Tcl string representation" of both is
identical.

I.e.:

$ rlwrap tclsh
% set a [list one two three four]
one two three four
% set b [dict create one two three four]
one two three four
% string equal $a $b
1

$a is a list of four elements. $b is a dict of two key/value pairs.
Their string representations are equal, but a list is a subtly
different 'thing' than a dict. So some would say that $a should not be
equal to $b because they are different "types" underneath. Those that
usualy want such strict definitions also often use languages who's type
systems enforce such definitions, where a variable defined as a "list"
is never equal to a variable defined as a "dict" because list and dict
are two different "types" in the language.

One single 'equal' can't satisify both sides of that divide.

> About the dicts, I don't know. I still don't know how they really work
> until I reserve some time to study them adequately.

At a very broad level, dict's are essentially just arrays that you can
pass into procs by value instead of by name only.

Re: looking for [dict equal]

<tkjfeo$jihp$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10111&group=comp.lang.tcl#10111

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: looking for [dict equal]
Date: Thu, 10 Nov 2022 18:21:12 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <tkjfeo$jihp$2@dont-email.me>
References: <0436611c-cd52-448b-9582-217287942da7n@googlegroups.com> <20221109151744.0e36b05d@lud1.home> <tkh8oj$b1p1$1@dont-email.me> <ygatu375b4h.fsf@akutech.de> <20221110124924.29bcc23b@lud1.home> <ygapmdu69x4.fsf@akutech.de> <tkjaf9$j6n8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 10 Nov 2022 18:21:12 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="cb137c1dce65bd9b035a161c79d8bb82";
logging-data="641593"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vxZKDbc0uby8H99tVkFlv"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:CoHwRMvvlLGyl6slet/N5DJpbJk=
 by: Rich - Thu, 10 Nov 2022 18:21 UTC

Harald Oehlmann <wortkarg3@yahoo.com> wrote:
> Am 10.11.2022 um 17:39 schrieb Ralf Fassel:
>> * Luc <no@no.no>
>> | About the dicts, I don't know. I still don't know how they really
>> work | until I reserve some time to study them adequately.
>>
>> Always a good idea :-) I don't know the internals of dicts either,
>> but Rich has listed the advantages when using them instead of arrays
>> up-thread.
>>
>> | I'm just very stubborn. It can be a valuable trait in certain
>> situations.
>>
>> I wouldn't call that stubborn in this context. If you're honestly
>> trying to understand what this is all about, that's a Good Thing¹
>> IMHO.
>>
>> R'
>> ---
>> ¹ http://www.catb.org/~esr/jargon/html/G/Good-Thing.html
>
> To guess the type of a list value, you may look what the pdict does
> with values:
>
> https://wiki.tcl-lang.org/page/pdict%3A+Pretty+print+a+dict?R=0&O=pdict&W=
>
> Look at the line:
> [string match "value is a dict*"\
> [tcl::unsupported::representation $val]]

True, but that big "unsupported" there in the proc namespace should
serve as a warning....

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor