On 9/4/11 7:11 AM, Jacob Carlborg wrote:
On 2011-09-04 04:48, Steven Schveighoffer wrote:
On Sat, 03 Sep 2011 18:57:06 -0400, Andrej Mitrovic
<andrej.mitrov...@gmail.com> wrote:

Also, changing structs to classes is gonna *massively* break code
everywhere. Why inheritance instead of a predicate like isInputStream
= is(typeof(T t; t.put; t.close)), you know the drill..

Because it breaks runtime swapping of I/O.

For example, if you wanted to change stdin to a network socket, it's
simple, just assign another InputStream.

However, if stdin is a templated struct, you cannot do this at runtime,
you have to decide at compile time what your stdin is. Believe it or
not, this is not dissimilar to FILE *, except we have more flexibility.

But I realize the implications now. I think I have to revisit this
decision.

We definitely need classes at the lower level, but I think we can wrap
them with structs that are commonly used for RAII and for not breaking
existing code.

-Steve

Tango has added a new method to Object, "dispose". The method is called
by the runtime when a scoped class exits a scope:

void foo ()
{
scope f = new File;
}

When "foo" exits File.dispose will be called and it can close any file
handles. I think it's quite clever.

What happens if f is aliased beyond the existence of foo()?

Andrei

Reply via email to