On 2005.02.06, Dan Chak <[EMAIL PROTECTED]> wrote:
>
> Also, the namespace stuff isn't stripping namespace away, but simply
> making the namespace explicit when the proc was defined in one.  For
> some reason, _not_doing_this_ breaks code in namespaces.  I plucked
> that snippet from OACS's ad_proc.

This is interesting.  I'd like to see a test case demonstrating this
breakage.  I wonder if we'd be better off doing:

    rename proc _proc
    _proc proc {name args body} {
        uplevel [list _proc $name $args $body]
    }

That should work correctly with namespaces.  Another thing that should
be done is examining [lindex [info level 0] 0] to ensure we invoke the
real proc in the right namespace, if it's appropriate: maybe this is
unnecessary.  I'd have to see a code example where it failed to work
correctly because it didn't do this.

> First, I want to make sure our terminology is matching.  When you say
> "master interp," you are referring to the interpreter that is
> processing the private tcl library, correct?

Correct.

> I actually _do_ want the private library to load using the redefined
> proc.  The only time I do not want my version of proc to be used is
> during the "cloning" which causes all the defined procs to be
> redefined with whatever is the current proc command.

So, then, what you want is:

--- 000-redefine-proc.tcl ---

    rename proc _proc
    _proc proc {name args body} {
        # your new proc def here
    }

--- 999-redefine-proc.tcl ---

    rename proc {}
    rename _proc proc

---

This way, your private Tcl library sources with your custom [proc]
definition, but blows it away at the end so before AOLserver dumps the
contents of the master interp's proc definitions, your custom [proc] is
gone, so future child interps don't contain your redefined proc, and
instead use the real thing.

> Next, I tried to use ns_ictl get/save, but it doens't seem to do
> anything.  E.g., I had this load early in my private tcl library, but
> when I print out the value of [ns_ictl get] in a .tcl page, I don't see
> my ns_log calls, and I never see the messages in the log itself,
> either.  If this worked, it would seem like it could take the place of
> 'oncreate' and the 'postcreate' which I am looking for.

Ah, yes - silly me.  You can't use [ns_ictl get] or [ns_ictl save]
during startup because the script is only formed once all of the Tcl
libraries are done sourcing.  I tested this from the control port ...
sorry about that.

Yeah, there really isn't a good way to do a "postcreate" script.  But
then, I often think when your approach requires one, you're probably
doing wrong ... :-)

    "Doctor, it hurts when do I this ..."  "Well, then, don't do that."

-- Dossy

--
Dossy Shiobara                       mail: [EMAIL PROTECTED]
Panoptic Computer Network             web: http://www.panoptic.com/
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to