I've been thinking about the last thread on module methods and
namespaces, and also the idea of method modifiers. There are times when
I just want one method that does a number of different but related
things. Th obligatory silly example,
class T
def dothis(sym, *args)
when :oneway
puts "One Way! #{args}"
when :another
puts "Another! #{args}"
end
end
end
t = T.new
t.dothis :oneway
But we can also do this without the space,
t.dothis:another
I think this in itself is pretty nice.
IMO that's nice. And allows me to get the effect that I want. What
would be even more convenient thgouh is if this later form, lacking the
space, would give the method precedence, so we could do,
t.dothis:another.upcase
and it would work, executing #dothis before #upcase. Then, also,
secondary parameters could be given without the initial comma. So,
t.dothis :oneway, 1
could instead be written,
t.dothis:oneway 1
Musing on this, you know what'd be really great? Support for partial
function application! I suppose this could already be emulated (or,
more aptly, evamulated), but it could be a really useful feature.
Those pesky side-effects just get in the way but I'm sure that could
be overcome
I do not think this would present any ambiguity to the parser. In fact
I thnk it can be take to any number of initial symbols.
t.dothis:oneway:twoway:threeway
Where each subsequent symbol is another argument.
Musing on this, you know what'd be really great? Support for >
partial function application! I suppose this could already be
emulated (or, more aptly, evamulated), but it could be a really >
useful feature. Those pesky side-effects just get in the way
but I'm sure that could be overcome
Forgive me but I have no idea what you are talking about. If you are
being serious, what is partial function application? What would the
advantages be? Would the advantage offset the disadvatages it may
create elsewhere? If you were not, then please don't afford yourself as
so funny.
I believe it was Richard Feynman who said, though I paraphrase, "Never
underestimate the power of a new notation."
I personally can't stand alias' syntax. Since we are discussing syntax changes, I vote to have the alias method in its current form deprecated so it can be replaced with something more normal.
ยทยทยท
On Jan 31, 2005, at 9:50 PM, Trans wrote:
It just occured to me that there is already one "method" in Ruby that
already does this with two arguments:
alias:dothis:another
I'm just looking toward the apparent generalization of the speicalized
behavior.