Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Mr. Watson, come here, I want you." -- Alexander Graham Bell


devel / comp.lang.tcl / possible problem with namespace and tcl-C-extension

SubjectAuthor
* possible problem with namespace and tcl-C-extensionaotto1968
`* Re: possible problem with namespace and tcl-C-extensionRich
 `* Re: possible problem with namespace and tcl-C-extensionaotto1968
  +- Re: possible problem with namespace and tcl-C-extensionRich
  `- Re: possible problem with namespace and tcl-C-extensionblacksqr

1
possible problem with namespace and tcl-C-extension

<t6fevv$6dq$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: possible problem with namespace and tcl-C-extension
Date: Mon, 23 May 2022 10:01:02 +0200
Organization: A noiseless patient Spider
Lines: 91
Message-ID: <t6fevv$6dq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 23 May 2022 08:01:03 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cb24e097b7386d9ae534b8c775e58e77";
logging-data="6586"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CwiCFeI42uAtycKlGcpdydZtFrsKG+EQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Cancel-Lock: sha1:om1j9YQyR82xeZLCzSIZH/mbUf8=
Content-Language: en-US
 by: aotto1968 - Mon, 23 May 2022 08:01 UTC

Hi, I have a problem that a "package require …" always be done into the
global (::) namespace. I have a problem to setup a "namespace" from
required package to be "::test::tclmsgque::MkKernel" and *not*
"::tclmsgque::MkKernel"

error: namespace import tclmsgque::* =
unknown namespace in import pattern "tclmsgque::*"

I don't know if this is a feature or a bug because without fix to global
"::" ns a package require or a lazy loading would be probably put the
package into a *wrong* ns. BUT the feature to force an other "namespace
current" as global(::) for a package imported would be a benefit.

tcl code:

namespace eval test {

cmd package names
cmd namespace current

package require tclmsgque::MkKernel

cmd namespace current
cmd namespace import tclmsgque::*

tcl result:

package names = zlib TclOO tcl::tommath Tcl
namespace current = ::test
X> :(tclStubsPtr->tcl_GetCurrentNamespace)(interp)->fullName<::>
X> :ns->fullName<::tclmsgque::MkKernel>
namespace current = ::test
namespace import tclmsgque::* = unknown namespace in import
pattern "tclmsgque::*"

tcl extension C code

OT_TCL_EXTERN int

Tclmkkernel_Init (

Tcl_Interp * interp

)

{

// check for the right tcl version

if (Tcl_InitStubs (interp, "8.5", 0) == NULL) {

return TCL_ERROR;

}

if (Tcl_OOInitStubs (interp) == NULL) {

return TCL_ERROR;

}

printC(Tcl_GetCurrentNamespace(interp)->fullName)

// announce my package

LngErrorCheck (Tcl_PkgProvide (interp, "tclmsgque::MkKernel",
LIBMSGQUE_VERSION ));

// toplevel namespace

Tcl_Namespace *ns = Tcl_CreateNamespace (interp,
"tclmsgque::MkKernel", NULL, NULL);
check_NULL(ns) return TCL_ERROR;

printC(ns->fullName)

mfg ao

Re: possible problem with namespace and tcl-C-extension

<t6g4dk$2gu$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: possible problem with namespace and tcl-C-extension
Date: Mon, 23 May 2022 14:06:44 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <t6g4dk$2gu$1@dont-email.me>
References: <t6fevv$6dq$1@dont-email.me>
Injection-Date: Mon, 23 May 2022 14:06:44 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="47d9e66b95e7f8f13e014063e2249c57";
logging-data="2590"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19rITlXdnH7LupplGO29KBC"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:4/m2uwZj79VTsqV9vyKboAAj5p4=
 by: Rich - Mon, 23 May 2022 14:06 UTC

aotto1968 <aotto1968@t-online.de> wrote:
>
> Hi, I have a problem that a "package require ?" always be done into
> the global (::) namespace. I have a problem to setup a "namespace"
> from required package to be "::test::tclmsgque::MkKernel" and *not*
> "::tclmsgque::MkKernel"

Do you mean you always want your "test" namespace to be created in the
global top-level namespace?

> tcl code:
>
> namespace eval test {

If you want "test" to always be in the global, then ask for that:

namespace eval ::test {

Now 'test' will always be in the global namespace, no matter in what
namespace you run the package require.

Re: possible problem with namespace and tcl-C-extension

<t6gano$m3q$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: possible problem with namespace and tcl-C-extension
Date: Mon, 23 May 2022 17:54:32 +0200
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <t6gano$m3q$1@dont-email.me>
References: <t6fevv$6dq$1@dont-email.me> <t6g4dk$2gu$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 23 May 2022 15:54:32 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cb24e097b7386d9ae534b8c775e58e77";
logging-data="22650"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CXsY2blpYfF3nleNmj/wJ1mjKIJf4iT4="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Cancel-Lock: sha1:NbRMNwTtQYyJJcjKLTdyJNfgi5E=
In-Reply-To: <t6g4dk$2gu$1@dont-email.me>
Content-Language: en-US
 by: aotto1968 - Mon, 23 May 2022 15:54 UTC

On 23.05.22 16:06, Rich wrote:
> aotto1968 <aotto1968@t-online.de> wrote:
>>
>> Hi, I have a problem that a "package require ?" always be done into
>> the global (::) namespace. I have a problem to setup a "namespace"
>> from required package to be "::test::tclmsgque::MkKernel" and *not*
>> "::tclmsgque::MkKernel"
>
> Do you mean you always want your "test" namespace to be created in the
> global top-level namespace?
>
>> tcl code:
>>
>> namespace eval test {
>
> If you want "test" to always be in the global, then ask for that:
>
> namespace eval ::test {
>
> Now 'test' will always be in the global namespace, no matter in what
> namespace you run the package require.

I want to have that the "tclmsgque" namespace be created into the
namespace the "package require" was called (now "test"). the "test"
namespace is just an "test-example"

mfg

Re: possible problem with namespace and tcl-C-extension

<t6glm3$eu8$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: possible problem with namespace and tcl-C-extension
Date: Mon, 23 May 2022 19:01:23 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <t6glm3$eu8$1@dont-email.me>
References: <t6fevv$6dq$1@dont-email.me> <t6g4dk$2gu$1@dont-email.me> <t6gano$m3q$1@dont-email.me>
Injection-Date: Mon, 23 May 2022 19:01:23 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="47d9e66b95e7f8f13e014063e2249c57";
logging-data="15304"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+IemoE4qXN5A9I0r/GncA"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:YyhZoju4/ZKxurIgv3fGYNXU0Lg=
 by: Rich - Mon, 23 May 2022 19:01 UTC

aotto1968 <aotto1968@t-online.de> wrote:
> On 23.05.22 16:06, Rich wrote:
>> aotto1968 <aotto1968@t-online.de> wrote:
>>>
>>> Hi, I have a problem that a "package require ?" always be done into
>>> the global (::) namespace. I have a problem to setup a "namespace"
>>> from required package to be "::test::tclmsgque::MkKernel" and *not*
>>> "::tclmsgque::MkKernel"
>>
>> Do you mean you always want your "test" namespace to be created in the
>> global top-level namespace?
>>
>>> tcl code:
>>>
>>> namespace eval test {
>>
>> If you want "test" to always be in the global, then ask for that:
>>
>> namespace eval ::test {
>>
>> Now 'test' will always be in the global namespace, no matter in what
>> namespace you run the package require.
>
> I want to have that the "tclmsgque" namespace be created into the
> namespace the "package require" was called (now "test"). the "test"
> namespace is just an "test-example"

How does the "tclmsgque" package define it's namespace eval?

If it does "namespace eval ::tclmsgque {...}" then change it to be
"namespace eval tclmsgque {...}" and it should create the "tclmsgque"
namespace inside where it is called from. But you do need to run the
package require inside the namespace you wish to be the parent, i.e.:

namespace eval ::test {
package require tclmsgque
}

And it should then create ::test::tclmsgque.

Re: possible problem with namespace and tcl-C-extension

<e903027c-67ec-486e-af04-fb32efae5b8cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:622a:3d3:b0:2f3:ba0b:ee5b with SMTP id k19-20020a05622a03d300b002f3ba0bee5bmr21232255qtx.365.1653421236103;
Tue, 24 May 2022 12:40:36 -0700 (PDT)
X-Received: by 2002:a05:6808:148b:b0:32b:9960:857f with SMTP id
e11-20020a056808148b00b0032b9960857fmr121427oiw.201.1653421235661; Tue, 24
May 2022 12:40:35 -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, 24 May 2022 12:40:35 -0700 (PDT)
In-Reply-To: <t6gano$m3q$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:241:8002:20f0:b151:81d6:becb:16b;
posting-account=HOjbdAkAAADQWpbtDe731VR_-chRuCoh
NNTP-Posting-Host: 2601:241:8002:20f0:b151:81d6:becb:16b
References: <t6fevv$6dq$1@dont-email.me> <t6g4dk$2gu$1@dont-email.me> <t6gano$m3q$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e903027c-67ec-486e-af04-fb32efae5b8cn@googlegroups.com>
Subject: Re: possible problem with namespace and tcl-C-extension
From: stephen.huntley@alum.mit.edu (blacksqr)
Injection-Date: Tue, 24 May 2022 19:40:36 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2737
 by: blacksqr - Tue, 24 May 2022 19:40 UTC

On Monday, May 23, 2022 at 10:54:36 AM UTC-5, aotto1...@gmail.com wrote:
> I want to have that the "tclmsgque" namespace be created into the
> namespace the "package require" was called (now "test"). the "test"
> namespace is just an "test-example"

The fact that some people include double-colons in package names (like you do with "tclmsgque::MkKernel") is simply a convention, it's just a coincidence that the package name looks like a namespace, and the naming of the package plays no role in where the package's namespaces are created.

The package name is just a string, and Tcl's package API checks if that string matches a package name registered with the "package ifneeded" command. The "package ifneeded" command registers a script to be executed when "package require" is called with that package name. The script registered with "package ifneeded" is always executed in the global namespace.

So if you want the script that runs when you call "package require tclmsgque::MkKernel" to create a child of the current namespace, you'll have to find a way to pass the name of the current namespace to the package script when it executes in the global namespace. For example, you could create a global variable called "mynamespace" and set it equal to ::test just before calling the "package require" command. Then the package script could include a command like "namespace eval ${mynamespace}::tclmsgque::MkKernel {}"


devel / comp.lang.tcl / possible problem with namespace and tcl-C-extension

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor