You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by Massimo Manghi <mx...@apache.org> on 2016/02/14 23:51:49 UTC

renaming [info] caveats

Hi

I'm trying to find a solution to the existing problem with

[info script]

that doesn't return meaningful information with mod_rivet but I hit a 
problem that perhaps demands deeper insights into Tcl internals.

As a first step I decided to filter every call to [::info ...] by 
renaming the core command and then defining our own ::info procedure. As 
such the following should work as a transparent replacement

rename ::info ::Rivet::tclcore_info
proc ::info {cmd args} {

     return [::Rivet::tclcore_info $cmd {*}$args]

}

I separated the fist argument because more expressive, it follows the 
command syntactical structure and it should make natural to execute the 
test

if { $cmd=="script" } { ...}

in order to return meaningful information. The ::Rivet namespace is 
meant for Rivet internal usage and it's not documented.

Calling [info <option> ...] in a script or rivet template results in a 
weird error though

unknown or ambiguous subcommand "exists": must be add, clicks, format, 
microseconds, milliseconds, scan, or seconds
     while executing
"info exists some_sort_of_variable"
     (in namespace eval "::request" script line 10)
     invoked from within
"namespace eval request {

which seems to suggests I've somehow tampered with some table of 
commands and info got replaced by [clock...]: anyone has suggestions on 
how to properly and safely rename core commands?

-- Massimo

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: renaming [info] caveats

Posted by Massimo Manghi <ma...@unipr.it>.
Thank you Harald for the suggestion, still it shouldn't prevent me from 
renaming a command.

% namespace eval ::A {
     proc a {} { return 0}
     namespace export a
     namespace ensemble create }
::A
% ::A a
0
% rename ::A ::B
% ::B a
0
% ::A a
invalid command name "::A"
while evaluating {::A a}

I think I will seek another way to get around this, even though I could 
figure out how Tcl wants this command to be renamed it looks like a too 
deep tampering with the core language.

   -- Massimo

On 02/15/2016 08:57 AM, Harald Oehlmann wrote:
> Hi Massimo,
>
> AFAIK, info is implemented as an ensemble.
> You can add subcommands just like that.
> I am not sure to which TCL version this is true...
>
> -Harald
>

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: renaming [info] caveats

Posted by Harald Oehlmann <ha...@elmicron.de>.
Hi Massimo,

AFAIK, info is implemented as an ensemble.
You can add subcommands just like that.
I am not sure to which TCL version this is true...

-Harald

Am 14.02.2016 um 23:51 schrieb Massimo Manghi:
> Hi
> 
> I'm trying to find a solution to the existing problem with
> 
> [info script]
> 
> that doesn't return meaningful information with mod_rivet but I hit a
> problem that perhaps demands deeper insights into Tcl internals.
> 
> As a first step I decided to filter every call to [::info ...] by
> renaming the core command and then defining our own ::info procedure. As
> such the following should work as a transparent replacement
> 
> rename ::info ::Rivet::tclcore_info
> proc ::info {cmd args} {
> 
>     return [::Rivet::tclcore_info $cmd {*}$args]
> 
> }
> 
> I separated the fist argument because more expressive, it follows the
> command syntactical structure and it should make natural to execute the
> test
> 
> if { $cmd=="script" } { ...}
> 
> in order to return meaningful information. The ::Rivet namespace is
> meant for Rivet internal usage and it's not documented.
> 
> Calling [info <option> ...] in a script or rivet template results in a
> weird error though
> 
> unknown or ambiguous subcommand "exists": must be add, clicks, format,
> microseconds, milliseconds, scan, or seconds
>     while executing
> "info exists some_sort_of_variable"
>     (in namespace eval "::request" script line 10)
>     invoked from within
> "namespace eval request {
> 
> which seems to suggests I've somehow tampered with some table of
> commands and info got replaced by [clock...]: anyone has suggestions on
> how to properly and safely rename core commands?
> 
> -- Massimo
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
> For additional commands, e-mail: rivet-dev-help@tcl.apache.org
> 


-- 
ELMICRON Dr. Harald Oehlmann GmbH
Koesener Str. 85
06618 Naumburg
Germany
Phone: +49 (0)3445 78112-0
Fax: +49 (0)3445 78112-19
www.Elmicron.de
German legal references:
Geschaeftsfuehrer: Dr. Harald Oehlmann, Jens Oehlmann
UST Nr. / VAT ID No.: DE206105272
HRB 212803 Stendal

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org