Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Got Mole problems? Call Avogadro at 6.02 x 10^23.


devel / comp.lang.tcl / Re: Recommended way to import files?

SubjectAuthor
* Recommended way to import files?clt.to.davebr
`* Re: Recommended way to import files?Mark
 +* Re: Recommended way to import files?Mark
 |+- Re: Recommended way to import files?Ralf Fassel
 |`* Re: Recommended way to import files?Rich
 | `* Re: Recommended way to import files?Mark
 |  `* Re: Recommended way to import files?Mark
 |   `- Re: Recommended way to import files?Robert Heller
 +- Re: Recommended way to import files?Robert Heller
 `* Re: Recommended way to import files?pd
  +- Re: Recommended way to import files?Rich
  `- Re: Recommended way to import files?et99

1
Recommended way to import files?

<6801685628753@dlp>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: clt.to.davebr@dfgh.net
Newsgroups: comp.lang.tcl
Subject: Recommended way to import files?
Date: Thu, 01 Jun 23 14:12:33 GMT
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <6801685628753@dlp>
Injection-Info: dont-email.me; posting-host="d0f5ffbef48fc80126fbbc7d9f9ec79b";
logging-data="2962561"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HEJZpFkRI7dFx826QLke5"
Cancel-Lock: sha1:nK3c64ivknSlcF08byyDspW9Nh4=
 by: clt.to.davebr@dfgh.net - Thu, 1 Jun 2023 14:12 UTC

The fileutil package from tcllib has fullnormalize that handles all links in a path

package require fileutil
set ::APP_PATH [file dir [fileutil::fullnormalize [info script]]]

you might consider cd into the directory while loading resources:

set dir [pwd]
cd [file dir [fileutil::fullnormalize [info sript]]]
try {foreach fn {liba.tcl libb.tcl} {source $fn}} finally {cd $dir}

dave b

Re: Recommended way to import files?

<5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ad4:4e2b:0:b0:625:aa48:fb48 with SMTP id dm11-20020ad44e2b000000b00625aa48fb48mr1323684qvb.13.1685629679592;
Thu, 01 Jun 2023 07:27:59 -0700 (PDT)
X-Received: by 2002:a05:620a:430d:b0:75b:29ef:6ef3 with SMTP id
u13-20020a05620a430d00b0075b29ef6ef3mr2442908qko.1.1685629679082; Thu, 01 Jun
2023 07:27:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!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: Thu, 1 Jun 2023 07:27:58 -0700 (PDT)
In-Reply-To: <6801685628753@dlp>
Injection-Info: google-groups.googlegroups.com; posting-host=31.125.17.241; posting-account=C1gZvwoAAAAojE_ZgHdwZjGSuZg6QpNd
NNTP-Posting-Host: 31.125.17.241
References: <6801685628753@dlp>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com>
Subject: Re: Recommended way to import files?
From: m.n.summerfield@googlemail.com (Mark)
Injection-Date: Thu, 01 Jun 2023 14:27:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Mark - Thu, 1 Jun 2023 14:27 UTC

I read the docs for tm and they say "A Tcl Module is a Tcl Package contained in a single file, and no other files required by it". This seems a bit restrictive compared to the package approach. And anyway, I'm only really looking at how to spread an application over multiple files; all the tcl files are for the application, they're not self-contained as such.

Re: Recommended way to import files?

<1cdca509-8d2e-4cd9-bec2-a2a7afebf98bn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:1a9f:b0:75c:edf5:37da with SMTP id bl31-20020a05620a1a9f00b0075cedf537damr469352qkb.6.1685630222399;
Thu, 01 Jun 2023 07:37:02 -0700 (PDT)
X-Received: by 2002:a05:622a:1889:b0:3f7:f727:dee8 with SMTP id
v9-20020a05622a188900b003f7f727dee8mr2798431qtc.2.1685630222178; Thu, 01 Jun
2023 07:37:02 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!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: Thu, 1 Jun 2023 07:37:01 -0700 (PDT)
In-Reply-To: <5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=31.125.17.241; posting-account=C1gZvwoAAAAojE_ZgHdwZjGSuZg6QpNd
NNTP-Posting-Host: 31.125.17.241
References: <6801685628753@dlp> <5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1cdca509-8d2e-4cd9-bec2-a2a7afebf98bn@googlegroups.com>
Subject: Re: Recommended way to import files?
From: m.n.summerfield@googlemail.com (Mark)
Injection-Date: Thu, 01 Jun 2023 14:37:02 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Mark - Thu, 1 Jun 2023 14:37 UTC

I've now tried using modules and despite the docs it seems to work fine and requires one less file (no need for pkgIndex.tcl)

# file: myapp.tcl
tcl::tm::path add [file dirname [info script]]
package require app
app::main

# file: app-1.0.0.tm
package provide app 1.0
package require util
namespace eval app {}

proc app::main {} {
puts "app.tcl main [util::commas 1234567890]"
}

# file: util-1.0.0.tm
package provide util 1.0
namespace eval util {}

proc util::commas {x} {
regsub -all \\d(?=(\\d{3})+([regexp -inline {\.\d*$} $x]$)) $x {\0,}
}

Re: Recommended way to import files?

<fhednX5NU-5GLOX5nZ2dnZfqnPidnZ2d@giganews.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 01 Jun 2023 14:57:31 +0000
MIME-Version: 1.0
From: heller@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.15)
Subject: Re: Recommended way to import files?
In-Reply-To: <5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com>
References: <6801685628753@dlp>
<5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com>
Newsgroups: comp.lang.tcl
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <fhednX5NU-5GLOX5nZ2dnZfqnPidnZ2d@giganews.com>
Date: Thu, 01 Jun 2023 14:57:31 +0000
Lines: 36
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-8UdpvsjEBb2HXhx8bkClxrbl/Q0Pe0ZYX1swX6pLEvfSBYtpUCsRGXLfGf3Ps9SXs/qOIfCE546j89r!krEzsdQ4g8t2z+q3E9sdfXK8p5exc3T1Yh/E5TpvI1TEwiHWNP7SWQBA6+x0lTqoJqOXQiL11YkU!k3s=
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
 by: Robert Heller - Thu, 1 Jun 2023 14:57 UTC

At Thu, 1 Jun 2023 07:27:58 -0700 (PDT) Mark <m.n.summerfield@googlemail.com> wrote:

>

> I read the docs for tm and they say "A Tcl Module is a Tcl Package contained
> in a single file, and no other files required by it". This seems a bit
> restrictive compared to the package approach. And anyway, I'm only really
> looking at how to spread an application over multiple files; all the tcl
> files are for the application, they're not self-contained as such.

You can have a "master" .tm file, that source's any number of other files:

foo-1.2.3.tm:

set dir [file dirname [info script]]

source [file join $dir foo-a.tcl]
source [file join $dir foo-b.tcl]
source [file join $dir foo-c.tcl]

so

package require foo 1.2.3

will load foo-a.tcl, foo-b.tcl, and foo-c.tcl.

>
>

--
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: Recommended way to import files?

<ygaedmvb52k.fsf@akutech.de>

  copy mid

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

  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: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: Recommended way to import files?
Date: Thu, 01 Jun 2023 17:00:35 +0200
Lines: 7
Message-ID: <ygaedmvb52k.fsf@akutech.de>
References: <6801685628753@dlp>
<5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com>
<1cdca509-8d2e-4cd9-bec2-a2a7afebf98bn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net YvN36L/PVb3r5P6YVe9Edg99XH1pCjuDaLtiw5UQp6IU6FRRw=
Cancel-Lock: sha1:pmRaiyLd2HXwcntDmSRqbLSrcLs= sha1:frbEsYskoIxWLp5/o+1O3GRvILo=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Thu, 1 Jun 2023 15:00 UTC

* Mark <m.n.summerfield@googlemail.com>
| I've now tried using modules and despite the docs it seems to work
| fine and requires one less file (no need for pkgIndex.tcl)

Even better, thanks for sharing!

R'

Re: Recommended way to import files?

<u5ahjo$2r91q$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Recommended way to import files?
Date: Thu, 1 Jun 2023 16:39:20 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <u5ahjo$2r91q$1@dont-email.me>
References: <6801685628753@dlp> <5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com> <1cdca509-8d2e-4cd9-bec2-a2a7afebf98bn@googlegroups.com>
Injection-Date: Thu, 1 Jun 2023 16:39:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2e1b42c0ffb3bcc398f181960b2d840e";
logging-data="2991162"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Bqk/VDK5RrgdDIxFJECAc"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.19 (x86_64))
Cancel-Lock: sha1:9qcVyr4dKWqIB/gI4J9ET1FmKco=
 by: Rich - Thu, 1 Jun 2023 16:39 UTC

Mark <m.n.summerfield@googlemail.com> wrote:
> I've now tried using modules and despite the docs it seems to work fine and requires one less file (no need for pkgIndex.tcl)
>
> # file: myapp.tcl
> tcl::tm::path add [file dirname [info script]]
> package require app
> app::main
>
> # file: app-1.0.0.tm
> package provide app 1.0
> package require util
> namespace eval app {}
>
> proc app::main {} {
> puts "app.tcl main [util::commas 1234567890]"
> }
>
> # file: util-1.0.0.tm
> package provide util 1.0
> namespace eval util {}
>
> proc util::commas {x} {
> regsub -all \\d(?=(\\d{3})+([regexp -inline {\.\d*$} $x]$)) $x {\0,}
> }

As I just learned from a post a few hours ago, you don't need the
"package provide" lines inside module (.tm) files. So you could drop
those lines as well.

And you do not /need/ to make the main 'app' a module file (unless you
really want to do so). The /secondary/ files can be modules, and the
main app just a script that loads the modules.

Re: Recommended way to import files?

<26bd74dc-167c-4353-b531-cc6e2a95448en@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:8ed:b0:624:4608:22ec with SMTP id dr13-20020a05621408ed00b00624460822ecmr1597382qvb.4.1685643541800;
Thu, 01 Jun 2023 11:19:01 -0700 (PDT)
X-Received: by 2002:ac8:5f4d:0:b0:3f6:c440:77a5 with SMTP id
y13-20020ac85f4d000000b003f6c44077a5mr2760412qta.9.1685643541578; Thu, 01 Jun
2023 11:19:01 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!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: Thu, 1 Jun 2023 11:19:01 -0700 (PDT)
In-Reply-To: <u5ahjo$2r91q$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=31.125.17.241; posting-account=C1gZvwoAAAAojE_ZgHdwZjGSuZg6QpNd
NNTP-Posting-Host: 31.125.17.241
References: <6801685628753@dlp> <5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com>
<1cdca509-8d2e-4cd9-bec2-a2a7afebf98bn@googlegroups.com> <u5ahjo$2r91q$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <26bd74dc-167c-4353-b531-cc6e2a95448en@googlegroups.com>
Subject: Re: Recommended way to import files?
From: m.n.summerfield@googlemail.com (Mark)
Injection-Date: Thu, 01 Jun 2023 18:19:01 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Mark - Thu, 1 Jun 2023 18:19 UTC

Thanks for the help.

So now I'm still only using 3 files but with even less boilerplate than before. And this is a nice scalable solution.

# file: myapp.tcl # this is the "driver" the user runs: ./myapp.tcl
tcl::tm::path add [file dirname [info script]]
package require app
app::main

# file: app-1.0.0.tm # this is the application module for main
package require util
namespace eval app {}

proc app::main {} {
puts "app-1.0.0.tm main [util::commas 1234567890]"
}

# file: util-1.0.0.tm # this is a supporting module
namespace eval util {}

proc util::commas {x} {
regsub -all \\d(?=(\\d{3})+([regexp -inline {\.\d*$} $x]$)) $x {\0,}
}

Re: Recommended way to import files?

<232f40f8-7d10-4897-a6f4-a57c674aa3a2n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:31a0:b0:75b:262d:4051 with SMTP id bi32-20020a05620a31a000b0075b262d4051mr2650506qkb.7.1685644819057;
Thu, 01 Jun 2023 11:40:19 -0700 (PDT)
X-Received: by 2002:a05:620a:462b:b0:75b:24db:cde8 with SMTP id
br43-20020a05620a462b00b0075b24dbcde8mr3014841qkb.10.1685644818792; Thu, 01
Jun 2023 11:40:18 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!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: Thu, 1 Jun 2023 11:40:18 -0700 (PDT)
In-Reply-To: <26bd74dc-167c-4353-b531-cc6e2a95448en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=31.125.17.241; posting-account=C1gZvwoAAAAojE_ZgHdwZjGSuZg6QpNd
NNTP-Posting-Host: 31.125.17.241
References: <6801685628753@dlp> <5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com>
<1cdca509-8d2e-4cd9-bec2-a2a7afebf98bn@googlegroups.com> <u5ahjo$2r91q$1@dont-email.me>
<26bd74dc-167c-4353-b531-cc6e2a95448en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <232f40f8-7d10-4897-a6f4-a57c674aa3a2n@googlegroups.com>
Subject: Re: Recommended way to import files?
From: m.n.summerfield@googlemail.com (Mark)
Injection-Date: Thu, 01 Jun 2023 18:40:19 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1526
 by: Mark - Thu, 1 Jun 2023 18:40 UTC

Although the above works fine, it causes nagelfar to complain:

$ nagelfar.tcl -quiet -H -tab 4 -len 76 -Wunusedvar *.{tcl,tm}
myapp.tcl: 8: W Unknown command "app::main"
app-1.0.0.tm: 9: W Unknown command "util::commas"

Re: Recommended way to import files?

<gOSdndhQGfhwd-X5nZ2dnZfqnPqdnZ2d@giganews.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 01 Jun 2023 19:01:01 +0000
MIME-Version: 1.0
From: heller@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.15)
Subject: Re: Recommended way to import files?
In-Reply-To: <232f40f8-7d10-4897-a6f4-a57c674aa3a2n@googlegroups.com>
References: <6801685628753@dlp>
<5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com>?
<1cdca509-8d2e-4cd9-bec2-a2a7afebf98bn@googlegroups.com>
<u5ahjo$2r91q$1@dont-email.me>?
<26bd74dc-167c-4353-b531-cc6e2a95448en@googlegroups.com>
<232f40f8-7d10-4897-a6f4-a57c674aa3a2n@googlegroups.com>
Newsgroups: comp.lang.tcl
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <gOSdndhQGfhwd-X5nZ2dnZfqnPqdnZ2d@giganews.com>
Date: Thu, 01 Jun 2023 19:01:01 +0000
Lines: 21
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-RJrlyV+n/9b0s9roFy+ZyT97LknWQOGRqqQKHSoHFyXxNtwe9JE41Yc50Nrri1ne/c8Jin7r9u0j1Fn!HmUQzc6TK5hi7BKdYbJOOC2Ul/VCE+qndd4Q4HU6ldo+WptzGJjFrk32YDUs3cTZzBzLnGLsBuTw!Nyk=
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
 by: Robert Heller - Thu, 1 Jun 2023 19:01 UTC

This is a "normal" warning. It can be safely ignored. nagelfar has no way of
"knowing" about procs defined in a file other than the one it is currently
processing.

At Thu, 1 Jun 2023 11:40:18 -0700 (PDT) Mark <m.n.summerfield@googlemail.com> wrote:

>
> Although the above works fine, it causes nagelfar to complain:
>
> $ nagelfar.tcl -quiet -H -tab 4 -len 76 -Wunusedvar *.{tcl,tm}
> myapp.tcl: 8: W Unknown command "app::main"
> app-1.0.0.tm: 9: W Unknown command "util::commas"
>
>

--
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: Recommended way to import files?

<255ba353-f5cb-4f0a-b233-872db0cfcda0n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:7f01:0:b0:3f7:bf8e:5e16 with SMTP id f1-20020ac87f01000000b003f7bf8e5e16mr3660775qtk.1.1685699704843;
Fri, 02 Jun 2023 02:55:04 -0700 (PDT)
X-Received: by 2002:a05:622a:24d:b0:3f6:b556:7c9f with SMTP id
c13-20020a05622a024d00b003f6b5567c9fmr3596985qtx.7.1685699704550; Fri, 02 Jun
2023 02:55:04 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!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: Fri, 2 Jun 2023 02:55:04 -0700 (PDT)
In-Reply-To: <5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=139.47.58.45; posting-account=fwjo5QoAAAAcS9TSqEAQL1VEl7b8nCOq
NNTP-Posting-Host: 139.47.58.45
References: <6801685628753@dlp> <5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <255ba353-f5cb-4f0a-b233-872db0cfcda0n@googlegroups.com>
Subject: Re: Recommended way to import files?
From: eukelade@gmail.com (pd)
Injection-Date: Fri, 02 Jun 2023 09:55:04 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: pd - Fri, 2 Jun 2023 09:55 UTC

El jueves, 1 de junio de 2023 a las 16:28:02 UTC+2, Mark escribió:
> I read the docs for tm and they say "A Tcl Module is a Tcl Package contained in a single file, and no other files required by it". This seems a bit restrictive compared to the package approach. And anyway, I'm only really looking at how to spread an application over multiple files; all the tcl files are for the application, they're not self-contained as such.

so what's the real difference between a package and a module in terms of use? it seems modules are just an evolution over packages intended to the same use.

After reading the replies in this thread (and without reading any doc), I have a doubt, if package provide is not required in a module, how tcl knows what names you want to export in the module? is it the case that all symbols defined in the module are public by default (and thus imported when you do a package require)?

Re: Recommended way to import files?

<u5cnpr$36bu7$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Recommended way to import files?
Date: Fri, 2 Jun 2023 12:37:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <u5cnpr$36bu7$1@dont-email.me>
References: <6801685628753@dlp> <5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com> <255ba353-f5cb-4f0a-b233-872db0cfcda0n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 2 Jun 2023 12:37:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="483dad0de93d0fa0d550705e4fd8c52b";
logging-data="3354567"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Rf4twD1IWNSdlVJtRnbiX"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.19 (x86_64))
Cancel-Lock: sha1:PS2rK2nRr+e5kJMiq9wiN7Gd3XM=
 by: Rich - Fri, 2 Jun 2023 12:37 UTC

pd <eukelade@gmail.com> wrote:
> El jueves, 1 de junio de 2023 a las 16:28:02 UTC+2, Mark escribió:
>> I read the docs for tm and they say "A Tcl Module is a Tcl Package
>> contained in a single file, and no other files required by it".
>> This seems a bit restrictive compared to the package approach. And
>> anyway, I'm only really looking at how to spread an application over
>> multiple files; all the tcl files are for the application, they're
>> not self-contained as such.
>
> so what's the real difference between a package and a module in terms
> of use?

Use?

By an end user: no difference (other than needing the tm::path setup
properly to find them -- which should be handled by the app. code).

By a creator: modules are slightly simpler to create, but offer
slightly less flexibility to the creator in the process.

Modules also potentially might be slightly faster to source on first
use, as they are a set of files in a directory, and the filenames
define the module names and versions so a single glob of a single
directory can retreive all the names and versions.

For packages, they are each in an individual directory, and the
pkgIndex.tcl in each has to be sourced to find the names and versions,
so finding packages involves a directory tree walk and sourcing of
potentially a lot of pkgIndex.tcl files.

> it seems modules are just an evolution over packages intended to the
> same use.

In effect, yes.

> After reading the replies in this thread (and without reading any
> doc), I have a doubt, if package provide is not required in a module,

After Shelte indicated this was so, I did a quick test. It is not
required in a module. Tcl picks up the version from the module
filename.

> how tcl knows what names you want to export in the module?

The same way as it knows for a package, by what you define in the
module file. If the module defines a namespace (and it should, to
avoid name collisions) then the names to be exported are the names
given to the namespace export command that should be part of the module
file.

> is it the case that all symbols defined in the module are public by
> default (and thus imported when you do a package require)?

No, importing expects a namespace, and importing requires that the
nameespace first export the names that should be 'importable'. I.e.,
as with globals in Tcl, namespace names are not normally importable
unless you specify them to be so.

Re: Recommended way to import files?

<u5dcne$38qbb$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: Recommended way to import files?
Date: Fri, 2 Jun 2023 11:34:20 -0700
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <u5dcne$38qbb$1@dont-email.me>
References: <6801685628753@dlp>
<5dda6ee3-887f-4cf8-b9af-a32d4111f9a4n@googlegroups.com>
<255ba353-f5cb-4f0a-b233-872db0cfcda0n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 2 Jun 2023 18:34:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4dfdada891ae52676137742918c62a26";
logging-data="3434859"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19FsTGSL4BgbeZG9XmAwcnR"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:kgmgf16XHzCxl8wGyLgTl0uX9K0=
In-Reply-To: <255ba353-f5cb-4f0a-b233-872db0cfcda0n@googlegroups.com>
Content-Language: en-US
 by: et99 - Fri, 2 Jun 2023 18:34 UTC

On 6/2/2023 2:55 AM, pd wrote:
> El jueves, 1 de junio de 2023 a las 16:28:02 UTC+2, Mark escribió:
>> I read the docs for tm and they say "A Tcl Module is a Tcl Package contained in a single file, and no other files required by it". This seems a bit restrictive compared to the package approach. And anyway, I'm only really looking at how to spread an application over multiple files; all the tcl files are for the application, they're not self-contained as such.
>
> so what's the real difference between a package and a module in terms of use? it seems modules are just an evolution over packages intended to the same use.
>
> After reading the replies in this thread (and without reading any doc), I have a doubt, if package provide is not required in a module, how tcl knows what names you want to export in the module? is it the case that all symbols defined in the module are public by default (and thus imported when you do a package require)?

One can use a [package provide] command if one really
wants to, but it's not necessary. If used, it does add
a slight maintenance cost, since it will need to be
updated if/when a new version is added. It has to
agree with the version that the file name is encoded with.

Modules, like packages, are intended to be code that
forms a library where ordinarily more than one program
will be using the code. For example, the http package
is actually provided as a module. A module is simply
a lite weight package, that is pure tcl and can be
loaded via a source command.

One can use the *list* subcommand to find which of the
directories are built in searches similar to how the
global auto_path is setup. For example,

$ tclsh
% join [tcl::tm::path list] \n
/usr/lib/tcltk/tcl8/site-tcl
/usr/lib/tcltk/tcl8/8.0
/usr/lib/tcltk/tcl8/8.1
/usr/lib/tcltk/tcl8/8.2
/usr/lib/tcltk/tcl8/8.3
/usr/lib/tcltk/tcl8/8.4
/usr/lib/tcltk/tcl8/8.5
/usr/lib/tcltk/tcl8/8.6
/usr/lib/tcl8/site-tcl
/usr/lib/tcl8/8.0
/usr/lib/tcl8/8.1
/usr/lib/tcl8/8.2
/usr/lib/tcl8/8.3
/usr/lib/tcl8/8.4
/usr/lib/tcl8/8.5
/usr/lib/tcl8/8.6
/usr/share/tcltk/tcl8/site-tcl
/usr/share/tcltk/tcl8/8.0
/usr/share/tcltk/tcl8/8.1
/usr/share/tcltk/tcl8/8.2
/usr/share/tcltk/tcl8/8.3
/usr/share/tcltk/tcl8/8.4
/usr/share/tcltk/tcl8/8.5
/usr/share/tcltk/tcl8/8.6
/usr/share/tcltk/tcl8.6/tcl8

$ ls /usr/share/tcltk/tcl8.6/tcl8
http-2.9.0.tm msgcat-1.6.1.tm platform-1.0.14.tm tcltest-2.5.0.tm

So, if one wants to supply a module that does not
need a [tcl::tm::path add] one can place a module
into one of the *known* directories listed above.


devel / comp.lang.tcl / Re: Recommended way to import files?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor