Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/procargs?V=29
QUERY_STRINGV=29
CONTENT_TYPE
DOCUMENT_URI/revision/procargs
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.70.100.98
REMOTE_PORT38064
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR3.143.4.181
HTTP_CF_RAY87fcc177aa191b68-ORD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected])
HTTP_CF_CONNECTING_IP3.143.4.181
HTTP_CDN_LOOPcloudflare
HTTP_CF_IPCOUNTRYUS

Body


Error

Unknow state transition: LINE -> END

-code

1

-level

0

-errorstack

INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit procargs {I use this proc to parse a proc's args and allow any parameter to be
specified as a switch [JBR].  

----
To redefine proc so that all future procs are "procargs" enabled:

   procargs proc

To "procargs" enable an existing proc

   procargs existingprocname

To define a proc with "procargs" enabeled

   procargs procname { parameters } { body }

----
I also use it as a replacement for getopt and friends.  I write the 
main function of the scripted command as a proc and then eval that 
proc at the bottom of the file with $argv.

   procargs main { parameter list here } {
        ...
   }
  
   eval main $argv

----
Here is the procargs proc:


======
 interp alias {} _proc {} proc

 proc _procargs { __name __params __args } {
    set __nargs [llength $__args]
    set __npars [llength $__params]

    # Set the defaults
    #
    foreach __par $__params {
        set __param     [lindex $__par 0]
        set __value     [lindex $__par 1]

        if { ![string compare $__par args] } {
            set __acat 1
            break
        }

        upvar $__param $__param
        set   $__param $__value
        lappend __paramnames $__param
    }

    # Set the args
    #
    set __p   0
    set __eoo 0
    for { set __i 0 } { $__i < $__nargs } { incr __i } {
        set __arg [lindex $__args $__i]

        if { $__eoo } {
            set __pnum $__p
            incr __p
        } else {
            switch -regexp -- $__arg {
             ^$         -
             ^-[0-9.]+$ -
             ^[^-].*$  {
                set __pnum $__p
                incr __p
             }
             default {
                if { ![string compare $__arg "--"] } {
                    set __eoo 1
                    continue
                }
                set __pnum [lsearch $__paramnames [string range $__arg 1 end]]
                if { $__pnum < 0 } {
                    error "$__name: no option $__arg: must be one of: $__paramname"
                }
                set __arg [lindex $__args [incr __i]]
             }
            }
        }

        set __param [lindex $__paramnames $__pnum]
        set $__param $__arg
    }
 }

 proc  procargs { args } {
        _procargs procargs { name params body } $args

    if { ![string compare $name proc] } {
        rename _proc     {}
        rename  proc     _proc
        rename  procargs  proc

        return
    }

    if { [llength [info commands $name]] && ![string compare $body {}] }  {
        set args [info args $name]
        set body [info body $name]

        # rebuild params
        #
        foreach arg $args {
            if { [info default $name $arg value] } {
                lappend params "$arg $value"
            } else {
                lappend params "$arg"
            }
        }
    }

    _proc $name { args } "_procargs $name [list $params] \$args; $body"
 }
======

----
[AMG]: Another option is to use [[[dict with]]].  Replace the argument list with `args`, and insert the command `dict with args {}` before the rest of the proc body script.  Now the procedure is called with an even number of arguments, the first, third, fifth, etc. of which are the names of the arguments, followed by the values of the arguments.  Here's the example from [Named arguments]:

======
proc myproc {args} {
   dict with args {}
   puts "$left=$right"
}
myproc left 2+2 right 4
======
[RFox] added a missing double quote at the end of the error command.
======

<<categories>> Argument Processing} regexp2} CALL {my render procargs {I use this proc to parse a proc's args and allow any parameter to be
specified as a switch [JBR].  

----
To redefine proc so that all future procs are "procargs" enabled:

   procargs proc

To "procargs" enable an existing proc

   procargs existingprocname

To define a proc with "procargs" enabeled

   procargs procname { parameters } { body }

----
I also use it as a replacement for getopt and friends.  I write the 
main function of the scripted command as a proc and then eval that 
proc at the bottom of the file with $argv.

   procargs main { parameter list here } {
        ...
   }
  
   eval main $argv

----
Here is the procargs proc:


======
 interp alias {} _proc {} proc

 proc _procargs { __name __params __args } {
    set __nargs [llength $__args]
    set __npars [llength $__params]

    # Set the defaults
    #
    foreach __par $__params {
        set __param     [lindex $__par 0]
        set __value     [lindex $__par 1]

        if { ![string compare $__par args] } {
            set __acat 1
            break
        }

        upvar $__param $__param
        set   $__param $__value
        lappend __paramnames $__param
    }

    # Set the args
    #
    set __p   0
    set __eoo 0
    for { set __i 0 } { $__i < $__nargs } { incr __i } {
        set __arg [lindex $__args $__i]

        if { $__eoo } {
            set __pnum $__p
            incr __p
        } else {
            switch -regexp -- $__arg {
             ^$         -
             ^-[0-9.]+$ -
             ^[^-].*$  {
                set __pnum $__p
                incr __p
             }
             default {
                if { ![string compare $__arg "--"] } {
                    set __eoo 1
                    continue
                }
                set __pnum [lsearch $__paramnames [string range $__arg 1 end]]
                if { $__pnum < 0 } {
                    error "$__name: no option $__arg: must be one of: $__paramname"
                }
                set __arg [lindex $__args [incr __i]]
             }
            }
        }

        set __param [lindex $__paramnames $__pnum]
        set $__param $__arg
    }
 }

 proc  procargs { args } {
        _procargs procargs { name params body } $args

    if { ![string compare $name proc] } {
        rename _proc     {}
        rename  proc     _proc
        rename  procargs  proc

        return
    }

    if { [llength [info commands $name]] && ![string compare $body {}] }  {
        set args [info args $name]
        set body [info body $name]

        # rebuild params
        #
        foreach arg $args {
            if { [info default $name $arg value] } {
                lappend params "$arg $value"
            } else {
                lappend params "$arg"
            }
        }
    }

    _proc $name { args } "_procargs $name [list $params] \$args; $body"
 }
======

----
[AMG]: Another option is to use [[[dict with]]].  Replace the argument list with `args`, and insert the command `dict with args {}` before the rest of the proc body script.  Now the procedure is called with an even number of arguments, the first, third, fifth, etc. of which are the names of the arguments, followed by the values of the arguments.  Here's the example from [Named arguments]:

======
proc myproc {args} {
   dict with args {}
   puts "$left=$right"
}
myproc left 2+2 right 4
======
[RFox] added a missing double quote at the end of the error command.
======

<<categories>> Argument Processing}} CALL {my revision procargs} CALL {::oo::Obj6978904 process revision/procargs} CALL {::oo::Obj6978902 process}

-errorcode

NONE

-errorinfo

Unknow state transition: LINE -> END
    while executing
"error $msg"
    (class "::Wiki" method "render_wikit" line 6)
    invoked from within
"my render_$default_markup $N $C $mkup_rendering_engine"
    (class "::Wiki" method "render" line 8)
    invoked from within
"my render $name $C"
    (class "::Wiki" method "revision" line 31)
    invoked from within
"my revision $page"
    (class "::Wiki" method "process" line 56)
    invoked from within
"$server process [string trim $uri /]"

-errorline

4