On May 17, 2005, at 9:51 AM, Nikolai Weibull wrote:
>>> class A
>>>  scoped_def :private, :a do
>>>    
>>>  end
>>> end
>>>
>> What do you prefer about the above, versus the existing (and, IMO,
>> slightly prettier):
>>
>> class A
>>     private; def meth1( arg1, arg2=:foo )
>>         'private'
>>     end
>>
>>     protected; def meth2( arg1, arg2='bar' )
>>         'protected'
>>     end
>
> Well, the visibility will affect all methods defined after it and I
> really want to intermingle methods of varying visibility, i.e.,  
> not, as
> you suggest below, to group them by visibility.

I suppose I assumed that you were always going to be specifying the  
'scope' of each method you defined, in which case the new private/ 
protected/public keyword for that particular def would take over.  
You're correct that what I suggested would be quite dangerous (or at  
least ripe for a confusing bug) if intermingled with standard def  
methods.

It would be nice if the def 'method' returned a symbol with the name  
of the method, in which case:

private def foo; ...; end

would work as a this-method-only specification.