On Sun, Jan 27, 2008 at 12:45:22PM -0500, Kris Maglione wrote:
Heh... it's more like the standard assert(foo == bar). It just uses a function rather than pushing a method on the entire object hierarchy. It seems much clearer to me. The == operator doesn't have a new meaning foisted on it, and it's clear that the want function is not a method of whatever object it's operating on.
I suppose the idea behind this is that the two values can be inspected and printed. I still think it's not ideal, though. I'd prefer something like:
class Want
class <<self
%w{== < > <= >= !=}.each do |op|
class_eval %{
def #{op} a, b
try a #{op} b, a, "#{op}", b
end
}
end
private
def try result, arga, op, argb
if !result
print "#{caller[1]}: Want #{arga} #{op} #{argb}; got
#{result}\n"
end
end
end
end
Want.== ret.type, Fcall.type
Anyway, feel free to ignore this. I haven't given it any real thought.
--
Kris Maglione
Real programmers don't write in Pascal, Bliss, or Ada, or
any of those pinko computer science languages. Strong
typing is for people with weak memories.
pgp8eVj2nTGR2.pgp
Description: PGP signature
