[PLUG] perl question, Math::Matrix stuff

Eric Wilhelm scratchcomputing at gmail.com
Sat May 6 04:16:24 UTC 2006


# from Dave
# on Friday 05 May 2006 11:49 am:

>Here's what I found after a bit of digging:
>- Math Matrix is bad perl mojo, as it doesn't let you get at the
> innards well if you want to.

use overload
       '~'  => 'transpose',
       '+'  => 'add',
       '-'  => 'subtract',
       '*'  => 'multiply',
       '""' => 'as_string';

>Overall, I rate this: "dirty hack"

Not really.  It's actually pretty well written OO.  Whether overloading 
in Perl is a dirty hack, well -- in an "everything is a string" 
language, it sometimes gets confusing.

The first time you run into it, it might seem weird.  If it's not done 
well, the DWIM might bite you.  But overall it's pretty 
straightforward.

Now, explain why the pure, clean, and consistent OO language has this 
speed-bump in the syntax?

#!/usr/bin/ruby

puts a=lambda {|x|
  f=x+1
  s=f**2
  s/f
}.call(2)

a=lambda do |x|
  f=x+1
  s=f**2
  s/f
end.call(2)
puts a

puts a=lambda do |x|
  f=x+1
  s=f**2
  s/f
end.call(2)

--Eric
-- 
"Those who cannot remember the past are condemned to repeat it."
--George Santayana
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------



More information about the PLUG mailing list