Re: druntime thread_needLock()

2008-12-05 Thread Sean Kelly
dsimcha wrote: According to both the docs and my own experiments, thread_needLock() in core.thread returns a bool that depends on whether the current process has *ever* been multithreaded at *any* point in its execution. In Phobos's GC (pre-druntime), a similar function existed, but it returned

druntime thread_needLock()

2008-12-05 Thread dsimcha
According to both the docs and my own experiments, thread_needLock() in core.thread returns a bool that depends on whether the current process has *ever* been multithreaded at *any* point in its execution. In Phobos's GC (pre-druntime), a similar function existed, but it returned a bool based on w

Re: A lightweight module for class extensions in D

2008-12-05 Thread Christopher Wright
Gregor Richards wrote: I ran into a situation where I needed (essentially) the visitor pattern, but the visitor pattern sucks, so I wanted to make something like class extensions instead (that is, methods added to a class outside of the class definition). I usually use this pattern but make i

Re: Value Preservation and Polysemy -> context dependent integer literals

2008-12-05 Thread Fawzi Mohamed
On 2008-12-05 16:27:01 +0100, Andrei Alexandrescu <[EMAIL PROTECTED]> said: Fawzi Mohamed wrote: On 2008-12-05 07:02:37 +0100, Andrei Alexandrescu <[EMAIL PROTECTED]> said: [...] Well any integral value carries: a) type as per the C rule b) minimum value possible c) maximum value possibl

Re: A lightweight module for class extensions in D

2008-12-05 Thread Robert Fraser
Gregor Richards wrote: Robert Fraser wrote: Gregor Richards wrote: I ran into a situation where I needed (essentially) the visitor pattern, but the visitor pattern sucks, so I wanted to make something like class extensions instead (that is, methods added to a class outside of the class defini

Re: Hard-to-reproduce GC bug

2008-12-05 Thread Jarrett Billingsley
On Fri, Dec 5, 2008 at 7:29 PM, Walter Bright <[EMAIL PROTECTED]> wrote: > That's like saying one works as an auto mechanic but prefers to use a rock > rather than a hammer because a hammer costs $15 !! It's just far too useful > to not buy at such a reasonable price. > > Even so, obj2asm is free o

Re: A lightweight module for class extensions in D

2008-12-05 Thread Gregor Richards
Robert Fraser wrote: Gregor Richards wrote: I ran into a situation where I needed (essentially) the visitor pattern, but the visitor pattern sucks, so I wanted to make something like class extensions instead (that is, methods added to a class outside of the class definition). Of course, it's

Re: A lightweight module for class extensions in D

2008-12-05 Thread Robert Fraser
Gregor Richards wrote: I ran into a situation where I needed (essentially) the visitor pattern, but the visitor pattern sucks, so I wanted to make something like class extensions instead (that is, methods added to a class outside of the class definition). Of course, it's not possible to do thi

Re: Hard-to-reproduce GC bug

2008-12-05 Thread Walter Bright
Jarrett Billingsley wrote: On Fri, Dec 5, 2008 at 5:38 PM, Walter Bright <[EMAIL PROTECTED]> wrote: TLS is always going to be slow. Beating the old drum about how freakin' useful a tool obj2asm is and why doesn't anyone use it, here's what it looks like: Er, Walter, you realize it's not free,

Re: Tail call elimination

2008-12-05 Thread Christopher Wright
Jérôme M. Berger wrote: Actually, on Linux, the stack for the main thread grows dynamically until it reaches the allowed size. That's exactly what I said. It didn't occur to me beforehand that you could preallocate the stack, but now that I think about it, nobody would be happy if Lin

Re: Is "Out of Memory" a recoverable error?

2008-12-05 Thread Leandro Lucarella
Walter Bright, el 5 de diciembre a las 15:05 me escribiste: > Sean Kelly wrote: > >I disagree. D is a systems app and so should not require termination on > >any error. The distinction to me is that Errors require special handling > >if recovery is to be attempted, while it's often safe (if bad

Re: Hard-to-reproduce GC bug

2008-12-05 Thread dsimcha
Thanks, guys. I've found ways to speed things up a decent amount, and put an alpha of my SuperStack up on Scrapple, though I renamed it to TempAlloc because I don't like the name SuperStack. See D.announce and http://dsource.org/projects/scrapple/browser/trunk/tempAlloc

Re: Hard-to-reproduce GC bug

2008-12-05 Thread Jarrett Billingsley
On Fri, Dec 5, 2008 at 5:38 PM, Walter Bright <[EMAIL PROTECTED]> wrote: > TLS is always going to be slow. Beating the old drum about how freakin' > useful a tool obj2asm is and why doesn't anyone use it, here's what it looks > like: Er, Walter, you realize it's not free, right? Meaning that even

Re: Is "Out of Memory" a recoverable error?

2008-12-05 Thread Walter Bright
Christopher Wright wrote: Walter Bright wrote: nothrow void foo(); void bar() { try { foo(); } finally { will_never_execute(); // even if foo() throws } } because the compiler will optimize away the finally clause. ! ! ! Surely you mean "catch" rather tha

Re: Is "Out of Memory" a recoverable error?

2008-12-05 Thread Walter Bright
Sean Kelly wrote: I disagree. D is a systems app and so should not require termination on any error. The distinction to me is that Errors require special handling if recovery is to be attempted, while it's often safe (if bad practice) to simply log Exceptions and soldier on. That isn't to say

Re: Is "Out of Memory" a recoverable error?

2008-12-05 Thread Walter Bright
Leandro Lucarella wrote: For example, I'm working on a softswitch (unfortunately no in D). Lets say we have a really bad moment and all the subscribers want to talk at the same time and we don't support that workload. Lets say our memory is exhausted and a new call arrive. A new allocation is don

Re: Hard-to-reproduce GC bug

2008-12-05 Thread Walter Bright
dsimcha wrote: Thanks, though I'm way ahead of you in that I already did this. Works great, except it's a little bit slow. TLS is always going to be slow. Beating the old drum about how freakin' useful a tool obj2asm is and why doesn't anyone use it, here's what it looks like:

Re: Hard-to-reproduce GC bug

2008-12-05 Thread Sean Kelly
== Quote from dsimcha ([EMAIL PROTECTED])'s article > > Thanks, though I'm way ahead of you in that I already did this. Works great, > except it's a little bit slow. > I'm actually working on an implementation of the SuperStack proposed by Andrei > about a month ago, which was why I needed good TL

Re: Why I like D

2008-12-05 Thread Nick Sabalausky
"bearophile" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Nick Sabalausky: >> bearophile: >> > But the dynamic languages allow you to save time in other ways. >> >> I'd argue that most of those time-saving things are things that have >> absolutely nothing to do with dynamic typing

Re: Is __traits(derivedMembers) supposed to return mangled names?

2008-12-05 Thread Mike Hearn
> Yeah, I'm using the same hack (i.e. defining private static const members) > to denote some members characteristics, e.g. whether a member is > serializable, its value is written to log etc. Is the code open source? I was intending to put together some kind of better integrated protobufs eq

Re: Hard-to-reproduce GC bug

2008-12-05 Thread dsimcha
== Quote from Sean Kelly ([EMAIL PROTECTED])'s article > Oh! You're using the built-in thread-local storage. I don't think that's > fully > implemented yet (Walter, please correct me if I'm wrong). You might want to > use the thread-local storage feature in the Thread class for now. Depending

Re: Is __traits(derivedMembers) supposed to return mangled names?

2008-12-05 Thread Denis Koroskin
On Sat, 06 Dec 2008 00:13:40 +0300, Mike Hearn <[EMAIL PROTECTED]> wrote: The language spec is ambiguous, and DMD can apparently do either. This program prints [a __T3TagS23_D11smartstruct4Test1aiVi1Z b __T3TagS24_D11smartstruct4Test1bAaVi2Z] Note: this is a lame-ass hack around the lack

Is __traits(derivedMembers) supposed to return mangled names?

2008-12-05 Thread Mike Hearn
The language spec is ambiguous, and DMD can apparently do either. This program prints [a __T3TagS23_D11smartstruct4Test1aiVi1Z b __T3TagS24_D11smartstruct4Test1bAaVi2Z] Note: this is a lame-ass hack around the lack of real metadata attributes in D2. It'd be nice if the real thing was supported

Re: Hard-to-reproduce GC bug

2008-12-05 Thread Sean Kelly
== Quote from dsimcha ([EMAIL PROTECTED])'s article > == Quote from Sean Kelly ([EMAIL PROTECTED])'s article > > Weird. The actual storage for TLS in druntime is an array of void* > > within the Thread class. I can't imagine that it wouldn't be scanned by > > the GC. Do you have a reproducible t

Re: Tail call elimination

2008-12-05 Thread Jérôme M. Berger
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Christopher Wright wrote: > Nick Sabalausky wrote: >> On a side note, stack overflows are still possible anyway (whether >> functional or imperative). Is there a reason (other than inertia) that >> stack frames aren't set up like a dynamic array to gro

Re: Hard-to-reproduce GC bug

2008-12-05 Thread Walter Bright
Steven Schveighoffer wrote: I'd say most likely that the GC doesn't see anything declared as __thread, so when you use that pointer as the only reference to GC allocated data, it doesn't see that it's still in use, and will collect. Looks like I need to do some research to see how the gc can d

Re: Hard-to-reproduce GC bug

2008-12-05 Thread dsimcha
== Quote from Steven Schveighoffer ([EMAIL PROTECTED])'s article > "dsimcha" wrote > > == Quote from Sean Kelly ([EMAIL PROTECTED])'s article > >> Weird. The actual storage for TLS in druntime is an array of void* > >> within the Thread class. I can't imagine that it wouldn't be scanned by > >> t

Re: Hard-to-reproduce GC bug

2008-12-05 Thread Steven Schveighoffer
"dsimcha" wrote > == Quote from Sean Kelly ([EMAIL PROTECTED])'s article >> Weird. The actual storage for TLS in druntime is an array of void* >> within the Thread class. I can't imagine that it wouldn't be scanned by >> the GC. Do you have a reproducible test case? >> Sean > > I just now manage

A lightweight module for class extensions in D

2008-12-05 Thread Gregor Richards
I ran into a situation where I needed (essentially) the visitor pattern, but the visitor pattern sucks, so I wanted to make something like class extensions instead (that is, methods added to a class outside of the class definition). Of course, it's not possible to do this particularly cleanly, b

Re: Hard-to-reproduce GC bug

2008-12-05 Thread dsimcha
== Quote from Sean Kelly ([EMAIL PROTECTED])'s article > Weird. The actual storage for TLS in druntime is an array of void* > within the Thread class. I can't imagine that it wouldn't be scanned by > the GC. Do you have a reproducible test case? > Sean I just now managed to play around with thi

Re: Why I like D

2008-12-05 Thread bearophile
Nick Sabalausky: > bearophile: > > But the dynamic languages allow you to save time in other ways. > > I'd argue that most of those time-saving things are things that have > absolutely nothing to do with dynamic typing and are perfectly possible with > static typing. I mostly agree, what I want

Re: Hard-to-reproduce GC bug

2008-12-05 Thread dsimcha
One thing I forgot to mention in the orig. post: This happens in single-threaded apps. I discovered this when writing a library struct, and haven't even tried to actually use multithreading yet.

Re: Value Preservation and Polysemy -> context dependent integer literals

2008-12-05 Thread Andrei Alexandrescu
Fawzi Mohamed wrote: On 2008-12-05 07:02:37 +0100, Andrei Alexandrescu <[EMAIL PROTECTED]> said: Sergey Gromov wrote: Thu, 04 Dec 2008 09:54:32 -0800, Andrei Alexandrescu wrote: Fawzi Mohamed wrote: On 2008-12-01 22:30:54 +0100, Walter Bright <[EMAIL PROTECTED]> said: Fawzi Mohamed wrot

Re: Why I like D

2008-12-05 Thread Nick Sabalausky
"bearophile" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > But the dynamic languages allow you to save time in other ways. I'd argue that most of those time-saving things are things that have absolutely nothing to do with dynamic typing and are perfectly possible with static t

Re: Why I like D

2008-12-05 Thread Nick Sabalausky
"Robert Fraser" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Nick Sabalausky Wrote: >> That's the reason I refuse to use dynamic languages and >> indentation-syntax >> languages whenever I have a choice. They're nothing but a giant step >> backwards, constantly replacing the most

Re: Value Preservation and Polysemy -> context dependent integer literals

2008-12-05 Thread Fawzi Mohamed
On 2008-12-05 07:02:37 +0100, Andrei Alexandrescu <[EMAIL PROTECTED]> said: Sergey Gromov wrote: Thu, 04 Dec 2008 09:54:32 -0800, Andrei Alexandrescu wrote: Fawzi Mohamed wrote: On 2008-12-01 22:30:54 +0100, Walter Bright <[EMAIL PROTECTED]> said: Fawzi Mohamed wrote: On 2008-12-01 21:16

Re: Hard-to-reproduce GC bug

2008-12-05 Thread Kagamin
there is no simple way to scan TSL from another thread, TSL was designed to be thread-local after all :)

Re: Does foreach on array literal allocate?

2008-12-05 Thread Kagamin
Bill Baxter Wrote: > Bummer. > > Does a static-sized array initializer also allocate? > > int[4] v = [1,2,3,4]; > foreach(x; v) { > /// ... > } http://d.puremagic.com/issues/show_bug.cgi?id=2356

Re: Why I like D

2008-12-05 Thread bearophile
Don: > I think for dynamic languages, test-driven development is mandatory. I generally write tests after the code in all languages I use :-) Maybe I'll learn to use TDD in the future, who knows. > But you have to write zillions of tests because the compiler accepts all > kinds of garbage. [..

Re: Value Preservation and Polysemy -> context dependent integer literals

2008-12-05 Thread Fawzi Mohamed
On 2008-12-05 02:53:11 +0100, Sergey Gromov <[EMAIL PROTECTED]> said: Thu, 04 Dec 2008 09:54:32 -0800, Andrei Alexandrescu wrote: Fawzi Mohamed wrote: On 2008-12-01 22:30:54 +0100, Walter Bright <[EMAIL PROTECTED]> said: Fawzi Mohamed wrote: On 2008-12-01 21:16:58 +0100, Walter Bright <[EM

Re: Value Preservation and Polysemy -> context dependent integer literals

2008-12-05 Thread Fawzi Mohamed
On 2008-12-05 09:40:03 +0100, Don <[EMAIL PROTECTED]> said: Andrei Alexandrescu wrote: Sergey Gromov wrote: Thu, 04 Dec 2008 09:54:32 -0800, Andrei Alexandrescu wrote: Fawzi Mohamed wrote: On 2008-12-01 22:30:54 +0100, Walter Bright <[EMAIL PROTECTED]> said: Fawzi Mohamed wrote: On 2008-

Re: Value Preservation and Polysemy -> context dependent integer literals

2008-12-05 Thread Don
Andrei Alexandrescu wrote: Sergey Gromov wrote: Thu, 04 Dec 2008 09:54:32 -0800, Andrei Alexandrescu wrote: Fawzi Mohamed wrote: On 2008-12-01 22:30:54 +0100, Walter Bright <[EMAIL PROTECTED]> said: Fawzi Mohamed wrote: On 2008-12-01 21:16:58 +0100, Walter Bright <[EMAIL PROTECTED]> said:

Re: Why I like D

2008-12-05 Thread Don
bearophile wrote: Bill Baxter: You never mistype the name of a variable? Probably I do such mistakes often or very often, but I test every little piece of code I write, so such bugs are fixed seconds or minutes after I have put them in, so even not using an IDE I have never felt it as proble