lib/nydp/truth.rb in nydp-0.1.15 vs lib/nydp/truth.rb in nydp-0.2.0
- old
+ new
@@ -1,17 +1,21 @@
+require 'singleton'
+
module Nydp
class Truth
- def init_with *; Nydp.T ; end
+ include Singleton
+ def init_with *; Nydp::T ; end
def to_s ; 't' ; end
def inspect ; 't[nydp::Truth]' ; end
def assign *_ ; self ; end
def nydp_type ; :truth ; end
def to_ruby ; true ; end
end
class Nil
- def init_with * ; Nydp.NIL ; end
+ include Singleton
+ def init_with * ; Nydp::NIL ; end
def car ; self ; end
def cdr ; self ; end
def size ; 0 ; end
def is? other ; other.class == self.class ; end
def isnt? other ; !is?(other) ; end
@@ -23,15 +27,8 @@
def nydp_type ; :nil ; end
def to_ruby ; nil ; end
def execute vm ; vm.push_arg self ; end
end
- @@nil = Nil.new
- @@t = Truth.new
-
- class Nil
- def self.new ; raise "no" ; end
- end
-
- def self.NIL; @@nil; end
- def self.T; @@t; end
+ NIL = Nil.instance
+ T = Truth.instance
end