Re: Best practice for strings across D1 and D2

2011-03-17 Thread Trass3r
nedbrek Wrote: 2) What is the best way to make the same declarations work for D1 and D2? It seems everything inside a version statement must parse correctly, and D1 doesn't want to parse immutable(char)... You may also use versioned aliases. Just include the D2 code via a string mixin to

Error in Template Alias Parameter example in the documentation

2011-03-17 Thread simendsjo
This example comes from http://digitalmars.com/d/2.0/template.html int x; template Foo(alias X) { static int* p = X; } void test() { alias Foo!(x) bar; *bar.p = 3; // set x to 3 static int y; alias Foo!(y) abc; *abc.p = 3; // set y to 3 } Compiling this

Re: Template string literal?

2011-03-17 Thread Jacob Carlborg
On 2011-03-16 22:41, Simen kjaeraas wrote: On Wed, 16 Mar 2011 22:39:00 +0100, Denis Koroskin 2kor...@gmail.com wrote: On Thu, 17 Mar 2011 00:30:17 +0300, Jacob Carlborg d...@me.com wrote: Is it possible to declare string literal of a template type, something like this: void bar (const(T)[]

std.regex.replace issues

2011-03-17 Thread Andrej Mitrovic
I've tried using this: auto file = File(file.cpp, r); char[] replacement; foreach (char[] line; file.byLine()) { replacement = line.replace(regex(//.*), .); // do something with replacement while its still alive.. } This gives me this bombshell of an error:

Re: Error in Template Alias Parameter example in the documentation

2011-03-17 Thread Jesse Phillips
simendsjo Wrote: Are these pages written using DDoc? Is it possible to extract and compile the examples to ensure they are correct? And perhaps use asserts instead of/in addition to comments where possible (Asserts are used many places already)? Executable and verifiable examples could be

Re: std.regex.replace issues

2011-03-17 Thread Jesse Phillips
Andrej Mitrovic Wrote: char[] replacement; foreach (char[] line; file.byLine()) { replacement = line.replace(regex(-), .) .replace(regex(::), .) .replace(regex(//.*), )

Re: std.regex.replace issues

2011-03-17 Thread Andrej Mitrovic
You're right, that point totally slipped my mind. I'm having some ideas about an alternative though. I'll try something out later. Btw, shouldn't byLine be able to return a dchar[]? For Unicode purposes?

Templated nested function can't access 'this'

2011-03-17 Thread Piotr Szturmaj
Why this works: struct Test { int read() { return 5; } int[] readArray() { int[] readDim() { return [read(), read()]; } return

Re: Templated nested function can't access 'this'

2011-03-17 Thread Zirneklis
A known bug http://d.puremagic.com/issues/show_bug.cgi?id=3159 Your just gonna have to make it a normal templated method -- Aku MoD.

Re: std.regex.replace issues

2011-03-17 Thread Jesse Phillips
Andrej Mitrovic Wrote: You're right, that point totally slipped my mind. I'm having some ideas about an alternative though. I'll try something out later. Btw, shouldn't byLine be able to return a dchar[]? For Unicode purposes? Why, if you want to operate on a dchar[] instead of a dchar

Re: std.regex.replace issues

2011-03-17 Thread Andrej Mitrovic
Okie.