[ruby-core:63463] Re: Access Modifiers (Internal Interfaces)

From: Zachary Scott <e@...>
Date: 2014-07-01 06:03:32 UTC
List: ruby-core #63463
I would suggest opening a feature request if you feel strongly about adding `internal` to Ruby.

See also: https://bugs.ruby-lang.org/projects/ruby/wiki/HowToRequestFeatures


On Jun 28, 2014, at 11:17 AM, Daniel da Silva Ferreira <danieldasilvaferreira@gmail.com> wrote:

> Hi,
> 
> I’m would like to discuss with you the concept of Internal Interfaces.
> 
> Currently ruby offers three access modifiers choices to set methods visibility:
> - public
> - protected
> - private
> 
> Public methods define what we may call the Public Interface.
> Private methods are private to the class and its subclasses.
> Protected methods are public for the subclasses.
> 
> I would like to work with a new access modifier that would allow the creation of Internal methods.
> 
> Internal methods would be object methods that could only be called within the namespace.
> 
> Ex: module Foo; end
> 
> class Foo::Bar
>  def baz 
>      puts ‘baz’
>   end
>   internal :baz
> end
> 
> class Foo::Qux
>  def baz
>     ::Foo::Bar.new.baz
>  end
> end
> 
> Is this something that we can think about in a future implementation of ruby?
> An extra feature that would not break backward compatibility.
> 
> Cheers,
> Daniel

In This Thread