Re: List of derived types?

2010-12-16 Thread Pelle Månsson
On 12/16/2010 02:16 PM, d coder wrote: Greetings I need a way to know (using traits or other compile time constructs) all the types derived from a given type. Is it possible in D? Is it possible to get a list of all the user-defined classes? I could use that to filter out the classes that I

Re: Concurrency and transfering ownership of data between threads?

2010-12-14 Thread Pelle Månsson
On 12/13/2010 09:45 PM, Heywood Floyd wrote: Good Evening from Berlin! Have been reading the chapter about concurrency by Andrei. Nice. I have some questions, of varying quality, I'm sure. Let's say that we have some sort of structure of rather complex data. To give us something concrete

Re: import inside a class overrides symbols imported in module scope?

2010-12-09 Thread Pelle Månsson
On 12/09/2010 10:53 PM, Trass3r wrote: It was quite hard to track that one down. In the following example the import statement was mixed into the class among other code so it wasn't as obvious as here. import std.traits; class Foo { import std.string; static assert(isNumeric!int); } foo.d(6):

Re: C++ istream / ostream equivalent ?

2010-12-02 Thread Pelle Månsson
On 12/02/2010 09:05 AM, vincent picaud wrote: Matthias Pleh Wrote: Thank you for your reply and yes that works :) Now i m facing with the following problem, what is the trick for input stream ? ( something like std::istream operator(std::istream in,A a) { // A.someData in;

Re: 'in' for plain arrays?

2010-12-02 Thread Pelle Månsson
On 12/02/2010 01:07 PM, spir wrote: Hello, Is there an equivalent of 'in' for (non-associative) arrays? Cannot find any 'contains' function. (Wouldn't it be nice to have in work for all arrays? What is the reason why it only works with AAs?) Denis -- -- -- -- -- -- -- vit esse estrany ☣

Re: Const foreach

2010-11-22 Thread Pelle Månsson
On 11/22/2010 04:12 PM, Simen kjaeraas wrote: spir denis.s...@gmail.com wrote: On Sun, 21 Nov 2010 20:21:14 -0500 bearophile bearophileh...@lycos.com wrote: If in a D2 program I have an array of mutable items I may want to iterate on them but not modify them, so I'd like the iteration

Re: defining in a module symbols for export

2010-11-22 Thread Pelle Månsson
On 11/22/2010 08:18 PM, spir wrote: Hello, Let us say I have a parsing library. Now, I want to define parsers in stand-alone modules -- for code structuration and reusability. Then, import them from apps that need them. Is there another way than defining the parser (== list of patterns) at

Re: segfault

2010-11-14 Thread Pelle Månsson
On 11/12/2010 02:03 PM, Steven Schveighoffer wrote: Pelle, I spent all this time helping him, and you swoop in with the answer :) I was in a rush when answering, causing the swoopiness of my post. :-) I only knew the answer because I had almost exactly the same bug a week ago, or so.

Re: How to implement a copy

2010-03-19 Thread Pelle Månsson
On 03/18/2010 05:43 PM, Paul D. Anderson wrote: If I'm implementing a struct and want to provide for duplication, is there a standard way to implement this? Here's an example: //--- struct S { // members of the struct -- three integer values int a;

Re: Tidy attributes

2010-03-11 Thread Pelle Månsson
On 03/11/2010 10:20 PM, bearophile wrote: While looking for possible attribute problems to add to Bugzilla, I have seen the following D2 program compiles and runs with no errors or warnings: static foo1() {} static does not apply to free functions, I would guess this means the same as

Re: Tidy attributes

2010-03-11 Thread Pelle Månsson
On 03/11/2010 10:44 PM, bearophile wrote: As far as I know, it's enum that has that purpose. Oh, but they are not the same. enum declares a constant, whereas static declares a variable. A static global is still mutable. Thank you for your answers, bearophile Why thank you!

Re: Static attributes aren' immutable

2010-03-05 Thread Pelle Månsson
On 03/05/2010 07:50 PM, bearophile wrote: div0: putting it in Foo simply puts it in a namespace. So my (wrong) idea of immutable applied to a struct was that every thing in such namespace becomes immutable (I think this is a bit more intuitive). What do you think of modifying D2 so in a

Re: raii

2010-02-28 Thread Pelle Månsson
On 02/28/2010 09:16 PM, Ellery Newcomer wrote: Hello The impetus: I agree, except I more and more think that scope classes were a mistake. Structs with destructors are a much better solution, and wrapping a class inside a struct would give it RAII semantics. The problem: In designing a

Re: running an external .exe

2010-02-17 Thread Pelle Månsson
On 02/16/2010 08:09 PM, Funog wrote: Is it possible to run an external .exe and have access to its standard input/output? Apparently std.process does not allow this. You'll want to choose either the input or the output stream, otherwise you might get eaten by a deadlock.

Re: Why isn't == used to compare structs

2010-02-08 Thread Pelle Månsson
On 02/08/2010 01:48 PM, Trass3r wrote: Why isn't == used to compare the struct members in the code above? I mean, if I compare the structs with == it could also use == to compare the members. If I use is to compare the structs it could use is to compare them members. Structs are compared

Re: default opAssign(string) behaviour

2010-01-28 Thread Pelle Månsson
On 01/28/2010 02:32 AM, strtr wrote: Personally, I use (D1)std2.conv a lot to get values from strings and thus would love the following default behaviour for all types: int i = 0; // i = 0 i = cast( int ) 0; // i = 48 ( If I read the utf8 table correctly ) What keeps this from being the case?

Re: boolean over multiple variables

2010-01-26 Thread Pelle Månsson
On 01/26/2010 01:02 AM, Nick Sabalausky wrote: strtrst...@spam.com wrote in message news:hjd6t1$be...@digitalmars.com... This may be is a very basic question, but is there a way to let me omit a repeating variable when doing multiple boolean operations? if ( var == a || var == b || var == c

Re: boolean over multiple variables

2010-01-25 Thread Pelle Månsson
On 01/23/2010 12:29 AM, strtr wrote: Simen kjaeraas Wrote: Not tested, but they should work: if ( anySame( var, a, b, c, d ) ) { } if ( allSame( var, a, b, c, d ) ) { } A lot prettier. I thought there would be a generic (basic) solution to this which I just didn't know about but maybe I

Timer library?

2010-01-25 Thread Pelle Månsson
I'm in need for a timer library that measures the acutal time. I have tried std.c.time's clock(), but it only measures time spent inside the program, not actual time elapsed. I need at least millisecond resolution, so std.c.time.time() is not an option. I wonder, is there a good library for

Re: Timer library?

2010-01-25 Thread Pelle Månsson
On 01/25/2010 04:02 PM, strtr wrote: Stanislav Blinov Wrote: Pelle M�nsson wrote: I'm in need for a timer library that measures the acutal time. I have tried std.c.time's clock(), but it only measures time spent inside the program, not actual time elapsed. I need at least millisecond