Re: Nested associative arrays

2010-11-14 Thread spir
On Sun, 14 Nov 2010 10:35:42 +0100 spir denis.s...@gmail.com wrote: I finally found the bit where it describes associative array literals and they look identical to initialising a flat array, so god only knows which one gets picked when. It would be better if they where made different.

__traits and std.traits and constructors

2010-11-14 Thread Jonathan M Davis
Is there a way to get use constructors with traits functions that take a function? For instance, functionAttributes!(func) takes a func and tells you whether it's pure, nothrow, etc. However, giving it the type doesn't work (i.e. functionAttributes!T), and giving it this doesn't work (i.e.

Re: Is there a way to forward-declare interfaces to avoid module interdependencies?

2010-11-14 Thread Per Ångström
On 2010-11-11 17:21, Steven Schveighoffer wrote: First, you can't forward-declare classes in one file that are defined in another file, instead of importing. The reason is because in D, the module is the namespace that the class is declared in. So for instance, when you define IStudent in

struct vs class

2010-11-14 Thread spir
Hello, There seems to be 2 main differences between structs classes: 1. structs instances are direct values, implement value semantics; while class instances are referenced (actually pointed) 2. classes can be subtyped/subclassed in a simple way; structs cannot be really subtyped -- but there

Re: Calling a D function from C

2010-11-14 Thread Carlo
On 12/11/2010 16:19, Michal Minich wrote: V Fri, 12 Nov 2010 16:14:30 +0100, Carlo wrote: Sorry if I bother you again with this probably silly problem. Here is the point. I want to call the D function fun from a .c file: \\file libforc.d extern (C) int fun(int x,int y){ return x; }

Re: struct vs class

2010-11-14 Thread Jonathan M Davis
On Sunday 14 November 2010 03:08:49 spir wrote: Hello, There seems to be 2 main differences between structs classes: 1. structs instances are direct values, implement value semantics; while class instances are referenced (actually pointed) 2. classes can be subtyped/subclassed in a

runtime type and that bizarre is()

2010-11-14 Thread spir
Hello, Is there a way to check the runtime type of an element? Meaning, for instance, process differently according to the actual type in a hierarchy? class C {} class C1 : C {int i;} bool checkTypeC1 (C c) { return is(typeof(c) == C1); } void main () { C1 c1 = new C1();

Re: struct vs class

2010-11-14 Thread bearophile
spir: a value makes no sense by itself, it is bound to what it describes an aspect of; referencing a value is meaningless, only copy makes no sense. For instance, the position color of a visual form should be values. Structs may have a meaning by themselves, all kind of member functions,

Re: struct vs class

2010-11-14 Thread div0
On 14/11/2010 11:08, spir wrote: Hello, There seems to be 2 main differences between structs classes: 1. structs instances are direct values, implement value semantics; while class instances are referenced (actually pointed) 2. classes can be subtyped/subclassed in a simple way; structs

Re: runtime type and that bizarre is()

2010-11-14 Thread Jonathan M Davis
On Sunday 14 November 2010 03:45:12 spir wrote: Hello, Is there a way to check the runtime type of an element? Meaning, for instance, process differently according to the actual type in a hierarchy? class C {} class C1 : C {int i;} bool checkTypeC1 (C c) { return is(typeof(c) ==

Re: struct vs class

2010-11-14 Thread spir
On Sun, 14 Nov 2010 03:32:18 -0800 Jonathan M Davis jmdavisp...@gmx.com wrote: On Sunday 14 November 2010 03:08:49 spir wrote: Hello, There seems to be 2 main differences between structs classes: 1. structs instances are direct values, implement value semantics; while class

Re: runtime type and that bizarre is()

2010-11-14 Thread bearophile
spir: Only partial answers, other answers left to other people. Is there a way to check the runtime type of an element? Meaning, for instance, process differently according to the actual type in a hierarchy? You may use a cast(). If it return null then it's not castable. Also, I would

Re: struct vs class

2010-11-14 Thread spir
On Sun, 14 Nov 2010 12:02:35 + div0 d...@sourceforge.net wrote: Both of these points may conflict with semantic considerations above: we may want to use structs for fast creation, but if ever they mean things, we must think at referencing them manually and/or using ref parameters.

Re: runtime type and that bizarre is()

2010-11-14 Thread spir
On Sun, 14 Nov 2010 04:09:22 -0800 Jonathan M Davis jmdavisp...@gmx.com wrote: If you are dealing with a class hierarchy and you want to know whether a base class reference referes to a particular derived class object, I believe that the correct way to do it is cast it to the derived type

Re: struct vs class

2010-11-14 Thread Jonathan M Davis
On Sunday 14 November 2010 04:14:29 spir wrote: On Sun, 14 Nov 2010 03:32:18 -0800 Jonathan M Davis jmdavisp...@gmx.com wrote: On Sunday 14 November 2010 03:08:49 spir wrote: Hello, There seems to be 2 main differences between structs classes: 1. structs instances are

Re: Nested associative arrays

2010-11-14 Thread Jacob Carlborg
On 2010-11-13 18:27, div0 wrote: On 13/11/2010 15:49, Jacob Carlborg wrote: On 2010-11-13 14:56, div0 wrote: On 13/11/2010 11:02, Jacob Carlborg wrote: On 2010-11-12 17:44, Ellery Newcomer wrote: Should be. Are you having problems? (I don't use them much, but fwiw, it seems like tango had

Re: struct vs class

2010-11-14 Thread Lutger Blijdestijn
spir wrote: On Sun, 14 Nov 2010 12:02:35 + div0 d...@sourceforge.net wrote: Both of these points may conflict with semantic considerations above: we may want to use structs for fast creation, but if ever they mean things, we must think at referencing them manually and/or using

Re: __traits and std.traits and constructors

2010-11-14 Thread Philippe Sigaud
On Sun, Nov 14, 2010 at 11:16, Jonathan M Davis jmdavisp...@gmx.com wrote: Is there a way to get use constructors with traits functions that take a function? For instance, functionAttributes!(func) takes a func and tells you whether it's pure, nothrow, etc. However, giving it the type doesn't

Re: runtime type and that bizarre is()

2010-11-14 Thread BCS
Hello Jonathan, On Sunday 14 November 2010 03:45:12 spir wrote: Hello, Is there a way to check the runtime type of an element? Meaning, for instance, process differently according to the actual type in a hierarchy? class C {} class C1 : C {int i;} bool checkTypeC1 (C c) { return

Re: Switch constants

2010-11-14 Thread BCS
Hello bearophile, In a not-ranged cases body, like in the program below (that doesn't compile), the switch variable is a compile-time constant, so why doesn't the compile see x as constant there? template Foo(uint x) { static if (x = 1) enum Foo = 1; else enum Foo = x * Foo!(x - 1); } int

Bemused by this build error

2010-11-14 Thread Bob Cowdery
Hi I copied a module because I am changing its form. The original is still in the build but is a different package and class name. The closest thing I can think it might be talking about is this line: x_points[] =

Re: Reading stdin in Windows 7

2010-11-14 Thread Adam Wall
I experience the exact same problem on Windows 7 64-bit. import std.stdio; int main() { char[] buf; while (stdin.readln(buf)) write(buf); return 0; } If compiled as test.exe, running the following command: echo test line 1 | test Produces the following result:

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: __traits and std.traits and constructors

2010-11-14 Thread Jonathan M Davis
On Sunday 14 November 2010 07:13:43 Philippe Sigaud wrote: On Sun, Nov 14, 2010 at 11:16, Jonathan M Davis jmdavisp...@gmx.com wrote: Is there a way to get use constructors with traits functions that take a function? For instance, functionAttributes!(func) takes a func and tells you whether