Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

"I am your density." -- George McFly in "Back to the Future"


devel / comp.lang.tcl / Re: Reference to dictionary variable name in dict commands seems inconsistent

SubjectAuthor
* Reference to dictionary variable name in dict commands seems inconsistentLawrence Emke
+* Reference to dictionary variable name in dict commands seemssaitology9
|`* Reference to dictionary variable name in dict commands seemset99
| `* Reference to dictionary variable name in dict commands seems inconsistentLawrence Emke
|  `* Reference to dictionary variable name in dict commands seems inconsistentLawrence Emke
|   +- Reference to dictionary variable name in dict commands seems inconsistentheinrichmartin
|   `- Reference to dictionary variable name in dict commands seems inconsistentRalf Fassel
`* Reference to dictionary variable name in dict commands seems inconsistentEmiliano
 `- Reference to dictionary variable name in dict commands seemset99

1
Reference to dictionary variable name in dict commands seems inconsistent

<fb8ebf20-d565-49a5-b0f3-0cc068a8e46an@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12350&group=comp.lang.tcl#12350

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:134d:b0:746:9411:4c18 with SMTP id c13-20020a05620a134d00b0074694114c18mr3885151qkl.5.1682447178311;
Tue, 25 Apr 2023 11:26:18 -0700 (PDT)
X-Received: by 2002:a05:620a:13b3:b0:74e:13f0:e680 with SMTP id
m19-20020a05620a13b300b0074e13f0e680mr2824336qki.5.1682447177999; Tue, 25 Apr
2023 11:26:17 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder8.news.weretis.net!news.uzoreto.com!peer02.ams4!peer.am4.highwinds-media.com!peer03.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: Tue, 25 Apr 2023 11:26:17 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2607:fb90:399a:41c1:f0ff:23fc:81f:5866;
posting-account=A-U1pgoAAAA9KnY2zwA9GUw_-CvzQnaD
NNTP-Posting-Host: 2607:fb90:399a:41c1:f0ff:23fc:81f:5866
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fb8ebf20-d565-49a5-b0f3-0cc068a8e46an@googlegroups.com>
Subject: Reference to dictionary variable name in dict commands seems inconsistent
From: lawrence.emke@gmail.com (Lawrence Emke)
Injection-Date: Tue, 25 Apr 2023 18:26:18 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1869
 by: Lawrence Emke - Tue, 25 Apr 2023 18:26 UTC

I understand the syntax to create a dict variable:
set dname [ dict create a b ]
Now compare these two commands:

dict append dname d e
and
dict get $dname d

in the first case the dict name does not require the de-reference $ character.
In the second command it does require the deference $ character.

This seems to be confusing. Don't force me to remember which case requires the de-reference $ character and which does not accept the $ character.

Maybe there is a hidden explanation (reason) other than the implementation of the command that does not just pop up to a new student. Please make it consistent. It will save time and effort to learn the language syntax.

Re: Reference to dictionary variable name in dict commands seems inconsistent

<u297es$vqbb$2@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12352&group=comp.lang.tcl#12352

  copy link   Newsgroups: comp.lang.tcl
Path: rocksolid2!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: Reference to dictionary variable name in dict commands seems
inconsistent
Date: Tue, 25 Apr 2023 14:51:07 -0400
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <u297es$vqbb$2@dont-email.me>
References: <fb8ebf20-d565-49a5-b0f3-0cc068a8e46an@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 25 Apr 2023 18:51:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7650db85cbda4689532e286ece70e41a";
logging-data="1042795"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Jf5eHjkFwbD4HZDQD6qjy"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:KbwG8Vf3+aDOpbEjrzoL3DM/8X8=
Content-Language: en-US
In-Reply-To: <fb8ebf20-d565-49a5-b0f3-0cc068a8e46an@googlegroups.com>
 by: saitology9 - Tue, 25 Apr 2023 18:51 UTC

On 4/25/2023 2:26 PM, Lawrence Emke wrote:
> I understand the syntax to create a dict variable:
> set dname [ dict create a b ]
> Now compare these two commands:
>
> dict append dname d e
> and
> dict get $dname d
>
> in the first case the dict name does not require the de-reference $ character.
> In the second command it does require the deference $ character.
>
> This seems to be confusing. Don't force me to remember which case requires the de-reference $ character and which does not accept the $ character.
>
> Maybe there is a hidden explanation (reason) other than the implementation of the command that does not just pop up to a new student. Please make it consistent. It will save time and effort to learn the language syntax.

I agree dict is hard to get used to.

Think of dict not as some new data structure in Tcl but rather as an
interface consisting of a set of commands that operate on lists with an
even number of elements. In fact, I suspect that many dict use cases
are on lists that happen to have this structure. You can use on any
literal lists or variable that satisfies this condition.

Under this light, the first one makes sense: you don't want to append to
a literal list, i.e., a constant value. This will be like doing "5 = x
+ y" in C for example.

The second makes sense too because it acts as a get-method on a list
that has an even number of elements. You don't want to be forced into
creating a temporary dict variable out of your normal lists just to get
some elements out of it.

Re: Reference to dictionary variable name in dict commands seems inconsistent

<u297u5$vv76$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12353&group=comp.lang.tcl#12353

  copy link   Newsgroups: comp.lang.tcl
Path: rocksolid2!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: Reference to dictionary variable name in dict commands seems
inconsistent
Date: Tue, 25 Apr 2023 11:59:17 -0700
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <u297u5$vv76$1@dont-email.me>
References: <fb8ebf20-d565-49a5-b0f3-0cc068a8e46an@googlegroups.com>
<u297es$vqbb$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 25 Apr 2023 18:59:17 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bdeff8619c0c9c631c919d60c9f275df";
logging-data="1047782"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+tIybdd1jf9V3G2PD2QWJO"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:gLmGgB177pxXSs3Npu4WQBVffCc=
Content-Language: en-US
In-Reply-To: <u297es$vqbb$2@dont-email.me>
 by: et99 - Tue, 25 Apr 2023 18:59 UTC

On 4/25/2023 11:51 AM, saitology9 wrote:
> On 4/25/2023 2:26 PM, Lawrence Emke wrote:
>> I understand the syntax to create a dict variable:
>>     set dname [ dict create a b ]
>> Now compare these two commands:
>>
>>     dict append dname  d e
>> and
>>     dict get $dname d
>>
>> in the first  case the dict name does not require the de-reference $ character.
>> In the second command it does require the deference $ character.
>>
>> This seems to be confusing. Don't force me to remember which case requires the de-reference $ character and which does not accept the $ character.
>>
>> Maybe there is a hidden explanation (reason) other than the implementation of the command that does not just pop up to a new student.  Please make it consistent. It will save time and effort to learn the language syntax.
>
> I agree dict is hard to get used to.
>
> Think of dict not as some new data structure in Tcl but rather as an interface consisting of a set of commands that operate on lists with an even number of elements.  In fact, I suspect that many dict use cases are on lists that happen to have this structure. You can use on any literal lists or variable that satisfies this condition.
>
> Under this light, the first one makes sense: you don't want to append to a literal list, i.e., a constant value.  This will be like doing "5 = x + y" in C for example.
>
> The second makes sense too because it acts as a get-method on a list that has an even number of elements.  You don't want to be forced into creating a temporary dict variable out of your normal lists just to get some elements out of it.
>
>
>
>

Commands that modify an existing variable, are call by name
if the variable's value is needed, then it's by value $value

that's how I remember them. Similar to say, lappend, lset etc.
which modify a current list are by name vs. lindex, lrange,
which take a list and return a new one or part of one are by value.

Incidentally, the dict append manual entry does not say that
if the variable doesn't exist, then it is created first as
an empty dict. But that is consistent with such commands as
[incr]. And so too [dict incr] which also doesn't mention that
a non existent key is treated as a 0 and then incremented.

Re: Reference to dictionary variable name in dict commands seems inconsistent

<8c0be45e-8528-4a79-afa9-34d5eb8fcc3cn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12357&group=comp.lang.tcl#12357

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:359:b0:74d:fb3d:536 with SMTP id t25-20020a05620a035900b0074dfb3d0536mr4106262qkm.13.1682458057468;
Tue, 25 Apr 2023 14:27:37 -0700 (PDT)
X-Received: by 2002:ac8:5713:0:b0:3ef:3541:4359 with SMTP id
19-20020ac85713000000b003ef35414359mr6937514qtw.1.1682458057181; Tue, 25 Apr
2023 14:27:37 -0700 (PDT)
Path: rocksolid2!i2pn.org!usenet.blueworldhosting.com!diablo1.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: Tue, 25 Apr 2023 14:27:36 -0700 (PDT)
In-Reply-To: <u297u5$vv76$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2607:fb90:399a:41c1:f0ff:23fc:81f:5866;
posting-account=A-U1pgoAAAA9KnY2zwA9GUw_-CvzQnaD
NNTP-Posting-Host: 2607:fb90:399a:41c1:f0ff:23fc:81f:5866
References: <fb8ebf20-d565-49a5-b0f3-0cc068a8e46an@googlegroups.com>
<u297es$vqbb$2@dont-email.me> <u297u5$vv76$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8c0be45e-8528-4a79-afa9-34d5eb8fcc3cn@googlegroups.com>
Subject: Re: Reference to dictionary variable name in dict commands seems inconsistent
From: lawrence.emke@gmail.com (Lawrence Emke)
Injection-Date: Tue, 25 Apr 2023 21:27:37 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 5739
 by: Lawrence Emke - Tue, 25 Apr 2023 21:27 UTC

On Tuesday, April 25, 2023 at 1:59:22 PM UTC-5, et99 wrote:
> On 4/25/2023 11:51 AM, saitology9 wrote:
> > On 4/25/2023 2:26 PM, Lawrence Emke wrote:
> >> I understand the syntax to create a dict variable:
> >> set dname [ dict create a b ]
> >> Now compare these two commands:
> >>
> >> dict append dname d e
> >> and
> >> dict get $dname d
> >>
> >> in the first case the dict name does not require the de-reference $ character.
> >> In the second command it does require the deference $ character.
> >>
> >> This seems to be confusing. Don't force me to remember which case requires the de-reference $ character and which does not accept the $ character..
> >>
> >> Maybe there is a hidden explanation (reason) other than the implementation of the command that does not just pop up to a new student. Please make it consistent. It will save time and effort to learn the language syntax.
> >
> > I agree dict is hard to get used to.
> >
> > Think of dict not as some new data structure in Tcl but rather as an interface consisting of a set of commands that operate on lists with an even number of elements. In fact, I suspect that many dict use cases are on lists that happen to have this structure. You can use on any literal lists or variable that satisfies this condition.
> >
> > Under this light, the first one makes sense: you don't want to append to a literal list, i.e., a constant value. This will be like doing "5 = x + y" in C for example.
> >
> > The second makes sense too because it acts as a get-method on a list that has an even number of elements. You don't want to be forced into creating a temporary dict variable out of your normal lists just to get some elements out of it.
> >
> >
> >
> >
> Commands that modify an existing variable, are call by name
> if the variable's value is needed, then it's by value $value
>
> that's how I remember them. Similar to say, lappend, lset etc.
> which modify a current list are by name vs. lindex, lrange,
> which take a list and return a new one or part of one are by value.
>
> Incidentally, the dict append manual entry does not say that
> if the variable doesn't exist, then it is created first as
> an empty dict. But that is consistent with such commands as
> [incr]. And so too [dict incr] which also doesn't mention that
> a non existent key is treated as a 0 and then incremented.

The problem is that the dict "name" is hard coded in the append command
without the $ de-reference action. In the get sub command it must contain
a reference variable syntax. If you switch the $ syntax on the both statements,
neither statement executes correctly.

My goal is to separate the application data namespace from the proc/methods..
By that I mean, having all of the app data in one namespace and the methods
in one or more other namespaces. I want to avoid little namespaces hanging off
the applications data namespace. This means the dict append sub-command executed in a proc
that receives the data via a parameter should use a reference to the dict structure rather than coding its name.
The append sub-command needs receive the dict structure via a proc parameter variable. In this
way the dict structure can be passed as a parameter. The unset sub-command takes either the DictName
or a de-reference variable to the dict element. Both work. The same should be for the append sub-command

I have tried several configurations in proc calls. None of them work. I have considered the
level command. However, the actual dict structure may be a member of the caller's
namespace. I assume in this situation, the search for the parameter in the caller's namespace would fail, because it is a variable in the namespace passed to the caller. It might work? Don't know. Still the dict append sub-command needs to allow reference the dict data via de-reference, to make it
simpler and more consistent. I have not tried the "set" sub-command, but if it is like you said, then
it also needs to be able to refer to the dict element via de-referenced variable name.

If I am not clear in my response, let me know.

thanks for the help. I will say no more.

Re: Reference to dictionary variable name in dict commands seems inconsistent

<47b33d6d-c36f-4448-ba9a-3ae25c6ac5b1n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12359&group=comp.lang.tcl#12359

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:13e9:b0:74e:1ea7:7817 with SMTP id h9-20020a05620a13e900b0074e1ea77817mr3344887qkl.2.1682464578357;
Tue, 25 Apr 2023 16:16:18 -0700 (PDT)
X-Received: by 2002:a05:6214:a70:b0:5ef:44fb:b65a with SMTP id
ef16-20020a0562140a7000b005ef44fbb65amr3633621qvb.0.1682464577975; Tue, 25
Apr 2023 16:16:17 -0700 (PDT)
Path: rocksolid2!i2pn.org!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!fdn.fr!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Tue, 25 Apr 2023 16:16:17 -0700 (PDT)
In-Reply-To: <8c0be45e-8528-4a79-afa9-34d5eb8fcc3cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2607:fb90:399a:41c1:f0ff:23fc:81f:5866;
posting-account=A-U1pgoAAAA9KnY2zwA9GUw_-CvzQnaD
NNTP-Posting-Host: 2607:fb90:399a:41c1:f0ff:23fc:81f:5866
References: <fb8ebf20-d565-49a5-b0f3-0cc068a8e46an@googlegroups.com>
<u297es$vqbb$2@dont-email.me> <u297u5$vv76$1@dont-email.me> <8c0be45e-8528-4a79-afa9-34d5eb8fcc3cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <47b33d6d-c36f-4448-ba9a-3ae25c6ac5b1n@googlegroups.com>
Subject: Re: Reference to dictionary variable name in dict commands seems inconsistent
From: lawrence.emke@gmail.com (Lawrence Emke)
Injection-Date: Tue, 25 Apr 2023 23:16:18 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Lawrence Emke - Tue, 25 Apr 2023 23:16 UTC

On Tuesday, April 25, 2023 at 4:27:39 PM UTC-5, Lawrence Emke wrote:
> On Tuesday, April 25, 2023 at 1:59:22 PM UTC-5, et99 wrote:
> > On 4/25/2023 11:51 AM, saitology9 wrote:
> > > On 4/25/2023 2:26 PM, Lawrence Emke wrote:
> > >> I understand the syntax to create a dict variable:
> > >> set dname [ dict create a b ]
> > >> Now compare these two commands:
> > >>
> > >> dict append dname d e
> > >> and
> > >> dict get $dname d
> > >>
> > >> in the first case the dict name does not require the de-reference $ character.
> > >> In the second command it does require the deference $ character.
> > >>
> > >> This seems to be confusing. Don't force me to remember which case requires the de-reference $ character and which does not accept the $ character.
> > >>
> > >> Maybe there is a hidden explanation (reason) other than the implementation of the command that does not just pop up to a new student. Please make it consistent. It will save time and effort to learn the language syntax..
> > >
> > > I agree dict is hard to get used to.
> > >
> > > Think of dict not as some new data structure in Tcl but rather as an interface consisting of a set of commands that operate on lists with an even number of elements. In fact, I suspect that many dict use cases are on lists that happen to have this structure. You can use on any literal lists or variable that satisfies this condition.
> > >
> > > Under this light, the first one makes sense: you don't want to append to a literal list, i.e., a constant value. This will be like doing "5 = x + y" in C for example.
> > >
> > > The second makes sense too because it acts as a get-method on a list that has an even number of elements. You don't want to be forced into creating a temporary dict variable out of your normal lists just to get some elements out of it.
> > >
> > >
> > >
> > >
> > Commands that modify an existing variable, are call by name
> > if the variable's value is needed, then it's by value $value
> >
> > that's how I remember them. Similar to say, lappend, lset etc.
> > which modify a current list are by name vs. lindex, lrange,
> > which take a list and return a new one or part of one are by value.
> >
> > Incidentally, the dict append manual entry does not say that
> > if the variable doesn't exist, then it is created first as
> > an empty dict. But that is consistent with such commands as
> > [incr]. And so too [dict incr] which also doesn't mention that
> > a non existent key is treated as a 0 and then incremented.
> The problem is that the dict "name" is hard coded in the append command
> without the $ de-reference action. In the get sub command it must contain
> a reference variable syntax. If you switch the $ syntax on the both statements,
> neither statement executes correctly.
>
> My goal is to separate the application data namespace from the proc/methods.
> By that I mean, having all of the app data in one namespace and the methods
> in one or more other namespaces. I want to avoid little namespaces hanging off
> the applications data namespace. This means the dict append sub-command executed in a proc
> that receives the data via a parameter should use a reference to the dict structure rather than coding its name.
> The append sub-command needs receive the dict structure via a proc parameter variable. In this
> way the dict structure can be passed as a parameter. The unset sub-command takes either the DictName
> or a de-reference variable to the dict element. Both work. The same should be for the append sub-command
>
> I have tried several configurations in proc calls. None of them work. I have considered the
> level command. However, the actual dict structure may be a member of the caller's
> namespace. I assume in this situation, the search for the parameter in the caller's namespace would fail, because it is a variable in the namespace passed to the caller. It might work? Don't know. Still the dict append sub-command needs to allow reference the dict data via de-reference, to make it
> simpler and more consistent. I have not tried the "set" sub-command, but if it is like you said, then
> it also needs to be able to refer to the dict element via de-referenced variable name.
>
> If I am not clear in my response, let me know.
>
> thanks for the help. I will say no more.

I found out how to do it. just place the name of the dict variable in a variable and pass that variable as the dict element name proc parameter. Then the "dict append $n a b" gets executed with the correct DictName

Re: Reference to dictionary variable name in dict commands seems inconsistent

<71cb23be-0c91-47ec-9105-9d2211c300ebn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12360&group=comp.lang.tcl#12360

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:5cd1:0:b0:3e1:5755:7bbf with SMTP id s17-20020ac85cd1000000b003e157557bbfmr7897765qta.5.1682494367633;
Wed, 26 Apr 2023 00:32:47 -0700 (PDT)
X-Received: by 2002:a05:622a:1a90:b0:3d5:bb6:9240 with SMTP id
s16-20020a05622a1a9000b003d50bb69240mr7204985qtc.4.1682494367427; Wed, 26 Apr
2023 00:32:47 -0700 (PDT)
Path: rocksolid2!i2pn.org!news.1d4.us!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.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, 26 Apr 2023 00:32:47 -0700 (PDT)
In-Reply-To: <47b33d6d-c36f-4448-ba9a-3ae25c6ac5b1n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=91.217.55.78; posting-account=Od2xOAoAAACEyRX3Iu5rYt4oevuoeYUG
NNTP-Posting-Host: 91.217.55.78
References: <fb8ebf20-d565-49a5-b0f3-0cc068a8e46an@googlegroups.com>
<u297es$vqbb$2@dont-email.me> <u297u5$vv76$1@dont-email.me>
<8c0be45e-8528-4a79-afa9-34d5eb8fcc3cn@googlegroups.com> <47b33d6d-c36f-4448-ba9a-3ae25c6ac5b1n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <71cb23be-0c91-47ec-9105-9d2211c300ebn@googlegroups.com>
Subject: Re: Reference to dictionary variable name in dict commands seems inconsistent
From: martin.heinrich@frequentis.com (heinrichmartin)
Injection-Date: Wed, 26 Apr 2023 07:32:47 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3091
 by: heinrichmartin - Wed, 26 Apr 2023 07:32 UTC

On Wednesday, April 26, 2023 at 1:16:21 AM UTC+2, Lawrence Emke wrote:
> > > > On 4/25/2023 2:26 PM, Lawrence Emke wrote:
> > > >> I understand the syntax to create a dict variable:
> > > >> set dname [ dict create a b ]
> > > >> Now compare these two commands:
> > > >>
> > > >> dict append dname d e
> > > >> and
> > > >> dict get $dname d
> > > >>
> > > >> in the first case the dict name does not require the de-reference $ character.
> > > >> In the second command it does require the deference $ character.
> > > >>
> > > >> This seems to be confusing. Don't force me to remember which case requires the de-reference $ character and which does not accept the $ character.
> I found out how to do it. just place the name of the dict variable in a variable and pass that variable as the dict element name proc parameter. Then the "dict append $n a b" gets executed with the correct DictName

As you were looking at Tcl basics, maybe these comments help:
* [set] is actually also a "get" when called with a single arg, i.e. [dict get [set $n] a] is the corresponding syntax to [dict append $n a b].
* I am using the suffix "var" for "indirect variables" (similar to arg names of e.g. dict sub-commands), i.e. [dict get [set $nvar] a] but [dict get $n a].
* Just to be sure: [dict append] appends a string to the existing value (or to the empty string if the key did not exist); [dict set] replaces the existing value.
* Unifying the syntax of reading and writing sub-commands will not happen, because passing a value - that is not in a variable - is a valid use case when reading.

Re: Reference to dictionary variable name in dict commands seems inconsistent

<yga7ctzxbte.fsf@akutech.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12361&group=comp.lang.tcl#12361

  copy link   Newsgroups: comp.lang.tcl
Path: rocksolid2!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: Reference to dictionary variable name in dict commands seems inconsistent
Date: Wed, 26 Apr 2023 10:55:09 +0200
Lines: 16
Message-ID: <yga7ctzxbte.fsf@akutech.de>
References: <fb8ebf20-d565-49a5-b0f3-0cc068a8e46an@googlegroups.com>
<u297es$vqbb$2@dont-email.me> <u297u5$vv76$1@dont-email.me>
<8c0be45e-8528-4a79-afa9-34d5eb8fcc3cn@googlegroups.com>
<47b33d6d-c36f-4448-ba9a-3ae25c6ac5b1n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net fBr8frCiTLTXK13s4jPz6A3+n4sv/fi7MDYBjkMSTHpprfqjY=
Cancel-Lock: sha1:GdUAWapSLCRprd+g7CDHOS2VlWA= sha1:n7EZD0o+HMqthTPyrR9V50zdJcs=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Wed, 26 Apr 2023 08:55 UTC

* Lawrence Emke <lawrence.emke@gmail.com>
| > I have tried several configurations in proc calls. None of them work.
--<snip-snip>--
| > If I am not clear in my response, let me know.

Generally when asking for help, it is advisable to show what you have
tried so far, what the results were, and what you expect them to
be. (copy/paste the code, do *not* type it in the message again,
copy/paste the results, do *not* paraphrase them in the message).

That way another person might catch a coding error or suggest an
alternate solution. You know it how it is: as soon as the administrator
looks over your shoulder... ;-)

HTH
R'

Re: Reference to dictionary variable name in dict commands seems inconsistent

<2fa90bf6-844f-48a2-b22d-f020183a6da2n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12370&group=comp.lang.tcl#12370

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ae9:e713:0:b0:74d:e887:167 with SMTP id m19-20020ae9e713000000b0074de8870167mr4816249qka.10.1682548542291;
Wed, 26 Apr 2023 15:35:42 -0700 (PDT)
X-Received: by 2002:ae9:c10c:0:b0:74e:2de8:c802 with SMTP id
z12-20020ae9c10c000000b0074e2de8c802mr4783213qki.9.1682548542138; Wed, 26 Apr
2023 15:35:42 -0700 (PDT)
Path: rocksolid2!i2pn.org!usenet.blueworldhosting.com!diablo1.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, 26 Apr 2023 15:35:41 -0700 (PDT)
In-Reply-To: <fb8ebf20-d565-49a5-b0f3-0cc068a8e46an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=190.31.8.142; posting-account=16hMVAoAAADREx1E2sS7dQoH2B688EVR
NNTP-Posting-Host: 190.31.8.142
References: <fb8ebf20-d565-49a5-b0f3-0cc068a8e46an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2fa90bf6-844f-48a2-b22d-f020183a6da2n@googlegroups.com>
Subject: Re: Reference to dictionary variable name in dict commands seems inconsistent
From: emilianogavilan@gmail.com (Emiliano)
Injection-Date: Wed, 26 Apr 2023 22:35:42 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2554
 by: Emiliano - Wed, 26 Apr 2023 22:35 UTC

El martes, 25 de abril de 2023 a las 15:26:20 UTC-3, Lawrence Emke escribió:
> I understand the syntax to create a dict variable:
> set dname [ dict create a b ]
> Now compare these two commands:
>
> dict append dname d e
> and
> dict get $dname d
>
> in the first case the dict name does not require the de-reference $ character.
> In the second command it does require the deference $ character.
>
> This seems to be confusing. Don't force me to remember which case requires the de-reference $ character and which does not accept the $ character.
>
> Maybe there is a hidden explanation (reason) other than the implementation of the command that does not just pop up to a new student. Please make it consistent. It will save time and effort to learn the language syntax.

A good rule of thumb is that if the command has
* "set" (set, unset, dict set, dict unset, array set, array unset, lset),
* "append" (append, lappend, dict append, dict lappend)
* "incr" (incr, dict incr)
in its name, then it takes a *variable name* as argument.

The "inconsistent" commands that break these "rules" are [array get], [dict update]
and [dict with]. Also [lpop], which is a new command in the upcoming 8.7 release.

Hope this helps

Emiliano

Re: Reference to dictionary variable name in dict commands seems inconsistent

<u2cdls$1j79f$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12371&group=comp.lang.tcl#12371

  copy link   Newsgroups: comp.lang.tcl
Path: rocksolid2!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: Reference to dictionary variable name in dict commands seems
inconsistent
Date: Wed, 26 Apr 2023 16:55:40 -0700
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <u2cdls$1j79f$1@dont-email.me>
References: <fb8ebf20-d565-49a5-b0f3-0cc068a8e46an@googlegroups.com>
<2fa90bf6-844f-48a2-b22d-f020183a6da2n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 26 Apr 2023 23:55:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="83ed5d94db8b66d4cd97b60c84b9f124";
logging-data="1678639"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SeZto024v/PjJYn2Yrezn"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:ctBG9tJltv+q+ltSA8aOl3c0pZE=
Content-Language: en-US
In-Reply-To: <2fa90bf6-844f-48a2-b22d-f020183a6da2n@googlegroups.com>
 by: et99 - Wed, 26 Apr 2023 23:55 UTC

On 4/26/2023 3:35 PM, Emiliano wrote:
> El martes, 25 de abril de 2023 a las 15:26:20 UTC-3, Lawrence Emke escribió:
>> I understand the syntax to create a dict variable:
>> set dname [ dict create a b ]
>> Now compare these two commands:
>>
>> dict append dname d e
>> and
>> dict get $dname d
>>
>> in the first case the dict name does not require the de-reference $ character.
>> In the second command it does require the deference $ character.
>>
>> This seems to be confusing. Don't force me to remember which case requires the de-reference $ character and which does not accept the $ character.
>>
>> Maybe there is a hidden explanation (reason) other than the implementation of the command that does not just pop up to a new student. Please make it consistent. It will save time and effort to learn the language syntax.
>
> A good rule of thumb is that if the command has
> * "set" (set, unset, dict set, dict unset, array set, array unset, lset),
> * "append" (append, lappend, dict append, dict lappend)
> * "incr" (incr, dict incr)
> in its name, then it takes a *variable name* as argument.
>
> The "inconsistent" commands that break these "rules" are [array get], [dict update]
> and [dict with]. Also [lpop], which is a new command in the upcoming 8.7 release.
>
> Hope this helps
>
> Emiliano

One of my favorite features about tcl is the console for doing
testing. Nearly all (some exceptions) commands can provide a very
useful 1 line summary as an error message. And to get a brief summary
of subcommands, just enter the command and something like zzz.

If it says ....Name then you supply the name of a variable. Easy Peasy.

1 % dict append
wrong # args: should be "dict append dictVarName key ?value ...?"
2 % lappend
wrong # args: should be "lappend varName ?value ...?"
3 % lindex
wrong # args: should be "lindex list ?index ...?"
4 % dict
wrong # args: should be "dict subcommand ?arg ...?"
5 % dict zzz
unknown or ambiguous subcommand "zzz": must be append, create, exists, filter, for, get, incr, info, keys, lappend, map, merge, remove, replace, set, size, unset, update, values, or with


devel / comp.lang.tcl / Re: Reference to dictionary variable name in dict commands seems inconsistent

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor