Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

[It is] best to confuse only one issue at a time. -- K&R


devel / comp.lang.tcl / indented parray-output ;-)

SubjectAuthor
* indented parray-output ;-)Andreas Leitgeb
+* indented parray-output ;-)et99
|`* indented parray-output ;-)Andreas Leitgeb
| `* indented parray-output ;-)Alan Grunwald
|  +* indented parray-output ;-)heinrichmartin
|  |`* indented parray-output ;-)Alan Grunwald
|  | `* indented parray-output ;-)Andreas Leitgeb
|  |  `- indented parray-output ;-)et99
|  `* indented parray-output ;-)saitology9
|   `* indented parray-output ;-)Christian Gollwitzer
|    `* indented parray-output ;-)saitology9
|     `- indented parray-output ;-)et99
+* indented parray-output ;-)Rolf Ade
|`* indented parray-output ;-)Rich
| `- indented parray-output ;-)Andreas Leitgeb
`- indented parray-output ;-)The Rickster

1
indented parray-output ;-)

<slrntu5tie.1v30n.avl@logic.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: avl...@logic.at (Andreas Leitgeb)
Newsgroups: comp.lang.tcl
Subject: indented parray-output ;-)
Date: Wed, 8 Feb 2023 01:09:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <slrntu5tie.1v30n.avl@logic.at>
Reply-To: avl@logic.at
Injection-Date: Wed, 8 Feb 2023 01:09:34 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="9e2b96a5fe6405aa1750b335b0833504";
logging-data="4147485"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19FLPgKfLQILef8enHKFrjZ"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:MELKUZd5z/LIRzei8/k+Y7oPY6U=
 by: Andreas Leitgeb - Wed, 8 Feb 2023 01:09 UTC

I wanted to include "parray" output in a report (on stdout),
but I needed it indented by a given string before each line.

The trick was rather simple in hindsight:

proc ind_parray {ind arr} {
upvar 1 $arr "$ind$arr"; parray "$ind$arr"
}

It works well for pure whitespace-indentations, and probably
most others as long as $ind doesn't contain "::" .

Just thought I'd share.

Re: indented parray-output ;-)

<trv7m9$16bt$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: et9...@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: indented parray-output ;-)
Date: Tue, 7 Feb 2023 20:16:09 -0800
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <trv7m9$16bt$1@dont-email.me>
References: <slrntu5tie.1v30n.avl@logic.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 8 Feb 2023 04:16:09 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="9b43c47c32ab8200c929abd0d45f0b50";
logging-data="39293"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WJL4IYzTH16mjij89ihkb"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:xTcq5FYG7uunDTLOKibppIAp9tI=
In-Reply-To: <slrntu5tie.1v30n.avl@logic.at>
Content-Language: en-US
 by: et99 - Wed, 8 Feb 2023 04:16 UTC

On 2/7/2023 5:09 PM, Andreas Leitgeb wrote:
> I wanted to include "parray" output in a report (on stdout),
> but I needed it indented by a given string before each line.
>
> The trick was rather simple in hindsight:
>
> proc ind_parray {ind arr} {
> upvar 1 $arr "$ind$arr"; parray "$ind$arr"
> }
>
> It works well for pure whitespace-indentations, and probably
> most others as long as $ind doesn't contain "::" .
>
> Just thought I'd share.

I too often use parray, and since it's easily modified (it's
autoloaded and found in tcl86/lib along with a few other commands) I
change it to use a -dictionary sort by default. I find that works
better when the indices are numerical, and alpha when not.

I wrote up a ticket once, since IMHO it is an oversight not to use a
dictionary sort and found a TIP to be a bit overkill.

My modified version changes the arglist to:

proc parray {a {pattern *} {type -dictionary}} {

and the lsort to:

set names [lsort {*}$type [array names array $pattern]]

which then allows for such things as -ascii or {-ascii -decreasing}
at the small cost of requiring the * if you still want that.

Re: indented parray-output ;-)

<87cz6jr4d8.fsf@pointsman.de>

  copy mid

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

  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: rol...@pointsman.de (Rolf Ade)
Newsgroups: comp.lang.tcl
Subject: Re: indented parray-output ;-)
Date: Thu, 09 Feb 2023 02:53:39 +0100
Organization: Me
Lines: 18
Message-ID: <87cz6jr4d8.fsf@pointsman.de>
References: <slrntu5tie.1v30n.avl@logic.at>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net epLSxF1J9k95EcfC7LsqJQ59LpAHhM2KDHoNoA13NuJYXhM54=
Cancel-Lock: sha1:vdCNC7Z7TlaUCOWKzn+ihX3fVpE= sha1:VJSzmIr+QJYcQrpi/Im2H5uMFxA=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
 by: Rolf Ade - Thu, 9 Feb 2023 01:53 UTC

Andreas Leitgeb <avl@logic.at> writes:
> I wanted to include "parray" output in a report (on stdout),
> but I needed it indented by a given string before each line.
>
> The trick was rather simple in hindsight:
>
> proc ind_parray {ind arr} {
> upvar 1 $arr "$ind$arr"; parray "$ind$arr"
> }
>
> It works well for pure whitespace-indentations, and probably
> most others as long as $ind doesn't contain "::" .
>
> Just thought I'd share.

But .. I don't get it? Could you please elaborate a bit more what do you
do here?

Re: indented parray-output ;-)

<ts1q5l$hp6i$1@dont-email.me>

  copy mid

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

  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: indented parray-output ;-)
Date: Thu, 9 Feb 2023 03:43:49 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <ts1q5l$hp6i$1@dont-email.me>
References: <slrntu5tie.1v30n.avl@logic.at> <87cz6jr4d8.fsf@pointsman.de>
Injection-Date: Thu, 9 Feb 2023 03:43:49 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="2e37d4293c77be2de6a54947c358794e";
logging-data="582866"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wAEnwKhcQsAEVw2/MYCTH"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:hM77+4uMiVoHsm0di1K9XMlti+w=
 by: Rich - Thu, 9 Feb 2023 03:43 UTC

Rolf Ade <rolf@pointsman.de> wrote:
>
> Andreas Leitgeb <avl@logic.at> writes:
>> I wanted to include "parray" output in a report (on stdout),
>> but I needed it indented by a given string before each line.
>>
>> The trick was rather simple in hindsight:
>>
>> proc ind_parray {ind arr} {
>> upvar 1 $arr "$ind$arr"; parray "$ind$arr"
>> }
>>
>> It works well for pure whitespace-indentations, and probably
>> most others as long as $ind doesn't contain "::" .
>>
>> Just thought I'd share.
>
> But .. I don't get it? Could you please elaborate a bit more what do you
> do here?

Inside the proc ind_parray the array variable that is being printed is
linked to a new name, that new name being the concatenation of an
"indent string" ($ind - presumably usually spaces or a few ASCII tabs
would be the usual content) and the origional array name from the
caller ($arr).

Then parray is called to "print" this new variable name.

Since the new name has the indent string prefixed, the array names
output from parray come out "spaced over" from where they would
otherwise be:

$ rlwrap tclsh
% parray tcl_platform
tcl_platform(byteOrder) = littleEndian
...

% ind_parray " " tcl_platform
tcl_platform(byteOrder) = littleEndian
...

Indent string can be just about anything, other than containing a :: or
[] sequence:

% ind_parray "Mary Had A Little Lamb " tcl_platform
Mary Had A Little Lamb tcl_platform(byteOrder) = littleEndian
...

% ind_parray " { } [ ] $ " tcl_platform
{ } $ tcl_platform(byteOrder) = littleEndian
...

Re: indented parray-output ;-)

<be4d80a7-f823-4edf-80e2-b9e6e4df2125n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a37:511:0:b0:71d:9c4c:3ed2 with SMTP id 17-20020a370511000000b0071d9c4c3ed2mr1664459qkf.11.1676051092831;
Fri, 10 Feb 2023 09:44:52 -0800 (PST)
X-Received: by 2002:a25:2188:0:b0:803:19fa:2c20 with SMTP id
h130-20020a252188000000b0080319fa2c20mr1456802ybh.207.1676051092518; Fri, 10
Feb 2023 09:44:52 -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: Fri, 10 Feb 2023 09:44:52 -0800 (PST)
In-Reply-To: <slrntu5tie.1v30n.avl@logic.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2603:8001:b5f0:88f0:8889:1157:bfe0:601e;
posting-account=a7bcHgoAAADQ0akqIyRQmxfQdEEZtAt5
NNTP-Posting-Host: 2603:8001:b5f0:88f0:8889:1157:bfe0:601e
References: <slrntu5tie.1v30n.avl@logic.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <be4d80a7-f823-4edf-80e2-b9e6e4df2125n@googlegroups.com>
Subject: Re: indented parray-output ;-)
From: sled99...@gmail.com (The Rickster)
Injection-Date: Fri, 10 Feb 2023 17:44:52 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1717
 by: The Rickster - Fri, 10 Feb 2023 17:44 UTC

On Tuesday, February 7, 2023 at 5:09:38 PM UTC-8, Andreas Leitgeb wrote:
> I wanted to include "parray" output in a report (on stdout),
> but I needed it indented by a given string before each line.
>
> The trick was rather simple in hindsight:
>
> proc ind_parray {ind arr} {
> upvar 1 $arr "$ind$arr"; parray "$ind$arr"
> }
>
> It works well for pure whitespace-indentations, and probably
> most others as long as $ind doesn't contain "::" .
>
> Just thought I'd share.
Andreas,
Simple and useful. Clever, thanks...and doesn't require 6000 scrollable text boxes {;-)

Re: indented parray-output ;-)

<slrntui2mb.1v30n.avl@logic.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: avl...@logic.at (Andreas Leitgeb)
Newsgroups: comp.lang.tcl
Subject: Re: indented parray-output ;-)
Date: Sun, 12 Feb 2023 15:50:35 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <slrntui2mb.1v30n.avl@logic.at>
References: <slrntu5tie.1v30n.avl@logic.at> <87cz6jr4d8.fsf@pointsman.de>
<ts1q5l$hp6i$1@dont-email.me>
Reply-To: avl@logic.at
Injection-Date: Sun, 12 Feb 2023 15:50:35 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="0dbf5d6ed1a17fd988692d3c56603987";
logging-data="1915545"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18FAxyYAKgALZqXKqotsWcl"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:8RgH6o7CKo+/y8wR/cFUD6QMPEs=
 by: Andreas Leitgeb - Sun, 12 Feb 2023 15:50 UTC

> Rolf Ade <rolf@pointsman.de> wrote:
>> Andreas Leitgeb <avl@logic.at> writes:
>>> I wanted to include "parray" output in a report (on stdout),
>>> but I needed it indented by a given string before each line.
>>> The trick was rather simple in hindsight:
>>> proc ind_parray {ind arr} {
>>> upvar 1 $arr "$ind$arr"; parray "$ind$arr"
>>> }
>>> It works well for pure whitespace-indentations, and probably
>>> most others as long as $ind doesn't contain "::" .
>> But .. I don't get it? Could you please elaborate a bit more what do you
>> do here?

My specific context was parsing pdf-files - which contain data structures
similar to dict values. I then turn them into an array and use my indenting
parray wrapper to print the array out to stdout. Depending on where exactly
the dict occurred in the pdf (i.e.: maybe nested) I want it indented.

Rich <rich@example.invalid> wrote:
> Indent string can be just about anything, other than containing a :: or
> [] sequence:

Rich, regarding [ ] you got confused over Tcl's parsing rules...

> % ind_parray " { } [ ] $ " tcl_platform
> { } $ tcl_platform(byteOrder) = littleEndian

The "[ ]" inside the double-quoted string got substed away, even before
ind_parray got to see it.

The only thing that really must not occur in the indent is "::",
as that would let the array appear to be in a namespace.

Originally, I expected open parentheses "(" to cause problems, but that
isn't the case... unless the original array name itself ends in ")",
which it easily could ;-)

Re: indented parray-output ;-)

<slrntui3fp.1v30n.avl@logic.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: avl...@logic.at (Andreas Leitgeb)
Newsgroups: comp.lang.tcl
Subject: Re: indented parray-output ;-)
Date: Sun, 12 Feb 2023 16:04:09 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <slrntui3fp.1v30n.avl@logic.at>
References: <slrntu5tie.1v30n.avl@logic.at> <trv7m9$16bt$1@dont-email.me>
Reply-To: avl@logic.at
Injection-Date: Sun, 12 Feb 2023 16:04:09 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="0dbf5d6ed1a17fd988692d3c56603987";
logging-data="1915545"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+EPNJqMzLqMwHmRzpJRFWQ"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:FjUvwvEF9+fmI4A5Ov/Dn+nSd0A=
 by: Andreas Leitgeb - Sun, 12 Feb 2023 16:04 UTC

et99 <et99@rocketship1.me> wrote:
> I too often use parray, and since it's easily modified (it's
> autoloaded and found in tcl86/lib along with a few other commands) I
> change it to use a -dictionary sort by default. I find that works
> better when the indices are numerical, and alpha when not.
>
> I wrote up a ticket once, since IMHO it is an oversight not to use a
> dictionary sort

I agree.
Purely integral array indices are probably quite common in practice.

> and found a TIP to be a bit overkill.

I disagree. At least it's not overkill for the following
extended suggestion:

> My modified version changes the arglist to:
> proc parray {a {pattern *} {type -dictionary}} {
> and the lsort to:
> set names [lsort {*}$type [array names array $pattern]]
> which then allows for such things as -ascii or {-ascii -decreasing}
> at the small cost of requiring the * if you still want that.

and I'd also welcome another option for indentation ;-)

Re: indented parray-output ;-)

<tsdb5c$2562a$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: nospam.n...@gmail.com (Alan Grunwald)
Newsgroups: comp.lang.tcl
Subject: Re: indented parray-output ;-)
Date: Mon, 13 Feb 2023 12:41:16 +0000
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <tsdb5c$2562a$1@dont-email.me>
References: <slrntu5tie.1v30n.avl@logic.at> <trv7m9$16bt$1@dont-email.me>
<slrntui3fp.1v30n.avl@logic.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 13 Feb 2023 12:41:16 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="ef1b051cbaec40b331b741220c46d163";
logging-data="2267210"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18K4zcvenMRhb6b3UziUvToxPP9XP+AQzo="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Cancel-Lock: sha1:LIwK9BOx5+hRWGExNLkL8VqThc8=
Content-Language: en-US
In-Reply-To: <slrntui3fp.1v30n.avl@logic.at>
 by: Alan Grunwald - Mon, 13 Feb 2023 12:41 UTC

On 12/02/2023 16:04, Andreas Leitgeb wrote:
> et99 <et99@rocketship1.me> wrote:
>> I too often use parray, and since it's easily modified (it's
>> autoloaded and found in tcl86/lib along with a few other commands) I
>> change it to use a -dictionary sort by default. I find that works
>> better when the indices are numerical, and alpha when not.
>>
>> I wrote up a ticket once, since IMHO it is an oversight not to use a
>> dictionary sort
>
> I agree.
> Purely integral array indices are probably quite common in practice.
>
>> and found a TIP to be a bit overkill.
>
> I disagree. At least it's not overkill for the following
> extended suggestion:
>
>> My modified version changes the arglist to:
>> proc parray {a {pattern *} {type -dictionary}} {
>> and the lsort to:
>> set names [lsort {*}$type [array names array $pattern]]
>> which then allows for such things as -ascii or {-ascii -decreasing}
>> at the small cost of requiring the * if you still want that.
>
> and I'd also welcome another option for indentation ;-)
>
If you're putting together a TIP, I'd welcome an argument to specify an
output script, making the calling sequence

proc parray {a {pattern *} {type -dictionary} {script {puts stdout}}}

Re: indented parray-output ;-)

<2335edf4-3ec7-410b-94f6-1ecb7bbbcd32n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:5896:0:b0:3b9:b2cd:388b with SMTP id t22-20020ac85896000000b003b9b2cd388bmr3031925qta.35.1676296501382;
Mon, 13 Feb 2023 05:55:01 -0800 (PST)
X-Received: by 2002:a25:2188:0:b0:803:19fa:2c20 with SMTP id
h130-20020a252188000000b0080319fa2c20mr1994750ybh.207.1676296501170; Mon, 13
Feb 2023 05:55:01 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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: Mon, 13 Feb 2023 05:55:00 -0800 (PST)
In-Reply-To: <tsdb5c$2562a$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=84.115.227.68; posting-account=Od2xOAoAAACEyRX3Iu5rYt4oevuoeYUG
NNTP-Posting-Host: 84.115.227.68
References: <slrntu5tie.1v30n.avl@logic.at> <trv7m9$16bt$1@dont-email.me>
<slrntui3fp.1v30n.avl@logic.at> <tsdb5c$2562a$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2335edf4-3ec7-410b-94f6-1ecb7bbbcd32n@googlegroups.com>
Subject: Re: indented parray-output ;-)
From: martin.h...@frequentis.com (heinrichmartin)
Injection-Date: Mon, 13 Feb 2023 13:55:01 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3008
 by: heinrichmartin - Mon, 13 Feb 2023 13:55 UTC

On Monday, February 13, 2023 at 1:41:20 PM UTC+1, Alan Grunwald wrote:
> On 12/02/2023 16:04, Andreas Leitgeb wrote:
> > et99 wrote:
> >> I too often use parray, and since it's easily modified (it's
> >> autoloaded and found in tcl86/lib along with a few other commands) I
> >> change it to use a -dictionary sort by default. I find that works
> >> better when the indices are numerical, and alpha when not.
> >>
> >> I wrote up a ticket once, since IMHO it is an oversight not to use a
> >> dictionary sort
> >
> > I agree.
> > Purely integral array indices are probably quite common in practice.
> >
> >> and found a TIP to be a bit overkill.
> >
> > I disagree. At least it's not overkill for the following
> > extended suggestion:
> >
> >> My modified version changes the arglist to:
> >> proc parray {a {pattern *} {type -dictionary}} {
> >> and the lsort to:
> >> set names [lsort {*}$type [array names array $pattern]]
> >> which then allows for such things as -ascii or {-ascii -decreasing}
> >> at the small cost of requiring the * if you still want that.
> >
> > and I'd also welcome another option for indentation ;-)
> >
> If you're putting together a TIP, I'd welcome an argument to specify an
> output script, making the calling sequence
>
> proc parray {a {pattern *} {type -dictionary} {script {puts stdout}}}

Looking to balance cost for effort, isn't that asking for a wrapper to the example of the array command?

foreach {color count} [array get colorcount] {
puts "Color: $color Count: $count"
}

I'd understand optional {channelId stdout} - and I would still warn about bad experience with this many optional positional parameters, i.e. I'd prefer switches.

parray -dictionary -format {Color: %10s Count: %10s} -chan stderr colorcount

Re: indented parray-output ;-)

<tsduf0$273sd$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: saitolo...@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: indented parray-output ;-)
Date: Mon, 13 Feb 2023 13:10:38 -0500
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <tsduf0$273sd$1@dont-email.me>
References: <slrntu5tie.1v30n.avl@logic.at> <trv7m9$16bt$1@dont-email.me>
<slrntui3fp.1v30n.avl@logic.at> <tsdb5c$2562a$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 13 Feb 2023 18:10:40 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="01de9f30ab11e2773661cc5c986fda58";
logging-data="2330509"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KIRQLEpPABA5V7wKk347O"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.3.2
Cancel-Lock: sha1:mNEXH+mjFVsXqll5PhoGP+oS9vs=
In-Reply-To: <tsdb5c$2562a$1@dont-email.me>
Content-Language: en-US
 by: saitology9 - Mon, 13 Feb 2023 18:10 UTC

On 2/13/2023 7:41 AM, Alan Grunwald wrote:

> If you're putting together a TIP, I'd welcome an argument to specify an
> output script, making the calling sequence
>
> proc parray {a {pattern *} {type -dictionary} {script {puts stdout}}}
>
>

Not mentioned yet but for me a major inconvenience with parray is that
it is not copy-paste ready. If you are using parray, most likely you are
interested in the contents of an element or a list. And almost always
you'd want to update it with some changes. Here comes the trouble: you
need to type "set ", copy-paste the array variable name, skip over the
"=", and copy paste the value and make changes to it. Since the value is
stripped off its braces, you will need to be a bit careful about
including those as well. In other words, its output is not "source"-able
and requires editing.

Re: indented parray-output ;-)

<tsdula$273cm$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: aurio...@gmx.de (Christian Gollwitzer)
Newsgroups: comp.lang.tcl
Subject: Re: indented parray-output ;-)
Date: Mon, 13 Feb 2023 19:14:02 +0100
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <tsdula$273cm$1@dont-email.me>
References: <slrntu5tie.1v30n.avl@logic.at> <trv7m9$16bt$1@dont-email.me>
<slrntui3fp.1v30n.avl@logic.at> <tsdb5c$2562a$1@dont-email.me>
<tsduf0$273sd$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 13 Feb 2023 18:14:02 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="a61cf76fe7ba676d108151a2a0c0c235";
logging-data="2330006"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+HFHkC1YzBe256bwkC+8b7x99pXOvxkj0="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.7.2
Cancel-Lock: sha1:lby0hJeLF906dbwOXgnyZne1JD0=
In-Reply-To: <tsduf0$273sd$1@dont-email.me>
 by: Christian Gollwitzer - Mon, 13 Feb 2023 18:14 UTC

Am 13.02.23 um 19:10 schrieb saitology9:
> On 2/13/2023 7:41 AM, Alan Grunwald wrote:
>
>> If you're putting together a TIP, I'd welcome an argument to specify
>> an output script, making the calling sequence
>>
>> proc parray {a {pattern *} {type -dictionary} {script {puts stdout}}}
>>
>>
>
> Not mentioned yet but for me a major inconvenience with parray is that
> it is not copy-paste ready. If you are using parray, most likely you are
> interested in the contents of an element or a list. And almost always
> you'd want to update it with some changes. Here comes the trouble: you
> need to type "set ", copy-paste the array variable name, skip over the [....]

Use tkcon. Then you say "edit <varname>" and a window pops up with an
editable version. By choosing "Send to slave" from the menu, it will be
updated in the interpreter. The nice thing is that it works with procs,
arrays and ordinary variables.

Christian

Re: indented parray-output ;-)

<tse7vs$286uv$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: saitolo...@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: indented parray-output ;-)
Date: Mon, 13 Feb 2023 15:53:14 -0500
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <tse7vs$286uv$1@dont-email.me>
References: <slrntu5tie.1v30n.avl@logic.at> <trv7m9$16bt$1@dont-email.me>
<slrntui3fp.1v30n.avl@logic.at> <tsdb5c$2562a$1@dont-email.me>
<tsduf0$273sd$1@dont-email.me> <tsdula$273cm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 13 Feb 2023 20:53:16 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="01de9f30ab11e2773661cc5c986fda58";
logging-data="2366431"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Pkb/4/Qh20uWecvSxII+V"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.3.2
Cancel-Lock: sha1:RzjPAcAUda8PcbZkBexcYhHv8VM=
In-Reply-To: <tsdula$273cm$1@dont-email.me>
Content-Language: en-US
 by: saitology9 - Mon, 13 Feb 2023 20:53 UTC

On 2/13/2023 1:14 PM, Christian Gollwitzer wrote:

>
> Use tkcon. Then you say "edit <varname>" and a window pops up with an
> editable version. By choosing "Send to slave" from the menu, it will be
> updated in the interpreter. The nice thing is that it works with procs,
> arrays and ordinary variables.
>

Nice! It still requires editing if you need to change one item only but
I can see it being quite useful.

Re: indented parray-output ;-)

<tse8ou$2898j$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: et9...@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: indented parray-output ;-)
Date: Mon, 13 Feb 2023 13:06:38 -0800
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <tse8ou$2898j$1@dont-email.me>
References: <slrntu5tie.1v30n.avl@logic.at> <trv7m9$16bt$1@dont-email.me>
<slrntui3fp.1v30n.avl@logic.at> <tsdb5c$2562a$1@dont-email.me>
<tsduf0$273sd$1@dont-email.me> <tsdula$273cm$1@dont-email.me>
<tse7vs$286uv$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 13 Feb 2023 21:06:38 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="6b8d7602919761a9376a390a24c82156";
logging-data="2368787"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18pE2OQgsQUPuL5qgK0C1aZ"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:CNW00WNs2Sg8nryrvPUnqZbf8WY=
Content-Language: en-US
In-Reply-To: <tse7vs$286uv$1@dont-email.me>
 by: et99 - Mon, 13 Feb 2023 21:06 UTC

On 2/13/2023 12:53 PM, saitology9 wrote:
> On 2/13/2023 1:14 PM, Christian Gollwitzer wrote:
>
>>
>> Use tkcon. Then you say "edit <varname>" and a window pops up with an editable version. By choosing "Send to slave" from the menu, it will be updated in the interpreter. The nice thing is that it works with procs, arrays and ordinary variables.
>>
>
> Nice! It still requires editing if you need to change one item only but I can see it being quite useful.
>


I felt a TIP was overkill since the parray code is so easily
modified being just 18 lines long. I also think most TIP
voters would also just say use tkcon. Something TIP worthy should
probably be an ensemble of debug listing commands, which is
how I use parray.

I actually shorten it to [la] and it's one of my set of [l?]
commands for listing globals, lists, arrays, dicts, procedure
bodies, widgets, etc. My [la] version also can match against
the value or the indices, and output either matches or non-
matches.

With any new release, I begin with an Ashok tclkit with twapi
and gui, and create a starpak with my l? commands for
debugging. This way I can have many tcl (and twapi) versions
available if some change breaks my code (like when twapi
handles changed their format).

[lg] for globals, is actually my favorite. I first make a list
of all the initial global variables in the starpak init, and
then by default only list globals I've added afterwards. Very
handy for debugging the smallish programs I typically write to
script tedious windows gui actions using twapi.

Re: indented parray-output ;-)

<tsif9r$2seod$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: nospam.n...@gmail.com (Alan Grunwald)
Newsgroups: comp.lang.tcl
Subject: Re: indented parray-output ;-)
Date: Wed, 15 Feb 2023 11:22:35 +0000
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <tsif9r$2seod$1@dont-email.me>
References: <slrntu5tie.1v30n.avl@logic.at> <trv7m9$16bt$1@dont-email.me>
<slrntui3fp.1v30n.avl@logic.at> <tsdb5c$2562a$1@dont-email.me>
<2335edf4-3ec7-410b-94f6-1ecb7bbbcd32n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 15 Feb 2023 11:22:35 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="983292608d22216f3d0d696eac83431d";
logging-data="3029773"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19uwM9RpydBHz+8OdqGSA1oLb6enLRFE0c="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Cancel-Lock: sha1:znUns786ZU+IzD1LRBnfRjANz28=
In-Reply-To: <2335edf4-3ec7-410b-94f6-1ecb7bbbcd32n@googlegroups.com>
Content-Language: en-US
 by: Alan Grunwald - Wed, 15 Feb 2023 11:22 UTC

On 13/02/2023 13:55, heinrichmartin wrote:
> On Monday, February 13, 2023 at 1:41:20 PM UTC+1, Alan Grunwald wrote:
>> On 12/02/2023 16:04, Andreas Leitgeb wrote:
>>> et99 wrote:
>>>> I too often use parray, and since it's easily modified (it's
>>>> autoloaded and found in tcl86/lib along with a few other commands) I
>>>> change it to use a -dictionary sort by default. I find that works
>>>> better when the indices are numerical, and alpha when not.
>>>>
>>>> I wrote up a ticket once, since IMHO it is an oversight not to use a
>>>> dictionary sort
>>>
>>> I agree.
>>> Purely integral array indices are probably quite common in practice.
>>>
>>>> and found a TIP to be a bit overkill.
>>>
>>> I disagree. At least it's not overkill for the following
>>> extended suggestion:
>>>
>>>> My modified version changes the arglist to:
>>>> proc parray {a {pattern *} {type -dictionary}} {
>>>> and the lsort to:
>>>> set names [lsort {*}$type [array names array $pattern]]
>>>> which then allows for such things as -ascii or {-ascii -decreasing}
>>>> at the small cost of requiring the * if you still want that.
>>>
>>> and I'd also welcome another option for indentation ;-)
>>>
>> If you're putting together a TIP, I'd welcome an argument to specify an
>> output script, making the calling sequence
>>
>> proc parray {a {pattern *} {type -dictionary} {script {puts stdout}}}
>
> Looking to balance cost for effort, isn't that asking for a wrapper to the example of the array command?
>
> foreach {color count} [array get colorcount] {
> puts "Color: $color Count: $count"
> }
>
> I'd understand optional {channelId stdout} - and I would still warn about bad experience with this many optional positional parameters, i.e. I'd prefer switches.
>
> parray -dictionary -format {Color: %10s Count: %10s} -chan stderr colorcount
I agree that many optional parameters is a Bad Idea, and have no
objection to using switches.

I'd prefer

parray ... -output {whatever}

because at times you might wish to direct the output from parray to a
text widget or the like, rather than simply write it to a particular
channel.

Alan

Re: indented parray-output ;-)

<slrntuplri.1v30n.avl@logic.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: avl...@logic.at (Andreas Leitgeb)
Newsgroups: comp.lang.tcl
Subject: Re: indented parray-output ;-)
Date: Wed, 15 Feb 2023 13:00:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <slrntuplri.1v30n.avl@logic.at>
References: <slrntu5tie.1v30n.avl@logic.at> <trv7m9$16bt$1@dont-email.me>
<slrntui3fp.1v30n.avl@logic.at> <tsdb5c$2562a$1@dont-email.me>
<2335edf4-3ec7-410b-94f6-1ecb7bbbcd32n@googlegroups.com>
<tsif9r$2seod$1@dont-email.me>
Reply-To: avl@logic.at
Injection-Date: Wed, 15 Feb 2023 13:00:34 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="f7eea8389e339e87ca5402cba993b60c";
logging-data="3050771"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19cpodZNKD1jG9788auBdeX"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:HfisKBloDONERrz+R40mdq8ZzYo=
 by: Andreas Leitgeb - Wed, 15 Feb 2023 13:00 UTC

I'm afraid, I think this thread has gone a bit "out of control"...

I don't think, "parray" itself ought to be turned into a swiss army
knife tool, but maybe some parray-on-steroids could be added to tcllib...

If that happens, I would suggest using
https://wiki.tcl-lang.org/page/TclImplForNamedArguments
to do the argument parsing ;-) - Afterall it's pure Tcl.

Re: indented parray-output ;-)

<tsj4t4$2un4g$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: et9...@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: indented parray-output ;-)
Date: Wed, 15 Feb 2023 09:31:16 -0800
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <tsj4t4$2un4g$1@dont-email.me>
References: <slrntu5tie.1v30n.avl@logic.at> <trv7m9$16bt$1@dont-email.me>
<slrntui3fp.1v30n.avl@logic.at> <tsdb5c$2562a$1@dont-email.me>
<2335edf4-3ec7-410b-94f6-1ecb7bbbcd32n@googlegroups.com>
<tsif9r$2seod$1@dont-email.me> <slrntuplri.1v30n.avl@logic.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 15 Feb 2023 17:31:16 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="258498bb6df77f2aed07f7af125e410a";
logging-data="3103888"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UM6vHg/eMYtbKbjtsdUJx"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:nsaclhDMAXcjdJ2NZsz2FRWd7Hs=
Content-Language: en-US
In-Reply-To: <slrntuplri.1v30n.avl@logic.at>
 by: et99 - Wed, 15 Feb 2023 17:31 UTC

On 2/15/2023 5:00 AM, Andreas Leitgeb wrote:
> I'm afraid, I think this thread has gone a bit "out of control"...
>
> I don't think, "parray" itself ought to be turned into a swiss army
> knife tool, but maybe some parray-on-steroids could be added to tcllib...
>
I agree. I don't think I was clear; I was suggesting
that a new ensemble command like parray that would output
several types of info might be useful, not a
repurposing of parray itself.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor