Hello everybody,

	I'd like to ask you if you're going to (love|hate) this approach.

	What it is about?

	Introduction:
		You have lib. in 'C' that have struct BN (BigNums) and some 
	functions for it in lib. There are funcs for BN *BN_new(), hex2bn(BN *, char *), 
	dec2bn(BN *, char *) and so on.
		I'd like to wrap this lib to Ruby, but I'd like to make 'smart' :-)

	Solution 1 - Traditional:

		BN::new(*) - in 'C', WrapsStruct and BN_new()
		bn.initialize(str, type=DEC) - in 'C', handles all in code, complex

	(+) easy
	(+) fast
	(-) cannot be enhanced (enhanced only via aliasing old init and making new one (?))

	Solution 2 - General (SmallTalk's (?))

		BN::new(*) - in 'C', WrapsStruct and BN_new()

		class BN
			def initialize(arg=nil, type=DEC)
				send("from_#{type.class.name.downcase}", arg, type)
			end
			def from_fixnum(arg, type=DEC)
				from_string(arg.to_s, type)
			end
			def from_string(arg, type=DEC)
				send("from_#{type.downcase}", arg)
			end
		end

		bn.from_dec(str) - in 'C' - stupid
		bn.from_hex(str) - in 'C' - stupid

	(-) complex (?) - breaks KISS (?) (- breaks POLS (???))
	(-) slower
	(+) very easy to add own 'from_...' method
	
	So are you going to love it or 'Traditional' approach is better 
	from your point of view?

		Michal


PS: Better initialize like this:

	def initialize(arg=nil, type=DEC)
		type = arg.class
		while type
			method = "from_#{type.name.downcase}".intern
			return send(method, arg, type) if respond_to? method
			type = type.superclass
		end
		raise "Don't know how to init from #{arg.class.name}"
	end
	

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Michal Rokos                           Czech Technical University, Prague
E-mail: m.rokos / sh.cvut.cz         Jabber: majkl / jabber.cz, ICQ: 36118339
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-