[ruby-core:63467] [ruby-trunk - Feature #9992] Access Modifiers (Internal Interfaces)

From: e@...
Date: 2014-07-01 06:12:42 UTC
List: ruby-core #63467
Issue #9992 has been updated by Zachary Scott.


 Ehh, sorry I must have missed #9992
=20
=20
 On Jun 30, 2014, at 11:03 PM, Zachary Scott <[email protected]> wrote:
=20
 > I would suggest opening a feature request if you feel strongly about add=
ing `internal` to Ruby.
 >=20
 > See also: https://bugs.ruby-lang.org/projects/ruby/wiki/HowToRequestFeat=
ures
 >=20
 >=20
 > On Jun 28, 2014, at 11:17 AM, Daniel da Silva Ferreira <danieldasilvafer=
[email protected]> wrote:
 >=20
 >> Hi,
 >>=20
 >> I=E2=80=99m would like to discuss with you the concept of Internal Inte=
rfaces.
 >>=20
 >> Currently ruby offers three access modifiers choices to set methods vis=
ibility:
 >> - public
 >> - protected
 >> - private
 >>=20
 >> 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.
 >>=20
 >> I would like to work with a new access modifier that would allow the cr=
eation of Internal methods.
 >>=20
 >> Internal methods would be object methods that could only be called with=
in the namespace.
 >>=20
 >> Ex: module Foo; end
 >>=20
 >> class Foo::Bar
 >> def baz
 >>     puts =E2=80=98baz=E2=80=99
 >>  end
 >>  internal :baz
 >> end
 >>=20
 >> class Foo::Qux
 >> def baz
 >>    ::Foo::Bar.new.baz
 >> end
 >> end
 >>=20
 >> Is this something that we can think about in a future implementation of=
 ruby?
 >> An extra feature that would not break backward compatibility.
 >>=20
 >> Cheers,
 >> Daniel
 >

----------------------------------------
Feature #9992: Access Modifiers (Internal Interfaces)
https://bugs.ruby-lang.org/issues/9992#change-47506

* Author: Daniel Ferreira
* Status: Open
* Priority: Normal
* Assignee:=20
* Category:=20
* Target version:=20
----------------------------------------
Hi,
=20
I=E2=80=99m would like to discuss with you the concept of Internal Interfac=
es.
=20
Currently ruby offers three access modifiers choices to set methods visibil=
ity:

- 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.
=20
I would like to work with a new access modifier that would allow the creati=
on of Internal methods.
=20
Internal methods would be object methods that could only be called within t=
he namespace.
=20
Ex:

~~~ruby
module Foo; end

class Foo::Bar
  def baz=20
     puts =E2=80=98baz=E2=80=99
  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 rub=
y?
An extra feature that would not break backward compatibility.
=20
Cheers,
Daniel



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

In This Thread

Prev Next