$tcl_platform(platform)
I get this error message:
error reading package index file dover1.0/pkgIndex.tcl: can't read "tcl_platform(platform)": no such variable
The same script works if I use the 8.3.4 interpreter. It is the same with
tclsh, wish and bltwish (the ones I use). So it must be in the tcl
library, which they all share.
The bit of pkgIndex.tcl script is basically like this:
package ifneeded Dover 1.00 "
switch $tcl_platform(platform) {
{windows} {
puts stderr Windows
}
{unix} {
puts stderr Unix
}
}
"
I tried making tcl_platform global, but this had no effect. This happens
even when the package folder contains only the pkgIndex.tcl file and this
is all the file contains.
If I just start tclsh, I can access $tcl_platform(platform) with no
problem...
I'm stumped.
--
Roger Oberholtzer
> I tried making tcl_platform global, but this had no effect. This happens
> even when the package folder contains only the pkgIndex.tcl file and this
> is all the file contains.
Global as in "global tcl_platform" or global as in "::tcl_platform"?
I use the latter successfully.. Worth a shot.
--
Michael Kirkham
Muonics
http://www.muonics.com/
> In article <pan.2003.07.31.12...@opq.se>, ro...@opq.se
> says...
>
>> I tried making tcl_platform global, but this had no effect. This happens
>> even when the package folder contains only the pkgIndex.tcl file and this
>> is all the file contains.
>
> Global as in "global tcl_platform" or global as in "::tcl_platform"?
That does make a difference. But why should it? I wonder how many other
things I do with 'global' that will be different. Is this expected
behavior? I looked for things related to tcl_platform in the
changes file in the 8.4.4 source and did not see anything
about this. So it must be a more general change.
I have an uneasy feeling about this...
Can you show us what you tried to do that had no effect?
--
Tenth Tcl/Tk Conference is this week! <http://www.tcl.tk/community/tcl2003>
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: mailto:lvi...@yahoo.com > <URL: http://www.purl.org/NET/lvirden/ >
> On Thu, 31 Jul 2003 13:28:32 +0000, Michael Kirkham wrote:
>
> > In article <pan.2003.07.31.12...@opq.se>, ro...@opq.se
> > says...
> >
> >> I tried making tcl_platform global, but this had no effect.
> >
> > Global as in "global tcl_platform" or global as in "::tcl_platform"?
>
> That does make a difference. But why should it?
Crystal ball ... You used
global tcl_platform(platform)
clouds obscure the view...and now I see
global $tcl_platform
the swirling mists return, but part to reveal
proc global {args} ...
The crystal goes dark.
Maybe you have one of those mistakes, maybe not.
--
Donald Arseneau as...@triumf.ca
> Crystal ball ... You used
> global tcl_platform(platform)
> clouds obscure the view...and now I see
> global $tcl_platform
> the swirling mists return, but part to reveal
> proc global {args} ...
> The crystal goes dark.
Nope. I used:
package ifneeded Dover 1.00 "
global tcl_platform
# Do stuff
"
which should make the whole array available. Alas, it did not.
(It was not in my original post because I wanted to show what
did not work that had been working since time started.)
As I wrote earlier, the change to using
$::tcl_platform(platform)
instead of
$tcl_platform(platform)
did the trick. But I am not out of the woods. There is other code
that is causing problems.
I did not expect script incompatabilities between 8.3.4 and 8.4.4, but
there may be a number of them.
You do realize that the `global' _inside_ the quoted string is
completely irrelevant for the resolution of the $tcl_platform in the
same quoted string?
If you want to use `global' (instead of the $::), you need
global tcl_platform
package ifneeded Dover 1.00 " ... $tcl_platform(platform) ..."
Note the changed sequence. The `global' statement is only seen and
evaluated when the stringified code is executed, but the $tcl_platform
dereference happens when the `package ifneeded' statement is read.
| I did not expect script incompatabilities between 8.3.4 and 8.4.4,
| but there may be a number of them.
_These_ are no string incompatibilities, but most likely a result of
the pkgindex file not being sourced in the global namespace any more.
R'
> * Roger Oberholtzer <ro...@opq.se>
> | package ifneeded Dover 1.00 "
> | global tcl_platform
> | # Do stuff
> | "
>
> You do realize that the `global' _inside_ the quoted string is completely
> irrelevant for the resolution of the $tcl_platform in the same quoted
> string?
The problem as I see it is that I did not need to specify tcl_platform as
global or anything in 8.3.4. It was directly available without the need of
any declaration at all. The same pkgIndex.tcl script that worked in this
sense on 8.3.4 failed on 8.4.4, requiring the $:: to make it work. So
there is indeed a change that introduced an incompatibility. But that is
now sorted out.
> If you want to use `global' (instead of the $::), you need
>
> global tcl_platform
> package ifneeded Dover 1.00 " ... $tcl_platform(platform) ..."
>
> Note the changed sequence. The `global' statement is only seen and
> evaluated when the stringified code is executed, but the $tcl_platform
> dereference happens when the `package ifneeded' statement is read.
>
> Most likely a result of the pkgindex file not being sourced in the global
> namespace any more.
>
> R'
If you want to dig deeper, put a debugging
puts "current level: {[info level]}"
puts "tcl_platform exists: {[info exists tcl_platform]}"
puts "current namespace: {[namespace current]}"
puts "tcl_platform is {[namespace which -variable tcl_platform]}"
at the top of the pkgindex.tcl, and then run the script in 8.3.4 and
8.4.4. My guess is that in 8.4.4 the script is not sourced at
toplevel scope, either due to changes in TCL 8.3->8.4, or due to other
changes in your code to make it work with 8.4.
R'
> I jave just tried to upgrade from tcl/tk 8.3.4 to 8.4.4 (on
> Linux). However, the following no longer works in a pkgIndex.tcl
> file:
>
> $tcl_platform(platform)
>
> I get this error message:
>
> error reading package index file dover1.0/pkgIndex.tcl: can't
> read "tcl_platform(platform)": no such variable
The fact that this worked before was pure luck, or dependence on
undocumented behaviour. pkgIndex.tcl files are not sourced at the
global level, but in the context of tclPkgUnknown.
Up to 8.4.1 tclPkgUnknown declared tcl_platform as global, because it
needed it, and therefore it was by chance also directly available to
pkgIndex.tcl scripts.
The question is, whether it would be better to change tclPkgUnknown so
that it sources pkgIndex.tcl files at the global level.
cu
Reinhard
In article <bgdas8$94p$1...@Fourier.suse.de>, Reinhard Max wrote:
> The fact that this worked before was pure luck, or dependence on
> undocumented behaviour. pkgIndex.tcl files are not sourced at the
> global level, but in the context of tclPkgUnknown.
That is the correct answer. For more info on things to keep in
mind when writing your index scripts, see
The only variable that you can count on being "in scope" in your
index script is the $dir variable that holds the name of the install
directory.
--
| Don Porter Mathematical and Computational Sciences Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|
not sur where or how you use it or what your syntax is but i use it
for my windrop and works great nothing fancy just some info
bind PUB m !stats stats:pub
proc stats:pub {nick uhost hand chan arg} {
putquick "NOTICE $nick :The os platfrom: $::tcl_platform(os)
$::tcl_platform(osVersion) on a $::tcl_platform(machine) processor."
}
maybe you see something usefull ?
> not sur where or how you use it or what your syntax is but i use it
> for my windrop and works great nothing fancy just some info
>
> bind PUB m !stats stats:pub
>
> proc stats:pub {nick uhost hand chan arg} {
> putquick "NOTICE $nick :The os platfrom: $::tcl_platform(os)
> $::tcl_platform(osVersion) on a $::tcl_platform(machine) processor."
> }
This is a perfectly valid use of tcl_platform.
The original question was, whether tcl_platform can be expected to be
available from within pkgIndex.tcl scripts without leading :: or
[global], and it turned out that it can't.
cu
Reinhard