|
2005-11-17
| ||
| 01:45 | • Ticket [1176470fff] Invoke *_*Init() for each load status still Open with... artifact: 50ae7d64d0 user: dgp | |
| 01:45 | • Ticket [1176470fff]: 3 changes artifact: 637b1e17cc user: dgp | |
| 01:45 | • Ticket [1176470fff]: 4 changes artifact: 39cff83c40 user: dgp | |
| 01:39 | • Ticket [1176470fff]: 4 changes artifact: 340d968478 user: dgp | |
|
2005-04-06
| ||
| 23:59 | • Open ticket [1176470fff]. artifact: 765eae797e user: eriklns | |
| 23:52 | • Pending ticket [1176470fff]. artifact: ea67940070 user: eriklns | |
| 23:52 | • Open ticket [1176470fff]. artifact: f5c81f51dc user: eriklns | |
|
2005-04-05
| ||
| 02:17 | • Ticket [1176470fff]: 6 changes artifact: d71e5a7285 user: hobbs | |
| 01:02 | • Pending ticket [1176470fff]. artifact: 116e8bf59d user: dgp | |
| 00:40 | • Open ticket [1176470fff]. artifact: 71a73c4031 user: dgp | |
| 00:30 | • Closed ticket [1176470fff]. artifact: aa0ea21484 user: hobbs | |
|
2005-04-04
| ||
| 23:48 | • Ticket [1176470fff]: 7 changes artifact: ac956bacdd user: dgp | |
| 16:31 | • New ticket [1176470fff]. artifact: 0a81fa3767 user: eriklns | |
Invoke *_*Init() for each [load]
Open1176470fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 21 years ago
Descriptionplain2005-04-04 16:31:24
L.S.
Two unexpected results occur when importing packages
which load compiled code:
1. When doing [package forget], the entry of the
corresponding shared library is not removed from what's
returned by [info loaded].
2. After having done [package forget], and issuing
again [package require], an error message is returned:
"can't find package ..."
An example session that exercises the above sequence
for Tkhtml and Tktable is appended to this message.
A discussion in c.l.t. (started at 4-Apr-2005,
featuring Michael Schlenker, Don Porter and yours
truly) arrived at the point where dgp judges there is
either a bug here or a misfeature.
Erik Leunissen
==============
Example Tcl session:
---------------
% info loaded
{{} Tk}
% package require Tkhtml
2.0
% info loaded
{/usr/lib/tk8.4/../libtk8.4.so Tk}
{/usr/local/lib/Tkhtml2.0/libTkhtml2.0.so Tkhtml} {{} Tk}
% package forget Tkhtml
% info loaded
{/usr/lib/tk8.4/../libtk8.4.so Tk}
{/usr/local/lib/Tkhtml2.0/libTkhtml2.0.so Tkhtml} {{} Tk}
% package require Tkhtml
can't find package Tkhtml
% package require Tktable
2.8
% info loaded
{/usr/local/lib/Tktable2.8/libTktable2.8.so Tktable}
{/usr/lib/tk8.4/../libtk8.4.so Tk}
{/usr/local/lib/Tkhtml2.0/libTkhtml2.0.so Tkhtml} {{} Tk}
% info loaded
{/usr/local/lib/Tktable2.8/libTktable2.8.so Tktable}
{/usr/lib/tk8.4/../libtk8.4.so Tk}
{/usr/local/lib/Tkhtml2.0/libTkhtml2.0.so Tkhtml} {{} Tk}
% package forget Tktable
% info loaded
{/usr/local/lib/Tktable2.8/libTktable2.8.so Tktable}
{/usr/lib/tk8.4/../libtk8.4.so Tk}
{/usr/local/lib/Tkhtml2.0/libTkhtml2.0.so Tkhtml} {{} Tk}
% package require Tktable
can't find package Tktable
-- end of message --
--
leunissen@ nl | Merge the left part of these
two lines into one,
e. hccnet. | respecting a character's
position in a line.
dgpplain2005-04-04 23:48:21
Logged In: YES user_id=80530 I'd have expected each [load] command to call the *_Init() routine again. That said, [package forget] is a rather specialized operation; not really meant for much use in programs. Avoid if possible.
hobbsplain2005-04-05 00:30:58
Logged In: YES
user_id=72656
This is clearly a misunderstanding on the part of the user.
Maybe the docs need clarification, but it's not a bug.
package forget forgets the 'ifneeded' part, which is of
course why the next package require will fail. It does
nothing else - it does not unload any packages. The 'info
loaded' is still 100% correct, as those dlls are still
loaded. You could still say 'load {} Tkhtml|Tktable' and
they will load.
dgpplain2005-04-05 00:40:04
Logged In: YES
user_id=80530
"package forget forgets the 'ifneeded' part, which is of
course why the next package require will fail."
Not so. [package forget] will forget all the
ifneeded scripts for all versions of Tkhtml, so
the next [package require Tkhtml] will invoke
[package unknown] to find those scripts again.
Nothing in the report suggests that second
search fails. The ifneeded script(s) get restored
back to the package database, but the report
is that they do not work the second time because
[load] doesn't work on the second pass.
"You could still say 'load {} Tkhtml|Tktable' and
they will load."
As I understand the report, this is not working.
dgpplain2005-04-05 01:02:12
Logged In: YES user_id=80530 Thinking more about this, having [load] call the same Foo_Init() routine a second time also has problems. It's quite likely many existing packages haven't had their Foo_Init() routines written to handle that case. Seems the only reasonable advice that can be given is: DO NOT USE [package forget].
hobbsplain2005-04-05 02:17:46
Logged In: YES
user_id=72656
As to the 'load {} Tkhtml|Tktable', it certainly does still
work, as would be expected when the library is still loaded.
Tested with Tktable just fine. I would agree that 'package
forget' mostly sucks in terms of being confusing/useless.
eriklnsplain2005-04-06 23:52:09
Logged In: YES
user_id=113903
The manual page for [load] says:
"If a given fileName is loaded into multiple
interpreters, then the first load will load the code and
call the initialization procedure; subsequent loads will
call the initialization procedure without loading the code
again.
It is not possible to unload or reload a package."
I've tested this with a small package "loadtest", by letting
Loadtest_Init emit a message to stdout.
When exercising the following at the Tcl prompt you will
find that the message is emitted with the first [load]
command. I didn't see that message when issuing the command
the second time and the namespace ::loadtest, created at the
first load, then deleted with ::loadtest::terminate, was not
recreated with the second [load].
% load ./loadtest/loadtest.so
% namespace exists ::loadtest
1
% loadtest::terminate
% namespace exists ::loadtest
0
% info loaded
{./loadtest/loadtest.so Loadtest} {{} Tk}
% load {} Loadtest
% namespace exists ::loadtest
0
%
Therefore, I believe that the _Init proc is not called a
second time as the man page desscribes.
The C code with build script has been uploaded.
eriklns Pending ticket [1176470fff].
[History diff]2005-04-06 23:52:42
eriklnsplain2005-04-06 23:59:40
Logged In: YES user_id=113903 I withdraw the last post. The case that I tested was when loading into the same main interp and that is not what the man page describes. _Init will only be called a second time when loading into a different interp. Sorry.
dgpplain2005-11-17 01:39:24
Logged In: YES user_id=80530 Converting this into a Feature Request for Tcl 8.5
dgpplain2005-11-17 01:45:23
data_type - 360894
dgp Ticket [1176470fff]: 3 changes
[History diff]2005-11-17 01:45:24
dgpplain2005-11-17 01:45:25
Logged In: YES user_id=80530 Converting this into a Feature Request for Tcl 8.5 Thing to watch out for is whether there are existing Foo_Init() routines that are not robust enough to accept multiple calls with the same interp argument. Note that the ability for a second [load] to call Foo_Init() to correct possible errors from the first Foo_Init() is more important since Bug 1162286 was fixed.
Log in (anonymous is fine) to add a comment.