--MPkR1dXiUZqK+927
Content-Type: multipart/mixed; boundary="h3LYUU6HlUDSAOzy"
Content-Disposition: inline


--h3LYUU6HlUDSAOzy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Nov 12, 2007 at 11:00:55AM +0900, Jordi wrote:
> Summing it up:
> 
> - Surprising or not, sending messages is not the same that calling
> methods in Ruby (there is  a real difference, see method_missing email
> of Matthew in this thread).
> - Honoring visibility is not the same that don't honoring it (obviously)
> 
> So, we can have potentially 4 operations in Ruby 1.8.x:
> 
> 1.- Call method honoring visibility
> 2.- Call method not honoring visibility
> 3.- Send message honoring visibility
> 4.- Send message not honoring visibility
> 
> In Ruby 1.8.x ,  1 is implemented with "." and 4 is implemented with
> "send". AFAIK, 2 and 3 are not implemented.
> IMHO they don't need to!
> The difference between sending a message and calling a method is so
> subtle (in real Ruby implemented world) that most of the times can be
> used like the honoring/not honoring pair of the same operation.
> 
> My personal opinion is make "." behave like "send" respect to
> method_missing. In other words, move "." from 1 to 3. Then kill the
> "call method" concept in Ruby. As I think that concept __is not
> intended to exist__ in the language anyway.
> 
> Also I'd rename "send" for something more like "respond" as the object
> is not sending but receiving, but that is much more of a personal
> taste. :P
> 
> --
> Jordi
> 

I'm not sure I follow you here. It seems to me that the 'dot' is #3; in fact, 
it's the only real way to send a message that will fall back to method_missing 
AND honor visibility. Here's the example:

  class Z
   public
    def pub() 'pub' end 
   protected 
    def prot() 'prot' end 
   private
    def priv() 'priv' end
    def method_missing(msg, *args); "method_missing: #{msg}"; end
  end

  # PUBLIC METHODS
  test.pub
  # ==> "pub"
  test.send(:pub)
  # ==> "pub"
  test.method(:pub).call
  # ==> "pub"

  # PROTECTED METHODS
  test.prot
  # ==> "method_missing: prot"
  test.send(:prot)
  # ==> "prot"
  test.method(:prot).call
  # ==> "prot"

  # PRIVATE METHODS
  test.priv
  # ==> "method_missing: priv"
  test.send(:priv)
  # ==> "priv"
  test.method(:priv).call
  # ==> "priv"

  # METHODS THAT DON'T EXIST
  test.doesnt_exist
  # ==> "method_missing: doesnt_exist"
  test.send(:doesnt_exist)
  # ==> "method_missing: doesnt_exist"
  test.method(:doesnt_exist).call
  #! #<NameError: (eval):1:in `method': undefined method `doesnt_exist' forlass `Z'>

--
Matthew Boeh

--h3LYUU6HlUDSAOzy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ruby-messages.rb"

class Z
 public
  def pub() 'pub' end
 protected
  def prot() 'prot' end
 private
  def priv() 'priv' end
  def method_missing(msg, *args); "method_missing: #{msg}"; end
end
def try_out(test, expr)
  begin
    puts expr
    puts "#  #{eval(expr).inspect}"
  rescue e
    puts "#! #{e.inspect}"
  end
end
test  .new
try_out(test, "test.pub")
try_out(test, "test.send(:pub)")
try_out(test, "test.method(:pub).call")
try_out(test, "test.prot")
try_out(test, "test.send(:prot)")
try_out(test, "test.method(:prot).call")
try_out(test, "test.priv")
try_out(test, "test.send(:priv)")
try_out(test, "test.method(:priv).call")
try_out(test, "test.doesnt_exist")
try_out(test, "test.send(:doesnt_exist)")
try_out(test, "test.method(:doesnt_exist).call")

--h3LYUU6HlUDSAOzy--

--MPkR1dXiUZqK+927
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFHN9WDfi+i1R7d/ZwRAg5QAJ9xS6jT4jDu3SIeDbDqzharOyWLBgCfXRpE
grrOZg4zjEbxbmdabD1NIHE▀┌m
-----END PGP SIGNATURE-----

--MPkR1dXiUZqK+927--