[#32676] VC++ embedded rubygems gives NoMethodError undefined method `synchronize' for Mutex — Phlip <phlip2005@...>
[I will try Bill Kelly's PDB path advice presently; this issue is more
5 messages
2010/10/03
[#32687] Re: VC++ embedded rubygems gives NoMethodError undefined method `synchronize' for Mutex
— Roger Pack <rogerdpack2@...>
2010/10/04
> This one's about...
[#32703] Re: VC++ embedded rubygems gives NoMethodError undefined method `synchronize' for Mutex
— Phlip <phlip2005@...>
2010/10/05
> > #<NoMethodError: undefined method `synchronize' for #<Mutex:0x750faa8>>
[#32698] [Ruby 1.9-Feature#3908][Open] private constant — Yusuke Endoh <redmine@...>
Feature #3908: private constant
10 messages
2010/10/05
[#32795] Call for Cooperation: CFUNC usage survey — SASADA Koichi <ko1@...>
Hi,
5 messages
2010/10/15
[#32814] WeakHash — Santiago Pastorino <santiago@...>
Hi guys,
6 messages
2010/10/15
[#32844] [Ruby 1.9-Feature#3963][Open] Map class in standard library — Thomas Sawyer <redmine@...>
Feature #3963: Map class in standard library
3 messages
2010/10/18
[#32864] [Ruby 1.9-Bug#3972][Open] r28668 breaks test/unit when combined with the testing rake task — Aaron Patterson <redmine@...>
Bug #3972: r28668 breaks test/unit when combined with the testing rake task
6 messages
2010/10/20
[#32932] Behavior of initialize in 1.9 — Aaron Patterson <aaron@...>
The behavior of initialize in 1.9 seems to have changed. Here is an irb
5 messages
2010/10/28
[#32960] [Ruby 1.9-Bug#4005][Open] YAML fails to roundtrip Time objects — Peter Weldon <redmine@...>
Bug #4005: YAML fails to roundtrip Time objects
6 messages
2010/10/29
[#32976] Improve MinGW builds for Ruby 1.8.7, 1.9.2 and 1.9.3 — Luis Lavena <luislavena@...>
Hello,
10 messages
2010/10/30
[#32978] Re: Improve MinGW builds for Ruby 1.8.7, 1.9.2 and 1.9.3
— Aaron Patterson <aaron@...>
2010/10/30
On Sun, Oct 31, 2010 at 03:42:02AM +0900, Luis Lavena wrote:
[ruby-core:32698] [Ruby 1.9-Feature#3908][Open] private constant
From:
Yusuke Endoh <redmine@...>
Date:
2010-10-05 15:19:19 UTC
List:
ruby-core #32698
Feature #3908: private constant
http://redmine.ruby-lang.org/issues/show/3908
Author: Yusuke Endoh
Status: Open, Priority: Normal
Assigned to: Yusuke Endoh, Category: core, Target version: 1.9.3
Hi,
I'd propose "private constant."
Private constant provides method-like visibility for constant.
=== Sample code ===
module SomeModule
class PublicClass
...
end
class PrivateClass
...
end
# you can make "PrivateClass" private by private_constant method
private_constant :PrivateClass
end
# we can refer access constant as is conventionally done
p SomeModule::PublicClass #=> SomeModule::PublicClass
# a RuntimeError is raised when we attempt to refer private constant
p SomeModule::PrivateClass #=> private constant (RuntimeError)
# we can even refer private constant from its parent scope
module SomeModule
p PrivateClass #=> SomeModule::PrivateClass
end
=== Background ===
Traditionally, there is no way to prevent users from using your classes.
It is too easy for user to access any internal class (e.g., CGI::Html3,
Enumerator::Generator, Matrix::Scalar, URI::Util, etc).
We can only write a document to ask users not to use them.
RubySpec inspired me to propose this feature. RubySpec declares the
policy that no spec should be written for private method. Nevertheless,
there were some specs for internal classes, such as CGI::Html3 (FYI,
such specs are already deleted).
I thought this was because there is no way to explicitly declare that
the constants are "internal use only."
=== Proposal ===
Private constant is a scoped constant that can be referred only from
its parent scope. It can be used for declaring "the constant is
for internal use," like private method.
When users try to refer private constant, they can realize that they
are going to use non-guaranteed feature, because the constant cannot
be referred so easily. Even so, they can use such a feature with
self-responsibility, by explicitly opening its parent scope.
Since the default visibility is public, this feature does not break
any compatibility.
=== Current status ===
I first suggested this at [ruby-dev:39685].
Matz approved my proposal [ruby-dev:39686]
Yugui has also approved [ruby-dev:40254], but said that it is needed
to discuss in ruby-core list before commit.
The patches are attached. make check and make test-rubyspec are all
passed.
What do you think?
I'll commit the patch unless there is objection.
--
Yusuke ENDOH <mame@tsg.ne.jp>
----------------------------------------
http://redmine.ruby-lang.org
Attachments (3)
0001-separate-RCLASS_CONST_TBL-from-RCLASS_IV_TBL.patch
(10.7 KB, application/mbox)
0002-use-rb_constant_entry_t-as-entry-of-RCLASS_CONST_TBL.patch
(10.6 KB, application/mbox)
0003-add-Module-public_constant-and-private_constant.patch
(3.25 KB, application/mbox)