Error processing request
Parameters
CONTENT_LENGTH | 0 |
REQUEST_METHOD | GET |
REQUEST_URI | /revision/Visitor+Pattern?V=0 |
QUERY_STRING | V=0 |
CONTENT_TYPE | |
DOCUMENT_URI | /revision/Visitor+Pattern |
DOCUMENT_ROOT | /var/www/nikit/nikit/nginx/../docroot |
SCGI | 1 |
SERVER_PROTOCOL | HTTP/1.1 |
HTTPS | on |
REMOTE_ADDR | 172.70.100.100 |
REMOTE_PORT | 12774 |
SERVER_PORT | 4443 |
SERVER_NAME | wiki.tcl-lang.org |
HTTP_HOST | wiki.tcl-lang.org |
HTTP_CONNECTION | Keep-Alive |
HTTP_ACCEPT_ENCODING | gzip, br |
HTTP_X_FORWARDED_FOR | 3.145.178.157 |
HTTP_CF_RAY | 87e4e1c49abe5c93-ORD |
HTTP_X_FORWARDED_PROTO | https |
HTTP_CF_VISITOR | {"scheme":"https"} |
HTTP_ACCEPT | */* |
HTTP_USER_AGENT | Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected]) |
HTTP_CF_CONNECTING_IP | 3.145.178.157 |
HTTP_CDN_LOOP | cloudflare |
HTTP_CF_IPCOUNTRY | US |
Body
Error
Unknow state transition: LINE -> END
-code
1
-level
0
-errorstack
INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit {Visitor Pattern} {The '''Visitor Pattern''' is an [OO] [Design Pattern] that makes it easy
to add new operations to a set of related classes without having to modify
each class to add the new method. It is somewhat related to pattern matching and
[algebraic types]. General discussions at [http://en.wikipedia.org/wiki/Visitor_pattern]
and [http://c2.com/cgi/wiki?VisitorPattern].
Here is a simple example in Tcl
to demonstrate the idea. The example here will be a simple OO tree representing
integer arithmetic expressions (similar to [expr], but much simpler). First, we
define the nodes that represent each class, and give each a ''visit'' method:
======
package require XOTcl 1.5
namespace import xotcl::*
# A dummy Term class as superclass
Class Term
# Integers
Class Int -superclass Term
Int method init val { my set val $val }
Int method visit v { $v visitInt [my set val] }
# Addition
Class Add -superclass Term
Add method init {a b} { my set a $a; my set b $b }
Add method visit v {
my instvar a b
$v visitAdd [$a visit $v] [$b visit $v]
}
# Multiplication
Class Mul -superclass Term
Mul method init {a b} { my set a $a; my set b $b }
Mul method visit v {
my instvar a b
$v visitMul [$a visit $v] [$b visit $v]
}
# Create an example: t1 = (12 + (3 * 4))
Add t1 [Int new 12] [Mul new [Int new 3] [Int new 4]]
======
We can now use these ''visit'' methods to define as many operations as we want over
our complex data-type:
======
# Pretty printer
Object pprint
pprint proc visitInt val { return $val }
pprint proc visitAdd {a b} { return "($a + $b)" }
pprint proc visitMul {a b} { return "($a * $b)" }
# Simple interpreter/calculator
Object calc
calc proc visitInt val { return $val }
calc proc visitAdd {a b} { expr {$a + $b} }
calc proc visitMul {a b} { expr {$a * $b} }
# Example:
puts "[t1 visit pprint] = [t1 visit calc]"
#=> (12 + (3 * 4)) = 24
----
!!!!!!
%| [Category Example] | [Category Design Pattern] |%
!!!!!!} regexp2} CALL {my render {Visitor Pattern} {The '''Visitor Pattern''' is an [OO] [Design Pattern] that makes it easy
to add new operations to a set of related classes without having to modify
each class to add the new method. It is somewhat related to pattern matching and
[algebraic types]. General discussions at [http://en.wikipedia.org/wiki/Visitor_pattern]
and [http://c2.com/cgi/wiki?VisitorPattern].
Here is a simple example in Tcl
to demonstrate the idea. The example here will be a simple OO tree representing
integer arithmetic expressions (similar to [expr], but much simpler). First, we
define the nodes that represent each class, and give each a ''visit'' method:
======
package require XOTcl 1.5
namespace import xotcl::*
# A dummy Term class as superclass
Class Term
# Integers
Class Int -superclass Term
Int method init val { my set val $val }
Int method visit v { $v visitInt [my set val] }
# Addition
Class Add -superclass Term
Add method init {a b} { my set a $a; my set b $b }
Add method visit v {
my instvar a b
$v visitAdd [$a visit $v] [$b visit $v]
}
# Multiplication
Class Mul -superclass Term
Mul method init {a b} { my set a $a; my set b $b }
Mul method visit v {
my instvar a b
$v visitMul [$a visit $v] [$b visit $v]
}
# Create an example: t1 = (12 + (3 * 4))
Add t1 [Int new 12] [Mul new [Int new 3] [Int new 4]]
======
We can now use these ''visit'' methods to define as many operations as we want over
our complex data-type:
======
# Pretty printer
Object pprint
pprint proc visitInt val { return $val }
pprint proc visitAdd {a b} { return "($a + $b)" }
pprint proc visitMul {a b} { return "($a * $b)" }
# Simple interpreter/calculator
Object calc
calc proc visitInt val { return $val }
calc proc visitAdd {a b} { expr {$a + $b} }
calc proc visitMul {a b} { expr {$a * $b} }
# Example:
puts "[t1 visit pprint] = [t1 visit calc]"
#=> (12 + (3 * 4)) = 24
----
!!!!!!
%| [Category Example] | [Category Design Pattern] |%
!!!!!!}} CALL {my revision {Visitor Pattern}} CALL {::oo::Obj5355825 process revision/Visitor+Pattern} CALL {::oo::Obj5355823 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