A
ara.t.howard
It means "dangerous", and I'm not sure what a dangerous id or class
method would be.
then you'd better not change it right!
;-)
-a
It means "dangerous", and I'm not sure what a dangerous id or class
method would be.
Hi --
I'm afraid I don't follow at all.
It means "dangerous", and I'm not sure what a dangerous id or class
method would be.
[email protected] said:i really think people are not seeing the forest for the trees. the issue with
send/send! is not the name: it's that the concept of both needing certain
methods to work a certain way and allowing, even encouraging via the
popularity of dsl like syntaxes in ruby, that those same methods can be easily
clobbered sets up a loosey-goosey mess that those of us who require our code
to run un-attended for months on end get stomach cramps over.
ara's right. having something like Pervasives would clean this whole
mess up.
though i want to point out, as things are, I think _why has pointed us
in the right direction when it comes to open apis. using dot-based
method_missing is passe. use '/' instead a la Hpricot.
I'm not sure I think Ruby has to give priority to being able to serve
as host language for sub-languages that are in conflict with the core
methods and idioms of Ruby.
It's not a winner-take-all thing,though; just use whatever makes sense
for what you're doing. (Not that I want to encourage the magic dot
(But still, there are lots of possibilities.)
I admit I don't like the name "Pervasives". I could imagine some
class methods on Kernel, possibly, as a kind of back-stop for the
regular existing methods (i.e., I don't want to *have* to do the more
functional style if I don't want to).
though i want to point out, as things are, I think _why has pointed us
in the right direction when it comes to open apis. using dot-based
method_missing is passe. use '/' instead a la Hpricot.
precisely! i'm not hung up on the name either, and i'm NOT advocating
removing any existing methods whatsoever: just the creation of a single
backdoor instead of '__method__', or 'method!' crazy proliferation: it simply
does not scale, is not robust, and has code smell in the sense that the
containment is not OO (one object repsonsible) but is scattered all over the
place via naming conventions.
i really think people are not seeing the forest for the trees. the issue with
send/send! is not the name: it's that the concept of both needing certain
methods to work a certain way and allowing, even encouraging via the
popularity of dsl like syntaxes in ruby, that those same methods can be easily
clobbered sets up a loosey-goosey mess that those of us who require our code
to run un-attended for months on end get stomach cramps over.
Ah ha, my OO-er than thou claim comes back to haunt me! I actually
don't usually talk in terms of more/less OO, and I know I'm guilty of
introducing that into this discussion... but I will say that I don't think
"one object responsible" is a principle of OO. It may be that the ability
to override send is a problem, but obj.send("message") is, I think, a pretty
object-oriented way to go about things.
I have been following this whole dicussion, and I think it is time toheh. i think we're all in agreement then. something should be done so
encapsulate the notion of 'this must always work' for a certain group of
methods. i'm for a module/syntax based solution or, at the very least, a
consistent naming convention. if you're reading matz, what do you think?
is anyone feeling up to summarizing and making a RCR?
-a
I have been following this whole dicussion, and I think it is time to
put my two cents in, and summarize it.
We started not liking how #send would call private methods. and we
need it to not call them, but wait we need soemthing so we can call
those private methds. The most commonly suggested method: #send! But
#send still causes namespace issues. The ultimate solution!...lots of
underscores. We hate those too, hrm. Lets add a new super
class/module/object/thing to the mix, called a Pervasive. When we
need something not unique to a class we call it with Pervasive.method
obj. Wait, then we do Pervasive.new(Foo, :args) every time, and we do
Pervasive.class obj a lot too. This is super ugly, probably breaks
encapsulation, etc... The solution, give the classes those methods,
and make them overriable, and also allow access to the object through
the Pervasive. Problem here though, when writing a library we won't
know that someone overrode a method somewhere else in the chain, so we
are stuck using the Pervasive a lot anyway. Why this isn't a problem
now you might ask? Because we don't have the Pervasive, so people are
less willing to override those methods. We still won't have a good
looking #send that calls private methds. Well, we will, but it needs
a name. I am willing to write up the RCR on this one.
Chris said:We started not liking how #send would call private methods. and we
need it to not call them, but wait we need soemthing so we can call
those private methds. The most commonly suggested method: #send! But
#send still causes namespace issues. The ultimate solution!...lots of
underscores. We hate those too, hrm. Lets add a new super
class/module/object/thing to the mix, called a Pervasive. When we
need something not unique to a class we call it with Pervasive.method
obj. Wait, then we do Pervasive.new(Foo, :args) every time, and we do
Pervasive.class obj a lot too. This is super ugly, probably breaks
encapsulation, etc... The solution, give the classes those methods,
and make them overriable, and also allow access to the object through
the Pervasive. Problem here though, when writing a library we won't
know that someone overrode a method somewhere else in the chain, so we
are stuck using the Pervasive a lot anyway. Why this isn't a problem
now you might ask? Because we don't have the Pervasive, so people are
less willing to override those methods. We still won't have a good
looking #send that calls private methds. Well, we will, but it needs
a name. I am willing to write up the RCR on this one.
"Pervasives.send obj, message" IMO is too long.
P = Pervasives
P.send obj, message
??
Why not get rid of Pervasives / P altogether and simply have some new
keywords in the parser?
send obj message
id obj
P = Pervasives
P.send obj, message
??
shorter would be better alright.
it __has__ to hang of another object otherwise
class C
def foo
send :inspect # keyword or method?
end
end
def if(*a) p a endcat a.rb
keyword 1ruby a.rb
Or maybe
obj!send message
Hmmm ... maybe I need some enlightening, but this is what I came up with ...
def if(*a) p a end
if true then puts 'keyword 1' end
if(true)
puts 'keyword 2'
end
keyword 1
keyword 2
That's the beauty of keywords -- the parser is going to intercept them
and invoke the appropriate function via the lexer. Unless I did not
properly define my "if" method there.
that's pretty good. i was leaning towards a module so we could just try to
write it as an extension now though...
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.