Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Fine day for friends. So-so day for you.


comp / comp.lang.tcl / Question: is "test2" a "varname" or a "command/object"

SubjectAuthor
* Question: is "test2" a "varname" or a "command/object"aotto1968
`- Re: Question: is "test2" a "varname" or a "command/object"Robert Heller

1
Subject: Question: is "test2" a "varname" or a "command/object"
From: aotto1968
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sat, 8 Jun 2024 20:57 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Question: is "test2" a "varname" or a "command/object"
Date: Sat, 8 Jun 2024 22:57:12 +0200
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <v42gja$2qq63$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 08 Jun 2024 22:57:14 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="376ab037287ec31ce1c95ac1bf67ce41";
logging-data="2975939"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191Wd6OFvK/elhMOSzLIZJUYonh/vZUcMA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:H3QtnjWYmcF5HOIbIvqYX6UfGew=
Content-Language: en-US
View all headers

# Hi tricky tcl OO stuff
# # → the "OtherC create test2" create the "test2" instance in the namespace of the calling instance (test1).
# → the advantage is, if the calling-instance is delete the test2-instance is delete too because the
# calling-instance namespace is deleted.
# # and now the question:
# # is the "test2" now a "variable" or a "command" ? → the reason I ask is because the "my varname test2"
# return the string with absolute ns-path of the "test2-command" bus BUT it is a command and *not*
# a variable. the test with "info exists $varname" say 0, not a variable.
# # → I check the result from "my varname test2" later with "$varname test"

oo::class create OtherC {
constructor {} {
puts "create OtherC→[self]"
}

destructor {
puts "delete OtherC→[self]"
}

method test {} {
puts "I'm [self]"
}

}

oo::class create OttoC {
constructor {} {
puts "create OttoC→[self]"
OtherC create test2
}

destructor {
puts "delete OttoC→[self]"
}

method get {} {
my varname test2
}

}

OttoC create test1

set varname [test1 get]

$varname test

puts "varname = $varname"
puts "varname exists = [info exists $varname]"

test1 destroy

result…

create OttoC→::test1
create OtherC→::oo::Obj13::test2
I'm ::oo::Obj13::test2
varname = ::oo::Obj13::test2
varname exists = 0
delete OttoC→::test1
delete OtherC→::oo::Obj13::test2

Subject: Re: Question: is "test2" a "varname" or a "command/object"
From: Robert Heller
Newsgroups: comp.lang.tcl
Organization: Deepwoods Software
Date: Sat, 8 Jun 2024 22:56 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-1.nntp.ord.giganews.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: Sat, 08 Jun 2024 22:56:50 +0000
MIME-Version: 1.0
From: heller@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.17)
Subject: Re: Question: is "test2" a "varname" or a "command/object"
In-Reply-To: <v42gja$2qq63$1@dont-email.me>
References: <v42gja$2qq63$1@dont-email.me>
Newsgroups: comp.lang.tcl
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <qcidnXAtcc8vfPn7nZ2dnZfqnPSdnZ2d@giganews.com>
Date: Sat, 08 Jun 2024 22:56:50 +0000
Lines: 82
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-r2GGzs/HjiRVOry1CB9t8puz9rmILq242umBAGkZ1T5xMY0OxORgiPinVzcgl3ipRWfYVQzWdL8kzOX!d0HBgOnmaISjqBaWaGxnhxZe//WOsplfCWAT0XVaLv368s645MogNa8K09e8MRINfyftElHxF4al!unY=
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
View all headers

I don't know how Tcl's oo package works (I use the SNIT framework, which works
differently), but I'm guessing you are seeing some sort of scope "magic".

At Sat, 8 Jun 2024 22:57:12 +0200 aotto1968 <aotto1968@t-online.de> wrote:

>
>
> # Hi tricky tcl OO stuff
> #
> # the "OtherC create test2" create the "test2" instance in the namespace of the calling instance (test1).
> # the advantage is, if the calling-instance is delete the test2-instance is delete too because the
> # calling-instance namespace is deleted.
> #
> # and now the question:
> #
> # is the "test2" now a "variable" or a "command" ? the reason I ask is because the "my varname test2"
> # return the string with absolute ns-path of the "test2-command" bus BUT it is a command and *not*
> # a variable. the test with "info exists $varname" say 0, not a variable.
> #
> # I check the result from "my varname test2" later with "$varname test"
>
> oo::class create OtherC {
> constructor {} {
> puts "create OtherC→[self]"
> }
>
> destructor {
> puts "delete OtherC→[self]"
> }
>
> method test {} {
> puts "I'm [self]"
> }
>
> }
>
> oo::class create OttoC {
> constructor {} {
> puts "create OttoC→[self]"
> OtherC create test2
> }
>
> destructor {
> puts "delete OttoC→[self]"
> }
>
> method get {} {
> my varname test2
> }
>
> }
>
> OttoC create test1
>
> set varname [test1 get]
>
> $varname test
>
> puts "varname = $varname"
> puts "varname exists = [info exists $varname]"
>
> test1 destroy
>
>
> result…
>
> create OttoC→::test1
> create OtherC→::oo::Obj13::test2
> I'm ::oo::Obj13::test2
> varname = ::oo::Obj13::test2
> varname exists = 0
> delete OttoC→::test1
> delete OtherC→::oo::Obj13::test2
>
>

--
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

1

rocksolid light 0.9.8
clearnet tor