[#86787] [Ruby trunk Feature#14723] [WIP] sleepy GC — ko1@...

Issue #14723 has been updated by ko1 (Koichi Sasada).

13 messages 2018/05/01
[#86790] Re: [Ruby trunk Feature#14723] [WIP] sleepy GC — Eric Wong <normalperson@...> 2018/05/01

ko1@atdot.net wrote:

[#87095] [Ruby trunk Feature#14767] [PATCH] gc.c: use monotonic counters for objspace_malloc_increase — ko1@...

Issue #14767 has been updated by ko1 (Koichi Sasada).

9 messages 2018/05/17

[ruby-core:87037] [Ruby trunk Feature#14758] Add a first-class support for isolated bounded packages / modules / contexts

From: danieldasilvaferreira@...
Date: 2018-05-15 08:33:31 UTC
List: ruby-core #87037
Issue #14758 has been updated by dsferreira (Daniel Ferreira).


Hi Grzegorz,

My proposal regarding the implementation of Internal Interfaces (internal access modifier) https://bugs.ruby-lang.org/issues/9992
was pondered when thinking around those terms but applies to internal classes/modules that can not be set as private.

The idea of some kind of isolation at the namespace level.

What I use to do to hide internal modules and classes all together is to use:

```ruby
module Foo
  class Bar
  end

  private_constant :Foo
end

a = Foo::Bar.new
# => NameError: private constant Foo::Bar referenced
```

As a Best Practice I use the top module as the gem API and let all internal classes and modules as private.
This poses some challenges but by using dependency injection we can easily overcome them.

Also I only test the API. 
I don't unit test internal modules or classes.
That way I'm free to redesign the internal architecture without the need to touch the tests and without breaking anything.
Hope this helps.

P.S.

Would love to hear your thoughts on the Internal Interface proposal!

----------------------------------------
Feature #14758: Add a first-class support for isolated bounded packages / modules / contexts
https://bugs.ruby-lang.org/issues/14758#change-72001

* Author: grzesiek (Grzegorz Bizon)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
While one of the core principles of Ruby is to extend the language in a way it is a most useful and convenient tool that a software developer can have in their toolbox, lack of a first-class isolation on module level can cause some serious problems when project grows beyond some size.

This is especially visible in large projects, where most of the code lives in the `lib/` directory, and there are tens or hundreds of modules there. Ideally we would like to make these modules isolated and hide complexity behind facades. Currently it is not possible to isolate such modules, because a developer can still reach beyond boundary of a bounded context, and use `MyModule::InternalClass` directly.

It is very difficult to enforce boundaries, currently it requires a lot of work to implement complex static analysis rules.

Would it make sense to add support for first-class `package`, `context` or `boundary`, that would be a regular module but would not allow referencing inner constants from outside?

~~~
context MyModule
  class MyIsolatedClass
    # ...
  end

  def self.build
    MyIsolatedClass.new
  end
end

MyModule::MyIsolatedClass # raises context violation
MyModule.build # => Returns an instance of MyModule::MyIsolatedClass
~~~ 

I'm pretty sure that I failed at finding similar feature proposal that has been already submitted, in that case sorry for that!

Please let me know what do you think about that! Thanks in advance! <3



-- 
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>

In This Thread

Prev Next