Feature #7019
closedallow `private` and `protected` keywords to take blocks
Description
Updated by trans (Thomas Sawyer) almost 14 years ago
Updated by shyouhei (Shyouhei Urabe) almost 14 years ago
I know you like blocks but this proposal doesn't make sense to me because public/private/protected are declarations, not something done. So it's odd to say "private DO something". I'd rather +1 to private def, which is natural (to me at least).
Updated by alexeymuranov (Alexey Muranov) almost 14 years ago
Updated by alexeymuranov (Alexey Muranov) almost 14 years ago
Updated by drbrain (Eric Hodel) almost 14 years ago
I don't know why you would expect this to work, private, public, etc. are methods on Module and your context is not a subclass of Module.
Why should we pollute every object with a new methods privately, publicly and protectedly (which isn't a word)?
Updated by headius (Charles Nutter) almost 14 years ago
+1 for "private def foo". I have never seen a good justification for why visibility is better as a value on the current frame, nor for why it's better to set a method's visibility after declaration rather than along with the declaration.
The fact that visibility lives on the frame also means implementations that attempt to optimize frames away (like JRuby does and eventually MRI will want to do) have a harder time of it.
Updated by luislavena (Luis Lavena) almost 14 years ago
- Category set to core
- Target version set to 2.0.0
headius (Charles Nutter) wrote:
+1 for "
private def foo". I have never seen a good justification for why visibility is better as a value on the current frame, nor for why it's better to set a method's visibility after declaration rather than along with the declaration.
So two changes:
defwill require to return the method defined instead ofnilprivatewill require to accept aMethodand not just aSymbol
I believe these two changes where already requested (can't find the bug reports yet).
This approach helps also to describe methods beyond documentation markers, making it clear when a method is private inline with the method definition and not after the method has been defined.
I like this.
Updated by trans (Thomas Sawyer) almost 14 years ago
Updated by alexeymuranov (Alexey Muranov) almost 14 years ago
Excuse me Thomas, what's the point in a "private attribute accessor"?
Updated by trans (Thomas Sawyer) almost 14 years ago
Probably not much, but it is possible. Could be "protected" instead as well. Also, other helpers can be created besides attr. My point is only that it needs to accept an array should the helper return multiple methods/symbols.
Or are you thinking that private def would be some kind of keyword thing?
Updated by ko1 (Koichi Sasada) over 13 years ago
- Assignee set to mame (Yusuke Endoh)
mame-san, could you judge this ticket?
IMO, it is too slow to introduce such a big feature.
Updated by mame (Yusuke Endoh) over 13 years ago
- Status changed from Open to Assigned
- Assignee changed from mame (Yusuke Endoh) to matz (Yukihiro Matsumoto)
- Target version changed from 2.0.0 to 3.0
IMO, it is too slow to introduce such a big feature.
Completely agreed.
--
Yusuke Endoh mame@tsg.ne.jp
Updated by alexeymuranov (Alexey Muranov) over 13 years ago
Please do not forget also module_function and such. (Or are they different in some sense?).
Alexey.
Updated by nobu (Nobuyoshi Nakada) over 11 years ago
- Description updated (diff)
Updated by kou (Kouhei Sutou) over 8 years ago
- Status changed from Assigned to Rejected
#3753 adds private def ... support. If you still want this feature, please reopen this issue.
Updated by shyouhei (Shyouhei Urabe) over 6 years ago
- Has duplicate Feature #16276: For consideration: "private do...end" / "protected do...end" added