From: ara.t.howard@... Date: 2007-03-12T14:21:26+09:00 Subject: Re: #define alternative for Ruby On Mon, 12 Mar 2007, Mike wrote: > > I was talking more about macros rather then constants. But I agree that > constant are convenient way to substitute "#define myconst 15". But can you > substitute "#define myfunc(x) (sin(x)*cos(x)*exp(x))"? You should know that > "x" could be as much other functions as a constant/variable. > perhaps i'm being dense, but i fail to see how the above example is none other than a simple function in ruby: harp:~ > cat a.rb def myfunc x Math.sin(x) * Math.cos(x) * Math.exp(x) end # x as function def x() 42 end p myfunc(x) # x as constant X = 42 p myfunc(X) # x as variable x = 42 p myfunc(x) harp:~ > ruby a.rb 6.37609775534436e+17 6.37609775534436e+17 6.37609775534436e+17 text macros like the above are really only useful in static/strong typed languages. in ruby, they are rather meaningless. regards. -a -- be kind whenever possible... it is always possible. - the dalai lama