Hija,
been makin a little "Vector" class by extending Array.
Now I wanna add Vector support to the native numeric
data types in ruby. Means: Not only Vector+Numeric
but also Numeric+Vector should call my + function.
But I have a syntax prolem..
Example (not working!):
class Fixnum
聽聽alias old+ + # here i have the syntax problem
聽聽def +(other)
聽聽聽聽if (other.class<=Vector)
聽聽聽聽聽聽other+self
聽聽聽聽else
聽聽聽聽聽聽self.old+(other)
聽聽聽聽end
聽聽end
end
Someone please help poor ruby nooby! :-)))
Regards, 0ffh
路路路
--
Posted via http://www.ruby-forum.com/.
Use this alias line...
alias :old_plus :+
both of the arguments to alias need to be symbols. also, "old+" wont be a
happy method name.
Mark
路路路
On 5/6/06, Frank Hirsch <0ffh@frankhirsch.net> wrote:
Hija,
been makin a little "Vector" class by extending Array.
Now I wanna add Vector support to the native numeric
data types in ruby. Means: Not only Vector+Numeric
but also Numeric+Vector should call my + function.
But I have a syntax prolem..
Example (not working!):
class Fixnum
alias old+ + # here i have the syntax problem
def +(other)
if (other.class<=Vector)
other+self
else
self.old+(other)
end
end
end
Someone please help poor ruby nooby! :-)))
Regards, 0ffh
--
Posted via http://www.ruby-forum.com/\.
--
Mark Van Holstyn
mvette13@gmail.com
http://lotswholetime.com
Mark Van Holstyn wrote:
alias :old_plus :+
both of the arguments to alias need to be symbols.
also, "old+" wont be a happy method name.
Thanks alot!
Actually I have already tried "alias :old+ :+",
which gave a syntax error as well, but I didn't
realise it was yet another one...
Regards, 0ffh
路路路
--
Posted via http://www.ruby-forum.com/\.
If you're not doing it for the fun of it: there are already vector and
matrix classes for Ruby plus libraries for manipulating them like
narray (see the RAA).
Kind regards
robert
路路路
2006/5/6, Frank Hirsch <0ffh@frankhirsch.net>:
Mark Van Holstyn wrote:
> alias :old_plus :+
> both of the arguments to alias need to be symbols.
> also, "old+" wont be a happy method name.
Thanks alot!
Actually I have already tried "alias :old+ :+",
which gave a syntax error as well, but I didn't
realise it was yet another one...
--
Have a look: http://www.flickr.com/photos/fussel-foto/
Robert Klemme wrote:
If you're not doing it for the fun of it: there are already vector and
matrix classes for Ruby plus libraries for manipulating them like
narray (see the RAA).
I have seen and downloaded narray.
I don't use it because it is usually more hassle to
get stuff like that running and learn how to use it
and then find out that it is not quite what you've
been looking for after all than just DIY...
I am sitting here in a Hotel room with a newbought,
virgin Windoze notebook. I don't even want to try
to estimate how long it will take me to get the
compiler, utilities and whatnot up and running to
even _start_ to compile narray.
But if I can get no-hassle installable binaries
somewhere, I'll be happy to give it a chance.
Regards, Frank
路路路
--
Posted via http://www.ruby-forum.com/\.
Frank Hirsch wrote:
I am sitting here in a Hotel room with a newbought,
virgin Windoze notebook. I don't even want to try
to estimate how long it will take me to get the
compiler, utilities and whatnot up and running to
even _start_ to compile narray.
But if I can get no-hassle installable binaries
somewhere, I'll be happy to give it a chance.
Regards, Frank
Ah... the reason that made my avoid so many Perl modules in my time... I
guess it's the same for Ruby. Perhaps it should be made a custom that
every extension library has a pure-Ruby version. This is useful for
prototyping - if one sees that the library fits his needs, he can later
put in the effort to actually compile and bind the extension to his
Ruby.
Perhaps a parallel for ActiveState's PPM (pre compiled modules) would be
nice. Unfortunately, Ruby still has no ActiveState version. Anyone knows
about plans to make it ?
路路路
--
Posted via http://www.ruby-forum.com/\.
Eli Bendersky wrote:
Perhaps a parallel for ActiveState's PPM (pre compiled modules) would be
nice. Unfortunately, Ruby still has no ActiveState version. Anyone knows
about plans to make it ?
No idea, but it makes for a very attractive idea!
Reagrds, 0ffh
路路路
--
Posted via http://www.ruby-forum.com/\.