Re: Multi dimensional array question.

2010-07-16 Thread Heywood Floyd
Lars T. Kyllingstad Wrote: > I do agree that, if possible, the language should match how most people > think. But in this case, it is impossible, because of templates. How > would the following example work with T = int[3], if arrays worked the > way you want? > > struct MyArray(T) > {

Anyone know why this CTFE isn't working?

2010-07-16 Thread Rory McGuire
import std.stdio;struct State { string s; string getString() { return s; } static State opCall(string s) { State ret; ret.s = s; return ret; }}void main() { auto s = State("adf"); pragma(msg, s.getString());}dmd Output: (line 14 is the pragma statement)struct.d(14): Error: variable s cannot

Re: Anyone know why this CTFE isn't working?

2010-07-16 Thread Lars T. Kyllingstad
On Fri, 16 Jul 2010 11:46:48 +0200, Rory McGuire wrote: > import std.stdio; > > struct State { > string s; string getString() { return s; } static State opCall(string > s) { > State ret; > ret.s = s; > return ret; > } > } > > void main() { > auto s = State("adf"); > pragma(msg, s

Re: Anyone know why this CTFE isn't working?

2010-07-16 Thread Rory McGuire
Sorry about the html On Fri, 16 Jul 2010 11:46:48 +0200, Rory McGuire wrote: import std.stdio; struct State { string s; string getString() { return s; } static State opCall(string s) { State ret; ret.s = s; return ret;

Re: Anyone know why this CTFE isn't working?

2010-07-16 Thread Jonathan M Davis
On Friday 16 July 2010 02:46:48 Rory McGuire wrote: > import std.stdio; > > struct State { > string s; string getString() { return s; } > static State opCall(string s) { > State ret; > ret.s = s; > return ret; > } > } > > void main() { > auto s = State("adf"); > pragma(msg, s.getS

Re: Anyone know why this CTFE isn't working?

2010-07-16 Thread Rory McGuire
On Fri, 16 Jul 2010 11:58:57 +0200, Lars T. Kyllingstad wrote: On Fri, 16 Jul 2010 11:46:48 +0200, Rory McGuire wrote: import std.stdio; struct State { string s; string getString() { return s; } static State opCall(string s) { State ret; ret.s = s; return ret; } } void main()

Re: Anyone know why this CTFE isn't working?

2010-07-16 Thread Rory McGuire
On Fri, 16 Jul 2010 12:05:02 +0200, Jonathan M Davis wrote: On Friday 16 July 2010 02:46:48 Rory McGuire wrote: import std.stdio; struct State { string s; string getString() { return s; } static State opCall(string s) { State ret; ret.s = s; return ret; } } void main() { auto

Re: Anyone know why this CTFE isn't working?

2010-07-16 Thread Lars T. Kyllingstad
On Fri, 16 Jul 2010 12:12:38 +0200, Rory McGuire wrote: > On Fri, 16 Jul 2010 11:58:57 +0200, Lars T. Kyllingstad > wrote: > >> On Fri, 16 Jul 2010 11:46:48 +0200, Rory McGuire wrote: >> >>> import std.stdio; >>> >>> struct State { >>> string s; string getString() { return s; } static State >>

Re: CT usage only in executable

2010-07-16 Thread Daniel Murphy
"strtr" wrote in message news:i1lro6$307...@digitalmars.com... > == Quote from bearophile (bearophileh...@lycos.com)'s article >> strtr: >> > Not that the memory is really significant compared to the rest of my >> > program, >> > but I have a few fairly large arrays I use only in compile time and

Re: Multi dimensional array question.

2010-07-16 Thread Tim Verweij
On 16 July 2010 11:12, Heywood Floyd wrote: > Lars T. Kyllingstad Wrote: > (...) > > When we introduce templates, this should still work: > > struct MyArray(T){ > array[3] T a; > } > > // Let's try > T == array[11] int > > array[3] T a; > array[3] (array[11] int) a; > array[3] array[11] a; > ar

Re: Multi dimensional array question.

2010-07-16 Thread Mafi
Am 16.07.2010 11:12, schrieb Heywood Floyd: Lars T. Kyllingstad Wrote: I do agree that, if possible, the language should match how most people think. But in this case, it is impossible, because of templates. How would the following example work with T = int[3], if arrays worked the way you wa

Re: Multi dimensional array question.

2010-07-16 Thread Tim Verweij
On 16 July 2010 20:11, Mafi wrote: > Am 16.07.2010 11:12, schrieb Heywood Floyd: > > Lars T. Kyllingstad Wrote: >> >> I do agree that, if possible, the language should match how most people >>> think. But in this case, it is impossible, because of templates. How >>> would the following exampl

multiple subtype vs. multiple inheritance

2010-07-16 Thread Neal Becker
What's the difference between the (forbidden) multiple inheritance, and multiple subtyping? BTW, IMO the syntax of multiple subtyping is strange and ugly.

Re: CT usage only in executable

2010-07-16 Thread strtr
== Quote from Daniel Murphy (yebbl...@nospamgmail.com)'s article > I think if you use enum instead of const/immutable the compiler is not meant > to put them in the executable (it might anyway in some/all cases). > eg. > module main; > enum CT_STRING = "int i=0;"; > void main(){ > mixin( CT_STRING

Re: Multi dimensional array question.

2010-07-16 Thread Heywood Floyd
Mafi Wrote: > > I don't really like it. Of course the order of indices feels better but > it breaks the rule of reading types from right to left. It also > introduces more parenthesis and a new keyword into types (amongst const, > immutable and delegate etc). Consider: >shared array[3](con

Re: Multi dimensional array question.

2010-07-16 Thread bearophile
Heywood Floyd: > First of all, I definitely think that how arrays are declared now would have > to stay just the way it is, > no matter what. I don't think stuff like that is changeable this late in a > language. Recently I have suggested to remove the syntax: new int[20]; And allow only: new in

Re: CT usage only in executable

2010-07-16 Thread Daniel Murphy
"strtr" wrote in message news:i1ql53$306...@digitalmars.com... > == Quote from Daniel Murphy (yebbl...@nospamgmail.com)'s article >> I think if you use enum instead of const/immutable the compiler is not >> meant >> to put them in the executable (it might anyway in some/all cases). >> eg. >> mod

Re: CT usage only in executable

2010-07-16 Thread Simen kjaeraas
Daniel Murphy wrote: Sorry, I don't have D1 installed. Can you use enum to declare manifest constants in D1 or is it a D2 thing? It's a D2 thing. I believe the D1 way to do it is with static const. If the string is left in the executable from const char[] CT_STRING = "blah blah"; void mai