View · Index

Stack for integers

Methods can be defined per-class (instproc) or per-object (proc).

Define a single stack for integers:


# Create a stack with a object-specific method
# to check the type of entries
#
# s4 is a stack of integer
 
Stack s4
s4 proc push {value} {
  if {![string is integer $value]} {
    error "value $value is not an integer"
  }   next
}