From: KDr2 Date: 2009-04-29T23:51:32+09:00 Subject: Re: Ruby Interface of Erlang --000e0cd28d78fa39510468b2b698 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Thank you for your advise :) They are very useful for me. On Wed, Apr 29, 2009 at 9:43 PM, Brian Candler wrote: > KDr2 wrote: > > see the section Erlix RPC on > > http://code.google.com/p/erlix/wiki/ErlixTutorial > > Just a thought: if you were to move all these constants into an Erlix > module (e.g. Erlix::Tuple, Erlix::Int etc) then you could 'include > Erlix' and save a lot of typing. The only conflict I can see would be > Float, and you can always use ::Float to get the Ruby one should you > need it. > > The separate namespace can also be useful when creating objects > dynamically: > type = "Tuple" > obj = Erlix.const_get(type).new > > You could also consider module functions as a shortcut for constructors. > > module Erlix > # Fake implementation > class Tuple > def initialize(*x) > @data = *x > end > end > class Int > def initialize(x) > @data = x > end > end > > # Module functions > def Tuple(*x) > Tuple.new(*x) > end > module_function :Tuple > def Int(*x) > Int.new(*x) > end > module_function :Int > # etc > end > > include Erlix > puts Tuple(Tuple(Int(1)), Int(2)).inspect > > Regards, > > Brian. > -- > Posted via http://www.ruby-forum.com/. > > -- Best Regards, -- KDr2, at x-macro.com. --000e0cd28d78fa39510468b2b698--