digitalmars.D - Auto classes are limiting
- vathixSpamFix dprogramming.com (Vathix) (6/6) May 07 2004 If a class is defined as auto, I am unable to keep an instance alive lon...
- Andy Friesen (16/20) May 07 2004 You're right, they are. On the bright side, you don't have to use auto
- vathixSpamFix dprogramming.com (Vathix) (7/19) May 07 2004 Right, but I mean when using someone else's code; like std.mmfile.MmFile...
- Stewart Gordon (10/34) May 10 2004 I don't see why that particular class has to be auto either. Why should...
- Matthew (7/41) May 11 2004 down
If a class is defined as auto, I am unable to keep an instance alive longer than its scope. I would like there to be a way to specify non-auto. Most of the time I want to immediately destruct a memory mapped file, but sometime I might want to keep it around for awhile; I'd have to rewrite or modify the code! -- Christopher E. Miller
May 07 2004
Vathix wrote:If a class is defined as auto, I am unable to keep an instance alive longer than its scope. I would like there to be a way to specify non-auto. Most of the time I want to immediately destruct a memory mapped file, but sometime I might want to keep it around for awhile; I'd have to rewrite or modify the code!You're right, they are. On the bright side, you don't have to use auto that way. Just write the class itself as non-auto, and use auto instances as needed. This is perfectly legal: class A { ... } A foo() { auto A a = new A(); A b = new A(); // a should be cleaned up when the function is done, b will not, // as it was not declared as auto return b; } -- andy
May 07 2004
In article <c7ggfk$v9r$1 digitaldaemon.com>, andy ikagames.com says...This is perfectly legal: class A { ... } A foo() { auto A a = new A(); A b = new A(); // a should be cleaned up when the function is done, b will not, // as it was not declared as auto return b; } -- andyRight, but I mean when using someone else's code; like std.mmfile.MmFile is auto, so I'm stuck with an auto class, or I have to use my own code. (By the way, when I click std.mmfile at the top of phobos.html, it doesn't scroll down to it because the <A> tag is incorrect.) -- Christopher E. Miller
May 07 2004
Vathix wrote:In article <c7ggfk$v9r$1 digitaldaemon.com>, andy ikagames.com says...I don't see why that particular class has to be auto either. Why should an mmfile have to have function-local scope whether the programmer likes it or not? I suppose a possible workaround is to wrap the mmfile in a thread.... Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.This is perfectly legal: class A { ... } A foo() { auto A a = new A(); A b = new A(); // a should be cleaned up when the function is done, b will not, // as it was not declared as auto return b; } -- andyRight, but I mean when using someone else's code; like std.mmfile.MmFile is auto, so I'm stuck with an auto class, or I have to use my own code. (By the way, when I click std.mmfile at the top of phobos.html, it doesn't scroll down to it because the <A> tag is incorrect.)
May 10 2004
"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:c7o59r$2u8c$1 digitaldaemon.com...Vathix wrote:downIn article <c7ggfk$v9r$1 digitaldaemon.com>, andy ikagames.com says...This is perfectly legal: class A { ... } A foo() { auto A a = new A(); A b = new A(); // a should be cleaned up when the function is done, b will not, // as it was not declared as auto return b; } -- andyRight, but I mean when using someone else's code; like std.mmfile.MmFile is auto, so I'm stuck with an auto class, or I have to use my own code. (By the way, when I click std.mmfile at the top of phobos.html, it doesn't scrollThat was the way Walter wanted it, and it seemed ok to me at the time. I concur that it should probably not be. Perhaps one of you could post is as a bug on the bugs NG, and we'll fix it for next time?to it because the <A> tag is incorrect.)I don't see why that particular class has to be auto either. Why should an mmfile have to have function-local scope whether the programmer likes it or not?I suppose a possible workaround is to wrap the mmfile in a thread.... Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
May 11 2004