• is this a bug?

    From aotto1968@21:1/5 to All on Sat Apr 22 11:16:16 2023
    hi,

    check the code:


    #!/usr/bin/env tclsh

    proc mytest {a b {c def} {
    set b
    #!/usr/bin/env tclsh

    proc mytest {a b {c def}} {
    set b
    #!/usr/bin/env tclsh

    proc mytest {a b {c def}} {
    set b
    }

    puts "info args mytest = [info args mytest]"
    puts "info body mytest = [info body mytest]"
    <<<

    get the result:


    info args mytest = a b c

    info body mytest =
    set b

    <<<

    as you see the "default" from "info arg" last argument "c" is missing

    man:

    info args procname
    Returns a list containing the names of the arguments to procedure procname, in order. Procname must be the name of a Tcl
    command procedure.

    I need the "info args" including the default !!


    mfg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mike Griffiths@21:1/5 to All on Sat Apr 22 15:42:22 2023
    On Saturday, 22 April 2023 at 10:16:21 UTC+1, aotto1968 wrote:
    hi,

    check the code:


    #!/usr/bin/env tclsh

    proc mytest {a b {c def} {
    set b
    #!/usr/bin/env tclsh

    proc mytest {a b {c def}} {
    set b
    #!/usr/bin/env tclsh

    proc mytest {a b {c def}} {
    set b
    }

    puts "info args mytest = [info args mytest]"
    puts "info body mytest = [info body mytest]"
    <<<

    get the result:


    info args mytest = a b c

    info body mytest =
    set b

    <<<

    as you see the "default" from "info arg" last argument "c" is missing

    man:

    info args procname
    Returns a list containing the names of the arguments to procedure procname, in order. Procname must be the name of a Tcl
    command procedure.

    I need the "info args" including the default !!


    mfg

    You need [info default]

    % proc mytest {a b {c def}} {
    puts foo
    }
    % set arglist [info args mytest]
    a b c
    % set argsDef [list]
    % foreach x $arglist {
    if { [info default mytest $x defval] } {
    lappend argsDef [list $x $defval]
    } else {
    lappend argsDef $x
    }
    }
    % set argsDef
    a b {c def}

    See https://www.tcl.tk/man/tcl/TclCmd/info.html#M12

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From aotto1968@21:1/5 to All on Sun Apr 23 07:58:30 2023
    On 23.04.23 00:42, Mike Griffiths wrote:

    → thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)