Issue #12697 has been updated by Robert A. Heiler.


This is somewhat an interesting comment made here, epecially in regards to .send().

Take code snippets such as here:

    https://gist.github.com/melborne/665406/4a2a732b1c35b290ddb5a08661453704b8d3c047#file-irc-rb

Quote:

    require "term/ansicolor"
    String.send(:include, Term::ANSIColor)

I think I myself has used similar ways for .send(), but in another context. I only vaguely remember
that if I would not have used .send() I would have gotten a method about using a private method.
So that confused me, since I could overrule it anyway via .send() - so essentially, ruby forced
me to use a more verbose way rather than the shorter. It was not a huge issue for me at all since
I really like .send() anyway. I also remember the addition of .public_send() to respect visibility
but I myself just happily use .send() since it is shorter. :)

So on this particular problem, I somewhat concur with "bug hit" on principle. But perhaps there
are other reasons why this is not wanted.

I think that matz once said that private/public do not make as much sense in ruby simply because
ruby is so extremely dynamic and flexible. But perhaps there were other reasons too, e. g. the
.public_send() - it is a bit strange though because to me the public/private distinction does
not really add a lot of necessary things other than restricting what can be done - but .send()
can bypass this anyway, so I am a bit confused.

I mention .send in particular because it was the only one where I noticed the above - I myself
do not use alias_method(), I prefer the shorter alias, even if it is not fully equivalent (I
am sorry, I think being terse is prettier when it is still readable.)

----------------------------------------
Feature #12697: Why shouldn't Module meta programming methods be public?
https://bugs.ruby-lang.org/issues/12697#change-60253

* Author: bug hit
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Methods like alias_method, attr_accessor, define_method, and similar

I don't think Ruby discourages this kind of meta programming, so why make it less convenient, by necessitating `send` or `module_eval`?



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>