Is Out of Memory a recoverable error?

2008-12-02 Thread Walter Bright
I asked this over on stackoverflow.com to see what people using other languages have to say, as well as the D community. The reason I ask is to see if memory allocation can be allowed in functions marked nothrow. http://stackoverflow.com/questions/333736/is-out-of-memory-a-recoverable-error

Re: indexing tuples using strings

2008-12-02 Thread Bill Baxter
On Tue, Dec 2, 2008 at 7:26 PM, bearophile [EMAIL PROTECTED] wrote: Bill Baxter: What about Perl shows that auto-flattening is bad? You can find a note here: http://steve.yegge.googlepages.com/ancient-languages-perl Larry decided to flatten lists by default. Hence, if you write this: @x =

Re: indexing tuples using strings

2008-12-02 Thread bearophile
Bill Baxter: What about Perl shows that auto-flattening is bad? You can find a note here: http://steve.yegge.googlepages.com/ancient-languages-perl Larry decided to flatten lists by default. Hence, if you write this: @x = (1, 2, 3, (4, 5)); It automagically turns into (1, 2, 3, 4, 5). With

Re: Is Out of Memory a recoverable error?

2008-12-02 Thread bearophile
In a program Out of Memory is recoverable, for example your program can use several caches, buffers, and it can use data already present on disk too, or data that can be moved on disk now. A good program when finds an out of memory situation can clear its caches, delete not essential data

Re: Interfacing with XPCOM

2008-12-02 Thread Walter Bright
John Reimer wrote: In D (windows) it would look like so (assuming you have done away with the compilers internal detection of COM interfaces): extern(C++) interface IUnknown: { extern(Windows): int QueryInterface(nsIID* uuid, void **result); int AddRef(); int

Re: Is Out of Memory a recoverable error?

2008-12-02 Thread Steven Schveighoffer
Walter Bright wrote I asked this over on stackoverflow.com to see what people using other languages have to say, as well as the D community. The reason I ask is to see if memory allocation can be allowed in functions marked nothrow.

Re: Is Out of Memory a recoverable error?

2008-12-02 Thread Walter Bright
Steven Schveighoffer wrote: It can be. For example, if you want to allocate a gigantic buffer to see if you can load a file, you may catch for failure, and display an appropriate message to the user on failure. The application could still continue to run. I think the difference between

Re: Is Out of Memory a recoverable error?

2008-12-02 Thread Russell Lewis
Walter Bright wrote: I asked this over on stackoverflow.com to see what people using other languages have to say, as well as the D community. The reason I ask is to see if memory allocation can be allowed in functions marked nothrow.

Re: Is Out of Memory a recoverable error?

2008-12-02 Thread Jarrett Billingsley
On Tue, Dec 2, 2008 at 11:57 AM, Russell Lewis [EMAIL PROTECTED] wrote: It seems that D has (or rather, can have) a trivial solution to this problem. Allow programs to register with the GC when they have memory which can be easily freed (caches and such). Then you can make out of memory a

Re: Is Out of Memory a recoverable error?

2008-12-02 Thread Sean Kelly
== Quote from Russell Lewis ([EMAIL PROTECTED])'s article Walter Bright wrote: I asked this over on stackoverflow.com to see what people using other languages have to say, as well as the D community. The reason I ask is to see if memory allocation can be allowed in functions marked nothrow.

Re: Is Out of Memory a recoverable error?

2008-12-02 Thread Walter Bright
Jarrett Billingsley wrote: On Tue, Dec 2, 2008 at 11:57 AM, Russell Lewis [EMAIL PROTECTED] wrote: It seems that D has (or rather, can have) a trivial solution to this problem. Allow programs to register with the GC when they have memory which can be easily freed (caches and such). Then you

Spinlocks for GC on multiprocessor PCs?

2008-12-02 Thread dsimcha
Since resource contention for memory allocations seems to be a big issue in D, at least for me, and memory allocation is usually pretty fast, would it make sense to make the lock used for GC.malloc a spinlock? Since memory allocation takes very little time relative to a full timeslice, there is

Delegate

2008-12-02 Thread Fabian Claßen
Hi I have a problem: What's wrong about this code? Code: import std.stdio; int main() { writefln(%f, add(100, 786, 56.0)); return 0; } double add(double delegate()[] dgs...) { double result = 0; foreach(double delegate() dg; dgs) { result += dg;

Re: Delegate

2008-12-02 Thread Fabian Claßen
Jarrett Billingsley schrieb: On Tue, Dec 2, 2008 at 1:30 PM, Fabian Claßen [EMAIL PROTECTED] wrote: result += dg; Just change that line to result += dg();. A delegate is like a function; you call it to get the value. Oh thank you. I see. That's a stupid mistake of mine :D

Re: Delegate

2008-12-02 Thread Derek Parnell
On Tue, 02 Dec 2008 19:30:47 +0100, Fabian Claßen wrote: Hi I have a problem: What's wrong about this code? Code: import std.stdio; int main() { writefln(%f, add(100, 786, 56.0)); return 0; } double add(double delegate()[] dgs...) { double result = 0;

Re: Delegate

2008-12-02 Thread Denis Koroskin
On Tue, 02 Dec 2008 22:45:03 +0300, Derek Parnell [EMAIL PROTECTED] wrote: On Tue, 02 Dec 2008 19:30:47 +0100, Fabian Claßen wrote: Hi I have a problem: What's wrong about this code? Code: import std.stdio; int main() { writefln(%f, add(100, 786, 56.0)); return 0; } double

Re: Delegate

2008-12-02 Thread Jarrett Billingsley
On Tue, Dec 2, 2008 at 2:45 PM, Derek Parnell [EMAIL PROTECTED] wrote: On Tue, 02 Dec 2008 19:30:47 +0100, Fabian Claßen wrote: Hi I have a problem: What's wrong about this code? Code: import std.stdio; int main() { writefln(%f, add(100, 786, 56.0)); return 0; } double

Re: Identity of interfaces (or not)

2008-12-02 Thread BCS
Reply to Tomas, The problem is that B has two vtables that implement the interface I. However, in A.addChild, i.parent get's the first one (introduced by A), and in main, it gets the second one (J , which derived from I). The identity check then fails because the pointers aren't the same, even

Re: Delegate

2008-12-02 Thread Derek Parnell
On Tue, 02 Dec 2008 22:53:25 +0300, Denis Koroskin wrote: On Tue, 02 Dec 2008 22:45:03 +0300, Derek Parnell [EMAIL PROTECTED] wrote: On Tue, 02 Dec 2008 19:30:47 +0100, Fabian Claßen wrote: Hi I have a problem: What's wrong about this code? Code: import std.stdio; int main() {

Re: Is Out of Memory a recoverable error?

2008-12-02 Thread Sean Kelly
== Quote from Kagamin ([EMAIL PROTECTED])'s article One can get rid of OOM just by adding a couple of lines to the default malloc, that call custom handler (similar to onOutOfMemoryError handler) wich does any magic wanted Endless loop. Sean

Re: Is Out of Memory a recoverable error?

2008-12-02 Thread Kagamin
Sean Kelly Wrote: == Quote from Kagamin ([EMAIL PROTECTED])'s article One can get rid of OOM just by adding a couple of lines to the default malloc, that call custom handler (similar to onOutOfMemoryError handler) wich does any magic wanted Endless loop. magic is far more powerful than

Re: Is Out of Memory a recoverable error?

2008-12-02 Thread Kagamin
Kagamin Wrote: One can get rid of OOM just by adding a couple of lines to the default malloc, that call custom handler (similar to onOutOfMemoryError handler) wich does any magic wanted, so OOM doesn't break nothrow functions, and if it's thrown, this means that recovery code has failed to

Re: Identity of interfaces (or not)

2008-12-02 Thread BCS
Reply to Frits, BCS wrote: Reply to Tomas, The problem is that B has two vtables that implement the interface I. However, in A.addChild, i.parent get's the first one (introduced by A), and in main, it gets the second one (J , which derived from I). The identity check then fails because the

Re: Identity of interfaces (or not)

2008-12-02 Thread Christopher Wright
BCS wrote: Reply to Tomas, The problem is that B has two vtables that implement the interface I. However, in A.addChild, i.parent get's the first one (introduced by A), and in main, it gets the second one (J , which derived from I). The identity check then fails because the pointers aren't the

Associative Array of structs

2008-12-02 Thread Zane
I tried writing to an associative array and got the exception: [EMAIL PROTECTED](15): Array index out of bounds the program below causes the exception: module test; import tango.io.Stdout; import tango.io.Console; struct S {uint i;} int main() { S[char[]] s;

Re: Associative Array of structs

2008-12-02 Thread Jarrett Billingsley
On Tue, Dec 2, 2008 at 7:34 PM, Zane [EMAIL PROTECTED] wrote: I tried writing to an associative array and got the exception: [EMAIL PROTECTED](15): Array index out of bounds the program below causes the exception: module test; import tango.io.Stdout; import tango.io.Console; struct S

Re: Interfacing with XPCOM

2008-12-02 Thread John Reimer
Hello Walter, John Reimer wrote: In D (windows) it would look like so (assuming you have done away with the compilers internal detection of COM interfaces): extern(C++) interface IUnknown: { extern(Windows): int QueryInterface(nsIID* uuid, void **result); int AddRef(); int Release(); } I bet

Re: Is Out of Memory a recoverable error?

2008-12-02 Thread Robert Fraser
Don wrote: Strategy (1): Windows used to have a WM_COMPACTING message (maybe it still does) which was sent when the system was running low on memory. In D, you could imagine a similar sort of system callback, which is called when memory is short -- it means, free some memory now, otherwise

Re: Interfacing with XPCOM

2008-12-02 Thread Walter Bright
John Reimer wrote: Okay, that is an important detail for me to know. But I assumed that a C++ interface must not be allocated in D either. In must acquire a pointer from an external factory that handles the allocation outside of the gc range (C++ code must allocate/delete it's own objects).

Re: How to compile and use an external class

2008-12-02 Thread bearophile
Some Guy: I am busy learning D and I want to be able to use classes now. I am used to programming in C# where it does everything for you and you don't have to think about this kind of thing so I now have no idea how to compile a program from the command line that uses a class in another

Re: How to compile and use an external class

2008-12-02 Thread Derek Parnell
On Tue, 2 Dec 2008 09:28:53 + (UTC), Some Guy wrote: I am busy learning D and I want to be able to use classes now. I am used to programming in C# where it does everything for you and you don't have to think about this kind of thing so I now have no idea how to compile a program from the

How to compile and use an external class

2008-12-02 Thread Some Guy
I am busy learning D and I want to be able to use classes now. I am used to programming in C# where it does everything for you and you don't have to think about this kind of thing so I now have no idea how to compile a program from the command line that uses a class in another source file. I have

[Issue 1961] Allow scoped const contracts

2008-12-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1961 --- Comment #15 from [EMAIL PROTECTED] 2008-12-02 09:07 --- (In reply to comment #12) This code duplication bug requires to write every rom method in three flavors to provide good rom interface. For me, this entirely prevents use

[Issue 1961] Allow scoped const contracts

2008-12-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1961 [EMAIL PROTECTED] changed: What|Removed |Added CC||[EMAIL PROTECTED] ---

[Issue 1961] Allow scoped const contracts

2008-12-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1961 --- Comment #12 from [EMAIL PROTECTED] 2008-12-02 04:19 --- Walter Bright wrote: For me, the question is is solving these issues a large enough problem that justifies adding a rather confusing new variation on const? This

[Issue 1961] Allow scoped const contracts

2008-12-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1961 --- Comment #16 from [EMAIL PROTECTED] 2008-12-02 09:57 --- You are right I hadn't fully re-read the your initial posting, it was a long time ago ;) --

[Issue 2485] New: non-static initialization of struct using static initializer syntax generates wrong code

2008-12-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2485 Summary: non-static initialization of struct using static initializer syntax generates wrong code Product: D Version: 1.035 Platform: PC OS/Version: Linux Status:

[Issue 1382] memory allocated for arrays in CTFE functions during compilation is not released

2008-12-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1382 --- Comment #3 from [EMAIL PROTECTED] 2008-12-02 12:31 --- We've had some success with reenabling boehm-gc: http://www.dsource.org/projects/ldc/ticket/49 . Another test with USE_BOEHM_GC=0, REDIRECT_MALLOC=GC_malloc and IGNORE_FREE

[Issue 2476] std.stdio fails to compile

2008-12-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2476 --- Comment #3 from [EMAIL PROTECTED] 2008-12-03 00:34 --- I think you want runtime, not druntime. druntime is the old version that Walter that got left in there. --

[Issue 2488] object.d: module object cannot read file 'object.d'

2008-12-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2488 --- Comment #3 from [EMAIL PROTECTED] 2008-12-03 01:33 --- Alright, the following change to dmd.conf did it. [EMAIL PROTECTED]/../src/phobos [EMAIL PROTECTED]/../src/druntime/import [EMAIL PROTECTED]/../lib I don't mind if that is