Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Gravity is a myth, the Earth sucks.


devel / comp.lang.tcl / strange behaviour with package and namespace

SubjectAuthor
* strange behaviour with package and namespacepd
+* Re: strange behaviour with package and namespacesaitology9
|`* Re: strange behaviour with package and namespacepd
| `* Re: strange behaviour with package and namespaceRich
|  `- Re: strange behaviour with package and namespaceHarald Oehlmann
`- Re: strange behaviour with package and namespacepd

1
strange behaviour with package and namespace

<c5d40d6d-06ef-4505-a1d5-53420544eea8n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Forwarded-Encrypted: i=1; AJvYcCXIIQwPsUYq9uPmrBB/Nio41nreKLzuUaZwOWPB/L+9VBamtETRNyjyCTCRBfO7Jtt1FbSAfhoQT2ZW+LGChXa07w3L6IhheHTSiZr6OS3Hnws=
X-Received: by 2002:a05:622a:4f:b0:42c:3f14:7dd5 with SMTP id y15-20020a05622a004f00b0042c3f147dd5mr21448qtw.12.1707260013049;
Tue, 06 Feb 2024 14:53:33 -0800 (PST)
X-Forwarded-Encrypted: i=1; AJvYcCVJ2T2kirRoa+pjLdJotByb08eOx+3N2q0SLiHdI+ezT9cruhwwuckHpCzBZJS/OQswQmnqllKW8A6f1nZdDiGVfJyLoFC/ZVMSqdamRbN2
X-Received: by 2002:ac8:7dca:0:b0:42c:347c:1e08 with SMTP id
c10-20020ac87dca000000b0042c347c1e08mr266946qte.8.1707260012802; Tue, 06 Feb
2024 14:53:32 -0800 (PST)
Path: i2pn2.org!i2pn.org!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: Tue, 6 Feb 2024 14:53:32 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=207.188.184.151; posting-account=fwjo5QoAAAAcS9TSqEAQL1VEl7b8nCOq
NNTP-Posting-Host: 207.188.184.151
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c5d40d6d-06ef-4505-a1d5-53420544eea8n@googlegroups.com>
Subject: strange behaviour with package and namespace
From: eukel...@gmail.com (pd)
Injection-Date: Tue, 06 Feb 2024 22:53:33 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3056
 by: pd - Tue, 6 Feb 2024 22:53 UTC

I'm trying the diagram implementation listed in [1] which provides an example and a link to a package file.

I've downloaded the package file (diagram.tcl) and copied the example in a tcl file (test_diagram.tcl)

I have a problem using the package diagram. But after loading successfully the package:

% lappend auto_path .
C:/Users/... .
% package require BWidget
1.9.13
% package require diagram
1

but I cannot use it because it doesn't find any command, for example:

% ::diagram::create_diagram
invalid command name "::diagram::create_diagram"

even when the namespace exits:

% namespace exists diagram
1

The namespace defined in package export all symbols (namespace export *) so I've tried to import them all and try to run the procs withou success:

% namespace import diagram::*
% create_diagram
invalid command name "create_diagram"

I was expecting to execute procs in a namespace when you fully qualified it, but it doesn't work in this case.

What is really strange is it seems to be using a different diagram namespace because if I query for its vars and procs I get:

% info vars ::diagram::*
::diagram::Snit_typemethodInfo ::diagram::Snit_info ::diagram::Snit_optionInfo ::diagram::Snit_methodInfo
% info procs ::diagram::*
::diagram::Snit_methodreset ::diagram::Snit_destructor ::diagram::Snit_constructor ::diagram::Snit_typeconstructor ::diagram::Snit_instanceVars

which seems to be related with Snit and not with the package I have loaded (which defines a diagram namespace with vars like data, minimap_ratio or autoscrolling and procs like create_scroll_minimap, find_port_point_circle or create_diagram)

Any idea about what's happening? maybe is a problem with another package loaded? maybe BWidget?

regards

Re: strange behaviour with package and namespace

<upul9h$14bql$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: saitolo...@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: strange behaviour with package and namespace
Date: Tue, 6 Feb 2024 20:10:08 -0500
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <upul9h$14bql$1@dont-email.me>
References: <c5d40d6d-06ef-4505-a1d5-53420544eea8n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 7 Feb 2024 01:10:09 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a7cca6816c9de3697906c6a8fb162e1a";
logging-data="1191765"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fDIpaBg9fgctsk/uZH3tE"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:gLY8E+K0LKmUZdp7/E/M5ug1rYE=
In-Reply-To: <c5d40d6d-06ef-4505-a1d5-53420544eea8n@googlegroups.com>
Content-Language: en-US
 by: saitology9 - Wed, 7 Feb 2024 01:10 UTC

On 2/6/2024 5:53 PM, pd wrote:
> I'm trying the diagram implementation listed in [1] which provides an example and a link to a package file.
>
> I've downloaded the package file (diagram.tcl) and copied the example in a tcl file (test_diagram.tcl)
>
> I have a problem using the package diagram. But after loading successfully the package:
>
> % lappend auto_path .
> C:/Users/... .
> % package require BWidget
> 1.9.13
> % package require diagram
> 1
>
> but I cannot use it because it doesn't find any command, for example:
>
> % ::diagram::create_diagram
> invalid command name "::diagram::create_diagram"

I am not familiar with this code but you should be able to get this to
run with the following changes:

1) In the file "diagram.tcl", move the statement "package provide ..."
from the top to the bottom of the file.

2) In the "test_diagram.tcl" file, change all instances of
"diagram::xyz" to "::diagram::xyz".

Re: strange behaviour with package and namespace

<19c02e6a-911e-4172-a166-8503cb6d4bbfn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a0c:eed4:0:b0:68c:ba72:d2ff with SMTP id h20-20020a0ceed4000000b0068cba72d2ffmr35641qvs.2.1707340230509;
Wed, 07 Feb 2024 13:10:30 -0800 (PST)
X-Received: by 2002:ac8:5cc5:0:b0:42c:44b4:3eb9 with SMTP id
s5-20020ac85cc5000000b0042c44b43eb9mr112190qta.1.1707340230280; Wed, 07 Feb
2024 13:10:30 -0800 (PST)
Path: i2pn2.org!i2pn.org!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, 7 Feb 2024 13:10:29 -0800 (PST)
In-Reply-To: <c5d40d6d-06ef-4505-a1d5-53420544eea8n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=207.188.184.151; posting-account=fwjo5QoAAAAcS9TSqEAQL1VEl7b8nCOq
NNTP-Posting-Host: 207.188.184.151
References: <c5d40d6d-06ef-4505-a1d5-53420544eea8n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <19c02e6a-911e-4172-a166-8503cb6d4bbfn@googlegroups.com>
Subject: Re: strange behaviour with package and namespace
From: eukel...@gmail.com (pd)
Injection-Date: Wed, 07 Feb 2024 21:10:30 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3131
 by: pd - Wed, 7 Feb 2024 21:10 UTC

El martes, 6 de febrero de 2024 a las 23:53:35 UTC+1, pd escribió:
>
> I have a problem using the package diagram. But after loading successfully the package:
>
> % lappend auto_path .
> C:/Users/... .
> % package require BWidget
> 1.9.13
> % package require diagram
> 1
>
> but I cannot use it because it doesn't find any command, for example:
>
> % ::diagram::create_diagram
> invalid command name "::diagram::create_diagram"
>
> even when the namespace exits:
>
> % namespace exists diagram
> 1
>
> What is really strange is it seems to be using a different diagram namespace because if I query for its vars and procs I get:
>
> % info vars ::diagram::*
> ::diagram::Snit_typemethodInfo ::diagram::Snit_info ::diagram::Snit_optionInfo ::diagram::Snit_methodInfo
> % info procs ::diagram::*
> ::diagram::Snit_methodreset ::diagram::Snit_destructor ::diagram::Snit_constructor ::diagram::Snit_typeconstructor ::diagram::Snit_instanceVars
>

I managed to solve the problem, apparently the package was loaded right but it's an illusion, really the package that was loaded with

% package require diagram

is the tcllib diagram package which happens to be also version 1.0 and also defines a diagram namespace, for this reason all procs and vars in the namespace are so strange, they are from tcllib diagram rather than diagram.tcl

I solved it making the diagram.tcl a module (pm) rather than a package, so I can better control which one is loading.

This issue makes me to realize about the problem of name collision between packages, I think it should be managed but don't know how because there's no proper mechanism , maybe a hierarchy name similar to java packages.

Also I have another problem with tcllib package (I've played with it after this problem) but I'll discuss it in another post.

Re: strange behaviour with package and namespace

<9723d9d6-fe8a-45c3-a40e-dedfd44ef751n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Forwarded-Encrypted: i=1; AJvYcCUnaEVHAxWbbbJusk5Jf6NaYLOv3k5e/P+XMXcAzg+IsWhDwU2gW7i7SAPJjAoLS5INoGF4Cghm2RKwp8PyMCFIj/Jv6WWhqtj82v+l5Tev0/4=
X-Received: by 2002:a05:622a:170f:b0:42c:3719:7ad8 with SMTP id h15-20020a05622a170f00b0042c37197ad8mr15305qtk.0.1707340476219;
Wed, 07 Feb 2024 13:14:36 -0800 (PST)
X-Forwarded-Encrypted: i=1; AJvYcCVf++LgbLSuZjad9kqVD5betcmRM9nPJLhPYh1bydAuRo9N6IdR2RU4fm3D8aQdG2iDBCZKUnuivLY8/T8Td1i7dWCEgNf8amtmY9+JSeFK
X-Received: by 2002:a05:6214:508c:b0:686:a20c:59f with SMTP id
kk12-20020a056214508c00b00686a20c059fmr30050qvb.0.1707340476005; Wed, 07 Feb
2024 13:14:36 -0800 (PST)
Path: i2pn2.org!i2pn.org!newsfeed.endofthelinebbs.com!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, 7 Feb 2024 13:14:35 -0800 (PST)
In-Reply-To: <upul9h$14bql$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=207.188.184.151; posting-account=fwjo5QoAAAAcS9TSqEAQL1VEl7b8nCOq
NNTP-Posting-Host: 207.188.184.151
References: <c5d40d6d-06ef-4505-a1d5-53420544eea8n@googlegroups.com> <upul9h$14bql$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9723d9d6-fe8a-45c3-a40e-dedfd44ef751n@googlegroups.com>
Subject: Re: strange behaviour with package and namespace
From: eukel...@gmail.com (pd)
Injection-Date: Wed, 07 Feb 2024 21:14:36 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2355
 by: pd - Wed, 7 Feb 2024 21:14 UTC

El miércoles, 7 de febrero de 2024 a las 2:10:15 UTC+1, saitology9 escribió:

> I am not familiar with this code but you should be able to get this to
> run with the following changes:
>
> 1) In the file "diagram.tcl", move the statement "package provide ..."
> from the top to the bottom of the file.
>
> 2) In the "test_diagram.tcl" file, change all instances of
> "diagram::xyz" to "::diagram::xyz".

thanks for the ideas, I solved it another way but your reply made me think about...

Is it important where you put the "package provide" in the source file? I supposed it is mainly declarative, independently of where it comes

I also thought ::X::y and X::y to be analogous, like an alias... but maybe X::y is relative to current namespace rather than relative to root namespace and thus ::X::y is not the same of X::y

Re: strange behaviour with package and namespace

<uq397a$23gul$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: strange behaviour with package and namespace
Date: Thu, 8 Feb 2024 19:14:50 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <uq397a$23gul$1@dont-email.me>
References: <c5d40d6d-06ef-4505-a1d5-53420544eea8n@googlegroups.com> <upul9h$14bql$1@dont-email.me> <9723d9d6-fe8a-45c3-a40e-dedfd44ef751n@googlegroups.com>
Injection-Date: Thu, 8 Feb 2024 19:14:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0a76cb11b3417798b83a271d819990b2";
logging-data="2212821"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+uGK44Dk3mkbt3hzNl3HlM"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:bqZNOf+9Sn35BDkr2mbvJRoRBas=
 by: Rich - Thu, 8 Feb 2024 19:14 UTC

pd <eukelade@gmail.com> wrote:
> I also thought ::X::y and X::y to be analogous, like an alias...

No, those two are not analogous.

> but maybe X::y is relative to current namespace

It is. So X::y will only resolve to ::X::y provided you do not have a
sub X namespace in your current namespace.

> rather than relative to root namespace and thus ::X::y is not the
> same of X::y

No, those two are not identical. X::y just ends up finding ::X::y
because of the namespace name lookup rules, and then only when you
don't have an X namespace below where you are.

If you have this

::X

Then in ::X just Y will look for ::Y as part of the name resolution.

But if you have this:

::X::Y

Then when in ::X, just Y will find ::X::Y and not ::Y (even if you also
have a ::Y).

Re: strange behaviour with package and namespace

<uq4l2o$2hhpq$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wortka...@yahoo.com (Harald Oehlmann)
Newsgroups: comp.lang.tcl
Subject: Re: strange behaviour with package and namespace
Date: Fri, 9 Feb 2024 08:43:21 +0100
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <uq4l2o$2hhpq$1@dont-email.me>
References: <c5d40d6d-06ef-4505-a1d5-53420544eea8n@googlegroups.com>
<upul9h$14bql$1@dont-email.me>
<9723d9d6-fe8a-45c3-a40e-dedfd44ef751n@googlegroups.com>
<uq397a$23gul$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 9 Feb 2024 07:43:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="aaf602e7d68f9fc38d22a9e5cf15e014";
logging-data="2672442"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+m3bUGqJoueCI5cykyUSvK"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ceP6g1fdra1SP3AR1AkUXP4TYgE=
In-Reply-To: <uq397a$23gul$1@dont-email.me>
Content-Language: en-GB
 by: Harald Oehlmann - Fri, 9 Feb 2024 07:43 UTC

Am 08.02.2024 um 20:14 schrieb Rich:
> pd <eukelade@gmail.com> wrote:
>> I also thought ::X::y and X::y to be analogous, like an alias...
>
> No, those two are not analogous.
>
>> but maybe X::y is relative to current namespace
>
> It is. So X::y will only resolve to ::X::y provided you do not have a
> sub X namespace in your current namespace.
>
>> rather than relative to root namespace and thus ::X::y is not the
>> same of X::y
>
> No, those two are not identical. X::y just ends up finding ::X::y
> because of the namespace name lookup rules, and then only when you
> don't have an X namespace below where you are.
>
> If you have this
>
> ::X
>
> Then in ::X just Y will look for ::Y as part of the name resolution.
>
> But if you have this:
>
> ::X::Y
>
> Then when in ::X, just Y will find ::X::Y and not ::Y (even if you also
> have a ::Y).
>

May I also underline, that the name resolution changed in 9.0.
9.0 does not try any more to resolve in the global namespace without
prefixed "::". So, in 9.0 it will "X::y" will only work from the global
namespace, "::X::y" will work from any namespace.

Harald

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor