Ilmari Heikkinen
1/16/2005 4:38:00 AM
> Let say you're Matz, but without any of the pressures of keeping up
> with a
> previous version of Ruby. What one thing above all others would you
> like to
> see differ about Ruby?
Couldn't think of much else.. well, there's the usual Marshallable
Everything, Tail-call Optimization, Real Threads, Automatic Parallelism
:) (ie. array.map{|x| do_something_expensive(x)} would automagically do
all maps in parallel)
But here's one:
Syntax sugar for parameter pattern matching + reflection for it
def sum(x, 0)
x
when (_,100)
raise "100 is bad number"
when (x,y)
sum(x+1, y-1)
end
would mean
def sum(x, y)
case [x,y]
when [x,0]
x
when [x,100]
raise "100 is bad number"
when [x,y]
sum(x+1, y-1)
end
end
And you could query & edit them:
s = method(:sum)
s.patterns
# => {(x,0)=>Method, (_,100)=>Method, (x,y)=>Method}
s.patterns.delete((_,100))
s.patterns[(x,y)] = Method.new{|x,y| x+y}