"Mauricio Fern?ndez" <batsman.geo / yahoo.com> wrote in message
news:20030518100201.GA3809 / student.ei.uni-stuttgart.de...

> The
>     SomeClass.get_resource do |r|
>
>     end
>
> idiom addresses this perfectly, IMHO.

Yes it is nice. But you do have to implement a block grabbing function and
it isn't that easy or intuitive.
It works well for predefined File classes and the like.
It also doesn't work well when you are dealing with multiple resources in
the same scope.

The out of scope is a returning issue and instead of saying no can do, I
think we actually could add something useful to the language here.

> > See the auto attribute of the D programming language:
> >
> > http://www.digitalmars.com/d/attribute.html#auto
>
> It seems D is a statically typed language... (but I've
> just read a little bit following your link).

It is statically typed, but that doesn't really matter in this context, you
just want to send the finalize message to whatever happens to be available
at given name where you declared auto. See my answer to Jim.

 Moreover,
> http://www.digitalmars.com/d/function.html#closures seems to indicate
> that it doesn't have real closures.


I'm not into the details about how this works with auto, but there are a
number of restrictions on what you can use auto on.

> These make it difficult to know when
> a variable "goes out of scope", as it's no longer a syntactic issue (ie.
> what's the "scope" then?).

I'd say it should be a syntactical issue - it should be as intuitive as
using the block method you wrote. See other mail. Frequently C++ has small
classes that really just grabs a reference to a longer living variable.
Refcounted smartpointers are perfect examples.
I'm sure there could be few difficult corners in Ruby that requires some
thinking, but it can be allowed in many common situations.

Mikkel