Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/Faking+tcl%3A%3Amathop%3A%3A%26%26+and+%7C%7C?V=0
QUERY_STRINGV=0
CONTENT_TYPE
DOCUMENT_URI/revision/Faking+tcl::mathop::&&+and+||
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.70.178.156
REMOTE_PORT33320
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR18.218.70.93
HTTP_CF_RAY87f118215a186345-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_IP18.218.70.93
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 {Faking tcl::mathop::&& and ||} {
The set of [tcl::mathop] commands does not include commands corresponding to the `[&&]` or `[||]` for reasons that are, well, reasonable.  You can still (easily) fake them on lists of values that are a subset of the general set of boolean values, namely 0 (falsity) and all non-zero numerical values (truth).  (You can also fake them on general boolean values, but not as easily or conveniently.)

Any boolean expression evaluates to these values, or can be trivially converted to one of these two values by applying the logical negation (NOT, `!`) twice:

======
set foo [list true 1 [expr {5 > 2}]]
# => true 1 1
set bar [lmap elem $foo { expr {!!$elem} }]
# => 1 1 1
======

This means that we can use `tcl::mathop::*` to perform a multi-argument AND operation on these values:

======
::tcl::mathop::* {*}$bar
# => 1
::tcl::mathop::* {*}[lmap elem [list [expr {5 > 2}] [expr {5 > 4}] [expr {5 > 7}]] { expr {!!$elem} }]
# => 0
======

since the semantics of multiplication corresponds to the semantics of conjunction (AND) when the domain of boolean values is defined this way.  Even in the case where there are no arguments provided the semantics are a fit, since the multiplicative and the conjunctive identities are both 1.

An important caveat is that there is no short-circuit evaluation: every argument is evaluated.

Multi-argument OR can also be faked:

======
::tcl::mathop::+ {*}$bar
# => 1
::tcl::mathop::+ {*}[lmap elem [list [expr {5 > 12}] [expr {5 > 14}] [expr {5 > 7}]] { expr {!!$elem} }]
# => 0
======

since the semantics of addition corresponds to the semantics of inclusive disjunction (OR) when the domain of boolean values is defined this way.  Even in the case where there are no arguments provided the semantics are a fit, since the additive and the disjunctive identities are both 0.

An important caveat is (as above) that there is no short-circuit evaluation: every argument is evaluated.Commands can be implemented for these operations in this way (but again, for every set of boolean values that aren't the boolean literals `on`, `true`, etc, the `tcl::mathop::*` and `+` commands are sufficient):

Commands can be implemented for these operations in this way:
proc listAnd args {
    # Performs serial logical conjunction without short-circuit evaluation.
    # Every argument shall be a pre-evaluated boolean value.
    # If given at least one false value, returns 0, otherwise (including if given no values) returns 1.
    ::tcl::mathop::* {*}[lmap arg $args { expr {!!$arg} }]
}

proc listOr args {
    # Performs serial logical inclusive disjunction without short-circuit evaluation.
    # Every argument shall be a pre-evaluated boolean value.
    # Performs serial logical disjunction without short-circuit evaluation.
    expr {[::tcl::mathop::+ {*}[lmap arg $args { expr {!!$arg} }]] > 0}
}

% listOr [expr {5 > 12}] [expr {5 > 14}] [expr {5 > 7}]
# => 0
% listOr [expr {5 > 12}] [expr {5 > 4}] [expr {5 > 7}]
# => 1
% listAnd [expr {5 > 2}] [expr {5 > 4}] [expr {5 > 7}]
# => 0
% listAnd [expr {5 > 2}] [expr {5 > 4}]
# => 1
======

See also

   * [tcl::mathop]
   * [Math Operators as Commands]


<<categories>> Command | Syntax} regexp2} CALL {my render {Faking tcl::mathop::&& and ||} {
The set of [tcl::mathop] commands does not include commands corresponding to the `[&&]` or `[||]` for reasons that are, well, reasonable.  You can still (easily) fake them on lists of values that are a subset of the general set of boolean values, namely 0 (falsity) and all non-zero numerical values (truth).  (You can also fake them on general boolean values, but not as easily or conveniently.)

Any boolean expression evaluates to these values, or can be trivially converted to one of these two values by applying the logical negation (NOT, `!`) twice:

======
set foo [list true 1 [expr {5 > 2}]]
# => true 1 1
set bar [lmap elem $foo { expr {!!$elem} }]
# => 1 1 1
======

This means that we can use `tcl::mathop::*` to perform a multi-argument AND operation on these values:

======
::tcl::mathop::* {*}$bar
# => 1
::tcl::mathop::* {*}[lmap elem [list [expr {5 > 2}] [expr {5 > 4}] [expr {5 > 7}]] { expr {!!$elem} }]
# => 0
======

since the semantics of multiplication corresponds to the semantics of conjunction (AND) when the domain of boolean values is defined this way.  Even in the case where there are no arguments provided the semantics are a fit, since the multiplicative and the conjunctive identities are both 1.

An important caveat is that there is no short-circuit evaluation: every argument is evaluated.

Multi-argument OR can also be faked:

======
::tcl::mathop::+ {*}$bar
# => 1
::tcl::mathop::+ {*}[lmap elem [list [expr {5 > 12}] [expr {5 > 14}] [expr {5 > 7}]] { expr {!!$elem} }]
# => 0
======

since the semantics of addition corresponds to the semantics of inclusive disjunction (OR) when the domain of boolean values is defined this way.  Even in the case where there are no arguments provided the semantics are a fit, since the additive and the disjunctive identities are both 0.

An important caveat is (as above) that there is no short-circuit evaluation: every argument is evaluated.Commands can be implemented for these operations in this way (but again, for every set of boolean values that aren't the boolean literals `on`, `true`, etc, the `tcl::mathop::*` and `+` commands are sufficient):

Commands can be implemented for these operations in this way:
proc listAnd args {
    # Performs serial logical conjunction without short-circuit evaluation.
    # Every argument shall be a pre-evaluated boolean value.
    # If given at least one false value, returns 0, otherwise (including if given no values) returns 1.
    ::tcl::mathop::* {*}[lmap arg $args { expr {!!$arg} }]
}

proc listOr args {
    # Performs serial logical inclusive disjunction without short-circuit evaluation.
    # Every argument shall be a pre-evaluated boolean value.
    # Performs serial logical disjunction without short-circuit evaluation.
    expr {[::tcl::mathop::+ {*}[lmap arg $args { expr {!!$arg} }]] > 0}
}

% listOr [expr {5 > 12}] [expr {5 > 14}] [expr {5 > 7}]
# => 0
% listOr [expr {5 > 12}] [expr {5 > 4}] [expr {5 > 7}]
# => 1
% listAnd [expr {5 > 2}] [expr {5 > 4}] [expr {5 > 7}]
# => 0
% listAnd [expr {5 > 2}] [expr {5 > 4}]
# => 1
======

See also

   * [tcl::mathop]
   * [Math Operators as Commands]


<<categories>> Command | Syntax}} CALL {my revision {Faking tcl::mathop::&& and ||}} CALL {::oo::Obj6183353 process revision/Faking+tcl%3A%3Amathop%3A%3A%26%26+and+%7C%7C} CALL {::oo::Obj6183351 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