Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"You need tender loving care once a week - so that I can slap you into shape." -- Ellyn Mustard


devel / comp.lang.tcl / Re: Jim Tcl: variables in namespace eval? sourcing non-regular files?

SubjectAuthor
* Jim Tcl: variables in namespace eval? sourcing non-regular files?Ivan Shmakov
+* Re: Jim Tcl: variables in namespace eval? sourcing non-regular files?Robert Heller
|`- Re: Jim Tcl: variables in namespace eval?Ivan Shmakov
`- Re: Jim Tcl: variables in namespace eval? sourcing non-regular files?Steve Bennett

1
Jim Tcl: variables in namespace eval? sourcing non-regular files?

<20220609194749.tbam4uufrfg6lgwv@violet.siamics.net>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!Qxabc7eGBd0F2DELua33IA.user.46.165.242.75.POSTED!not-for-mail
From: ivan@siamics.netREMOVE.invalid (Ivan Shmakov)
Newsgroups: comp.lang.tcl
Subject: Jim Tcl: variables in namespace eval? sourcing non-regular files?
Date: Thu, 9 Jun 2022 19:47:49 +0000
Organization: Aioe.org NNTP Server
Message-ID: <20220609194749.tbam4uufrfg6lgwv@violet.siamics.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: gioia.aioe.org; logging-data="9467"; posting-host="Qxabc7eGBd0F2DELua33IA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
License: CC0-1.0 (original contributions only)
X-Notice: Filtered by postfilter v. 0.9.2
Content-Disposition: inline
 by: Ivan Shmakov - Thu, 9 Jun 2022 19:47 UTC

I've recently stumbled on the different treatment of variables
in namespace eval body between Jim Tcl (as of 0.81 nb 1,
0.79 +dfsg0-2 and 0.77 +dfsg0-3 [1-3]) and Tcl 8.6.

[1] http://pkgsrc.se/lang/jimtcl
[2] http://packages.debian.org/bullseye/jimsh
[3] http://packages.debian.org/buster/jimsh

Namely, while namespace eval foo { set bar 42 } assigns to
the foo::bar variable in the latter, it appears like in Jim,
the same code rather modifies a variable local to the
namespace eval body itself; for instance, the following code
prints 42 in 8.6, but 1 in Jim:

namespace eval foo { } ; set foo::bar 1
namespace eval foo { set bar 42 }
puts [ set foo::bar ]

(It sure looks like that Jim likes its anonymous procedures
to a fault, or does it?)

Of course it's possible to namespace upvar in Jim (but not
in Tcl 8.6); and a workaround that appears to run the same
in either implementation is to introduce a separate "nset"
command:

proc nset { varn args } {
set p [ uplevel 1 { ::namespace current } ]
if { "::" ne $p } { append p :: }
## .
set ${p}$varn {*}$args
}

namespace eval foo { } ; set foo::bar 1
namespace eval foo { nset bar 42 } ; ## sets foo::bar in both Jim and 8.6
puts [ set foo::bar ] ; ## prints 42

Thoughts?

Another issue with Jim is that the 'source' command somehow
silently ignores non-regular files, such as pipes and character
specials. Same goes for such files passed as an argument to
the interpreter; for example:

bash$ jimsh <(printf %s\\n "puts 42")
bash$ tclsh8.6 <(printf %s\\n "puts 42")
42
bash$

Note that doing stat(2) on the /dev/fd/XX file (that is used
to implement Bash <() pipe) in the example above, identifies
the file as a pipe in Linux-based systems, but as a character
special in NetBSD (unless mount_fdesc(8) is in use, in which
case it is also identified as a pipe in this case.)

Is there any particular reason for such a behavior?

TIA.

--
FSF associate member #7257 http://am-1.org/~ivan/

Re: Jim Tcl: variables in namespace eval? sourcing non-regular files?

<WMOdnUwrEZTs_j__nZ2dnUU7-LPNnZ2d@giganews.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!buffer1.nntp.dca1.giganews.com!buffer2.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 09 Jun 2022 16:17:37 -0500
MIME-Version: 1.0
From: heller@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.12)
Subject: Re: Jim Tcl: variables in namespace eval? sourcing non-regular files?
In-Reply-To: <20220609194749.tbam4uufrfg6lgwv@violet.siamics.net>
References: <20220609194749.tbam4uufrfg6lgwv@violet.siamics.net>
Newsgroups: comp.lang.tcl
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <WMOdnUwrEZTs_j__nZ2dnUU7-LPNnZ2d@giganews.com>
Date: Thu, 09 Jun 2022 16:17:37 -0500
Lines: 85
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-IPSXH+B5jqu2CF6Lb4pmGCsjy2W32VGTbqlddetjZwjM3UEMUsD4REiRnRozRKj3kY1Y/oe4J3iFIzm!7u/I64vh2Ef8QqPsAtUTInVyQAzd4MbFFnEW86Xx5ftvkSrma33sgD2oxcdV2fTXqzmQcmAnTJ+/!Vkg=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 4075
 by: Robert Heller - Thu, 9 Jun 2022 21:17 UTC

At Thu, 9 Jun 2022 19:47:49 +0000 Ivan Shmakov <ivan@siamics.netREMOVE.invalid> wrote:

>
> I've recently stumbled on the different treatment of variables
> in namespace eval body between Jim Tcl (as of 0.81 nb 1,
> 0.79 +dfsg0-2 and 0.77 +dfsg0-3 [1-3]) and Tcl 8.6.
>
> [1] http://pkgsrc.se/lang/jimtcl
> [2] http://packages.debian.org/bullseye/jimsh
> [3] http://packages.debian.org/buster/jimsh
>
> Namely, while namespace eval foo { set bar 42 } assigns to
> the foo::bar variable in the latter, it appears like in Jim,
> the same code rather modifies a variable local to the
> namespace eval body itself; for instance, the following code
> prints 42 in 8.6, but 1 in Jim:
>
> namespace eval foo { } ; set foo::bar 1
> namespace eval foo { set bar 42 }

Do you really mean:

namespace eval foo {
variable bar
set bar 42
}

???

Wondering if the bug is not what you think it is.

Maybe Tcl 8.6, when it see "set foo::bar ...", it automagically implies a
namespace eval foo {variable bar} and Jim does not. (Not sure if that is a
bug in Jim or Tcl 8.6.)

> puts [ set foo::bar ]
>
> (It sure looks like that Jim likes its anonymous procedures
> to a fault, or does it?)
>
> Of course it's possible to namespace upvar in Jim (but not
> in Tcl 8.6); and a workaround that appears to run the same
> in either implementation is to introduce a separate "nset"
> command:
>
> proc nset { varn args } {
> set p [ uplevel 1 { ::namespace current } ]
> if { "::" ne $p } { append p :: }
> ## .
> set ${p}$varn {*}$args
> }
>
> namespace eval foo { } ; set foo::bar 1
> namespace eval foo { nset bar 42 } ; ## sets foo::bar in both Jim and 8.6
> puts [ set foo::bar ] ; ## prints 42
>
> Thoughts?
>
> Another issue with Jim is that the 'source' command somehow
> silently ignores non-regular files, such as pipes and character
> specials. Same goes for such files passed as an argument to
> the interpreter; for example:
>
> bash$ jimsh <(printf %s\\n "puts 42")
> bash$ tclsh8.6 <(printf %s\\n "puts 42")
> 42
> bash$
>
> Note that doing stat(2) on the /dev/fd/XX file (that is used
> to implement Bash <() pipe) in the example above, identifies
> the file as a pipe in Linux-based systems, but as a character
> special in NetBSD (unless mount_fdesc(8) is in use, in which
> case it is also identified as a pipe in this case.)
>
> Is there any particular reason for such a behavior?
>
> TIA.
>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

Re: Jim Tcl: variables in namespace eval?

<20220610015747.gzfnp6ajlznerm53@violet.siamics.net>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!Qxabc7eGBd0F2DELua33IA.user.46.165.242.75.POSTED!not-for-mail
From: ivan@siamics.netREMOVE.invalid (Ivan Shmakov)
Newsgroups: comp.lang.tcl
Subject: Re: Jim Tcl: variables in namespace eval?
Date: Fri, 10 Jun 2022 01:57:47 +0000
Organization: Aioe.org NNTP Server
Message-ID: <20220610015747.gzfnp6ajlznerm53@violet.siamics.net>
References: <20220609194749.tbam4uufrfg6lgwv@violet.siamics.net>
<WMOdnUwrEZTs_j__nZ2dnUU7-LPNnZ2d@giganews.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: gioia.aioe.org; logging-data="62313"; posting-host="Qxabc7eGBd0F2DELua33IA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Content-Disposition: inline
X-Notice: Filtered by postfilter v. 0.9.2
License: CC-BY-SA-3.0+ (original contributions only)
 by: Ivan Shmakov - Fri, 10 Jun 2022 01:57 UTC

>>>>> On 2022-06-09 16:17:37 -0500, Robert Heller wrote:
>>>>> At Thu, 9 Jun 2022 19:47:49 +0000 Ivan Shmakov wrote:

[...]

>> Namely, while namespace eval foo { set bar 42 } assigns to
>> the foo::bar variable in the latter, it appears like in Jim,
>> the same code rather modifies a variable local to the
>> namespace eval body itself; for instance, the following code
>> prints 42 in 8.6, but 1 in Jim:

>> namespace eval foo { } ; set foo::bar 1
>> namespace eval foo { set bar 42 }

> Do you really mean:

> namespace eval foo {
> variable bar
> set bar 42
> }

> ???

That's it; I've totally missed there needs to be a 'variable'
command! Somehow, it doesn't seem to be documented in Jim's
Tcl.html, which may be the reason why, to think of it.

Now I get the consistent behavior; thanks.

> Wondering if the bug is not what you think it is.

> Maybe Tcl 8.6, when it see "set foo::bar ...", it automagically
> implies a namespace eval foo {variable bar} and Jim does not.
> (Not sure if that is a bug in Jim or Tcl 8.6.)

No, the behavior of "set foo::bar ..." is entirely consistent
between Jim and 8.6: if the namespace variable named does not
exist, it's created. The only requirement is that the
namespace itself should exist; otherwise either the namespace
is silently created (Jim), or the command fails (Tcl 8.6.)

--
FSF associate member #7257 http://am-1.org/~ivan/

Re: Jim Tcl: variables in namespace eval? sourcing non-regular files?

<f2a7c1a7-c6ef-426e-85d8-d98f375edc1bn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:622a:3cd:b0:305:321b:c870 with SMTP id k13-20020a05622a03cd00b00305321bc870mr3199172qtx.190.1655199658573;
Tue, 14 Jun 2022 02:40:58 -0700 (PDT)
X-Received: by 2002:a4a:9731:0:b0:35e:fd1a:d452 with SMTP id
u46-20020a4a9731000000b0035efd1ad452mr1610220ooi.8.1655199658329; Tue, 14 Jun
2022 02:40:58 -0700 (PDT)
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: Tue, 14 Jun 2022 02:40:58 -0700 (PDT)
In-Reply-To: <20220609194749.tbam4uufrfg6lgwv@violet.siamics.net>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:8004:1140:42e5:d5a7:7bc2:976:9e05;
posting-account=sHuY2AoAAAA9mx5hjnXnz2DwduvHrVM8
NNTP-Posting-Host: 2001:8004:1140:42e5:d5a7:7bc2:976:9e05
References: <20220609194749.tbam4uufrfg6lgwv@violet.siamics.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f2a7c1a7-c6ef-426e-85d8-d98f375edc1bn@googlegroups.com>
Subject: Re: Jim Tcl: variables in namespace eval? sourcing non-regular files?
From: msteveb@gmail.com (Steve Bennett)
Injection-Date: Tue, 14 Jun 2022 09:40:58 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2207
 by: Steve Bennett - Tue, 14 Jun 2022 09:40 UTC

On Friday, June 10, 2022 at 5:48:02 AM UTC+10, Ivan Shmakov wrote:

>
> Another issue with Jim is that the 'source' command somehow
> silently ignores non-regular files, such as pipes and character
> specials. Same goes for such files passed as an argument to
> the interpreter; for example:
>
> bash$ jimsh <(printf %s\\n "puts 42")
> bash$ tclsh8.6 <(printf %s\\n "puts 42")
> 42
> bash$
>
> Note that doing stat(2) on the /dev/fd/XX file (that is used
> to implement Bash <() pipe) in the example above, identifies
> the file as a pipe in Linux-based systems, but as a character
> special in NetBSD (unless mount_fdesc(8) is in use, in which
> case it is also identified as a pipe in this case.)
>
> Is there any particular reason for such a behavior?

Jim stats the file, sees a size of zero and does nothing.
It would be possible to change that but it seems low value.
Perhaps send a patch to jimtcl on GitHub if you think is worth changing.

Cheers,
Steve

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor