Ben Giddings <bg-rubytalk / infofiend.com> writes:

> Christian Neukirchen wrote:
>>>But it seems to me that what people are really looking for is a way to
>>>apply multiple methods to an object without having to retype it's
>>>name:
>>>
>>>the_config_string_for_foo = $stdin.gets
>>>the_config_string_for_foo.apply { strip!; downcase! }
>> I like the idea of a safe instance_eval (one that doesnt circumvent
>> privacy or has access to instance variables), and "apply" is a good
>> name for that.
>
> There's also the idea that everything in the group would be assumed to
> be a method call, so that
>
> frame.layer.button[3].apply do
>    title = "Button title"
>    size = :max
>    pack!
>    show
> end
>
> would be equivalent to:
>
> frame.layer.button[3].title = "Button title"
> frame.layer.button[3].size = :max
> frame.layer.button[3].pack!
> frame.layer.button[3].show
>
> In other words, "title" and "size" would be accessor methods, and not
> local variables within the scope of the frame.layer.button[3]
> instance.

This would be inconsistent, which is bad.  If you really want that, go
for the "given ... [do] ... end" solution.  Or do it like the Tk
binding and use Smalltalk/Perl-style setters:

  read: object foo.        $object->foo;         object.foo
  set:  object foo: 42.    $object->foo(42);     object.foo 42

> Ben
-- 
Christian Neukirchen  <chneukirchen / gmail.com>  http://chneukirchen.org