Version 1 of Zarutian's Thingy Package

Updated 2006-10-14 03:08:56

=== Code Start ===

  # Code by Zarutian here is hereby free to everyone to use if they satisfy the following conditions:
  #   1. Dont blame me if this doesnt work for any purpose you intented.
  #   2. Attribute your use of this code
  #   3. Any and all modifications of this code must be shared under these conditions.
  #   4. Any patent infrightment (anywhere and anywhen) is the sole responsibility of the patent holder.
  #      I am sorry if your patent was too obvious or too broad to be infrighted upon but it is no concern of mine.
  package require Tcl 8.5
  package provide thingy 1.2
  proc thingy {name} {
    if {[namespace exists ::things::[set name]]} {
      namespace eval ::things::[set name] { destroy }
      if {[namespace exists ::things::[set name]]} { error }
    }
    namespace eval ::things::[set name] {
      proc dispatch args {
        return [uplevel 1 $args]
      }
      proc destroy {} {
        namespace delete [namespace current]
      }
    }
    proc $name args "namespace eval ::things::[set name] dispatch \$args"
    $name variable this $name
    $name variable creator thingy
    return $name
  }
  proc get {varname} {
    return [uplevel 1 [list set $varname]]
  }

=== Code End ===

Zarutian 02:52 GMT 14. oktober 2006: A variant of Richard Suchenwich thingy one line object orientation system. Please do not change the above code block without conferring with me first. Comments are welcome below.

Category Package Category Pure Tcl