Mixins: to!string cannot be interpreted at compile time

2011-02-28 Thread Peter Lundgren
I'm trying to use mixins to generate an array of numbers that are coprime to a statically known value. I've tried the following, but I receive the error: Error: to(i) ~ ", " cannot be interpreted at compile time string makePossibleAValues(string name, byte m) { string result = "immutable

Re: string vs. w/char*

2011-02-28 Thread Denis Koroskin
On Tue, 01 Mar 2011 02:08:48 +0300, Tyro[a.c.edwards] wrote: == Quote from Denis Koroskin (2kor...@gmail.com)'s article On Mon, 28 Feb 2011 19:35:47 +0300, Tyro[a.c.edwards] wrote: > On 2/28/2011 11:08 PM, J Chapman wrote: >> == Quote from Tyro[a.c.edwards] (nos...@home.com)'s article >>>

Re: Template argument deduction

2011-02-28 Thread Ali Çehreli
On 02/28/2011 07:39 PM, Tom wrote: I have... import std.stdio; int main(string[] args) { foo([[1,2],[3,4],[5,6]]); // ERROR [1] bar([[1,2],[3,4],[5,6]]); // OK foo!int([[1,2],[3,4],[5,6]]); // OK return 0; } void foo(T)(T[2][] t) { writeln(typeid(t)); } void bar(T)(T[][] t) { writeln(typeid(

Template argument deduction

2011-02-28 Thread Tom
I have... import std.stdio; int main(string[] args) { foo([[1,2],[3,4],[5,6]]); // ERROR [1] bar([[1,2],[3,4],[5,6]]); // OK foo!int([[1,2],[3,4],[5,6]]); // OK return 0; } void foo(T)(T[2][] t) { writeln(typeid(t)); } void bar(T)(T[][] t) { wri

Re: string vs. w/char*

2011-02-28 Thread Tyro[a.c.edwards]
== Quote from Denis Koroskin (2kor...@gmail.com)'s article > On Mon, 28 Feb 2011 19:35:47 +0300, Tyro[a.c.edwards] > wrote: > > On 2/28/2011 11:08 PM, J Chapman wrote: > >> == Quote from Tyro[a.c.edwards] (nos...@home.com)'s article > >>> Both implementations results in error code 1812 being retur

Re: How-to manipulate a C array with D2 vector operations?

2011-02-28 Thread Lars Holowko
On 2/28/2011 10:15 AM, Denis Koroskin wrote: On Mon, 28 Feb 2011 19:51:28 +0300, Lars Holowko wrote: gets called from a C module and I cannot change the caller): extern(C) read_into(char *buffer, size_t buf_len); I would like to use D's vector (or array-wise according to TDPL) operations on

Re: Ini parsing library in D ?

2011-02-28 Thread Jérôme M. Berger
Tarun Ramakrishna wrote: > Hi, > > Do we have a ini parser in D somewhere ? If not, is there some > documentation anywhere that tells one how to wrap a simple C++ library > like simple ini ? (Of course it isn't difficult to build a quick > parser, just that someone would done this already) >

Re: range violation

2011-02-28 Thread Andrej Mitrovic
That's because data2 has length 1000, each of which has an array of length 200. Not the other way around. This works: double[200][1000] data2; void main() { for(int i = 0; i < 1000; i++) { for(int j = 0; j < 200; j++) { data2[i][j] = 4.0; } } }

Re: range violation

2011-02-28 Thread bearophile
Dr.Smith: > For example: > > double [string] data; > double [200][1000] data2; > > for(int i = 0; i < 200; i++) { > for(int j = 0; j < 1000; j++) { > > // fake multi-dim works > string str = to!string(i) ~ "," ~ to!string(j); > data[str] = someNumber; > > // real mu

Re: range violation

2011-02-28 Thread Dr.Smith
For example: double [string] data; double [200][1000] data2; for(int i = 0; i < 200; i++) { for(int j = 0; j < 1000; j++) { // fake multi-dim works string str = to!string(i) ~ "," ~ to!string(j); data[str] = someNumber; // real multi-dim does not work data2[i][

Re: Defining type coercion

2011-02-28 Thread Simen kjaeraas
Jonathan M Davis wrote: struct Ordinal { private int representation; char getChar( ) { return representation + 'a'-1; } alias representation this; alias getChar this; } But like I said, it currently does not work. Would "alias getChar this" really be legal?

RPM Package management

2011-02-28 Thread Kai Meyer
I would like to get involved with the rpm build process. Who can I contact to get more information on what help I can provide?

Re: Some weird crashes

2011-02-28 Thread bearophile
simendsjo: > Not sure what line you are referring to though. http://en.wikipedia.org/wiki/Answer_to_Life,_the_Universe,_and_Everything#The_number_42 Bye, bearophile

Re: Ini parsing library in D ?

2011-02-28 Thread Tarun Ramakrishna
Hi Jesse, This list is filled with terrific people and you are one of them :) Thanks! Tarun On Tue, Mar 1, 2011 at 12:01 AM, Jesse Phillips wrote: > Jesse Phillips Wrote: > >> It doesn't take much to make it work with D2. I have a working one, and has >> mention of what I changed so I should b

Re: Some weird crashes

2011-02-28 Thread simendsjo
On 28.02.2011 20:24, Denis Koroskin wrote: I think you have a bug at line 42. On a serious note, it might have helped if you'd attached source code, or at least binaries. The file was too large to be attached. Here's a link to a public hosting service: http://share1t.com/4xgt2l. Everything (i

Is std.regex.match completely broken?

2011-02-28 Thread Jacob Carlborg
The following code will result in an AssertError or RangeError when run. import std.regex; import std.stdio; void main () { auto m = "abc".match(`a(\w)b`); writeln(m.hit); // AssertError in regex.d:1795 writeln(m.captures); // RangeError in regex.d:1719 } Should I report this as a

Re: Some weird crashes

2011-02-28 Thread Denis Koroskin
On Mon, 28 Feb 2011 22:04:44 +0300, simendsjo wrote: On 28.02.2011 18:52, simendsjo wrote: // ERROR auto res = mysql_library_init(0, null, null); auto cn = mysql_init(null); auto oldcn = cn; writeln(mysql_errno(cn)); assert(cn == oldcn); // when the last assert is active, the above line c

Re: Some weird crashes

2011-02-28 Thread simendsjo
On 28.02.2011 18:52, simendsjo wrote: // ERROR auto res = mysql_library_init(0, null, null); auto cn = mysql_init(null); auto oldcn = cn; writeln(mysql_errno(cn)); assert(cn == oldcn); // when the last assert is active, the above line changes cn and thus fails. auto err = mysql_errno(cn); ass

Re: Ini parsing library in D ?

2011-02-28 Thread Jesse Phillips
Jesse Phillips Wrote: > It doesn't take much to make it work with D2. I have a working one, and has > mention of what I changed so I should be able to redistribute it. I'll double > check though. Here it is: https://github.com/he-the-great/ini.d/tree/D2 The master branch should also work with

Re: How-to manipulate a C array with D2 vector operations?

2011-02-28 Thread Trass3r
I am trying to implement a D2 function that has this C signature (it gets called from a C module and I cannot change the caller): extern(C) read_into(char *buffer, size_t buf_len); I would like to use D's vector (or array-wise according to TDPL) operations on buffer but I cannot find a way, how

Re: How-to manipulate a C array with D2 vector operations?

2011-02-28 Thread Denis Koroskin
On Mon, 28 Feb 2011 19:51:28 +0300, Lars Holowko wrote: Hi I am trying to implement a D2 function that has this C signature (it gets called from a C module and I cannot change the caller): extern(C) read_into(char *buffer, size_t buf_len); I would like to use D's vector (or array-wise acco

How-to manipulate a C array with D2 vector operations?

2011-02-28 Thread Lars Holowko
Hi I am trying to implement a D2 function that has this C signature (it gets called from a C module and I cannot change the caller): extern(C) read_into(char *buffer, size_t buf_len); I would like to use D's vector (or array-wise according to TDPL) operations on buffer but I cannot find a way, h

Re: type set

2011-02-28 Thread bearophile
Steven Schveighoffer: > Not sure if this exists in std.traits or not, but that's where I'd look. std.typetuple.anySatisfy helps here. --- spir: > Is there any static switch? foreach done on a typetuple is a static foreach. > Or any other nicer way to write it than: I suggest to put the

Re: type set

2011-02-28 Thread Steven Schveighoffer
On Mon, 28 Feb 2011 12:50:21 -0500, spir wrote: PS: Is it your email client that eats whitespace (see my code above)? Only in your reply does the code appear indented improperly, so I think it's your client, not mine. -steve

Re: string vs. w/char*

2011-02-28 Thread Denis Koroskin
On Mon, 28 Feb 2011 19:35:47 +0300, Tyro[a.c.edwards] wrote: On 2/28/2011 11:08 PM, J Chapman wrote: == Quote from Tyro[a.c.edwards] (nos...@home.com)'s article Both implementations results in error code 1812 being returned from GetLastError. explanation of the code reads: ERROR_RESO

Some weird crashes

2011-02-28 Thread simendsjo
I'm trying to wrap the newest mysql c connector, but I get some weird bugs. I don't know any assembly, so I don't even know if I've included enough info.. I hope this is a small enough test case so someone can understand the issue. I've used implib on the included dll and rdmd and dmd 2.051 to

Re: type set

2011-02-28 Thread spir
On 02/28/2011 03:50 PM, Steven Schveighoffer wrote: On Mon, 28 Feb 2011 09:27:36 -0500, spir wrote: By the way, the block of the function is a series of static if-s, one for each allowed type. Is there any static switch? Or any other nicer way to write it than: T check (T) () if ( is(T == DLo

Re: range violation

2011-02-28 Thread Nick Treleaven
On Mon, 28 Feb 2011 16:07:41 +, Dr.Smith wrote: > With multidimensional arrays greater than 150x150, I get a range > violation at run time: "core.exception.RangeError@pweight(54): Range > violation" Is this a bug? Is there a work-around? Can you show some code or a test case? My sample below

Re: array idioms

2011-02-28 Thread Nick Treleaven
On Fri, 25 Feb 2011 23:48:19 +0100, spir wrote: > we cannot even use something like memcopy because the source & target > mem areas overlap In those cases, use memmove. But maybe there's a D-ish way that's just as efficient, not sure.

Re: string vs. w/char*

2011-02-28 Thread Tyro[a.c.edwards]
On 2/28/2011 11:08 PM, J Chapman wrote: == Quote from Tyro[a.c.edwards] (nos...@home.com)'s article Both implementations results in error code 1812 being returned from GetLastError. explanation of the code reads: ERROR_RESOURCE_DATA_NOT_FOUND 1812 (0x714) The specified image

range violation

2011-02-28 Thread Dr.Smith
With multidimensional arrays greater than 150x150, I get a range violation at run time: "core.exception.RangeError@pweight(54): Range violation" Is this a bug? Is there a work-around?

Re: Ini parsing library in D ?

2011-02-28 Thread Jesse Phillips
Tarun Ramakrishna Wrote: > Err ok, I got excited too soon. That seems to be a D1 module..anyways > I am already halfway through writing my D2 Ini parser, so I guess its > fine > > On Mon, Feb 28, 2011 at 6:07 PM, Tarun Ramakrishna wrote: > > Hi Trass, > > > > Wow! A pure, plain simple D module f

Re: type set

2011-02-28 Thread Steven Schveighoffer
On Mon, 28 Feb 2011 09:27:36 -0500, spir wrote: By the way, the block of the function is a series of static if-s, one for each allowed type. Is there any static switch? Or any other nicer way to write it than: T check (T) () if ( is(T == DLogical) || is(T ==

Re: string vs. w/char*

2011-02-28 Thread Andrej Mitrovic
I've successfully used resource files with DFL. Maybe this will help: http://www.dsource.org/forums/viewtopic.php?t=5591&sid=bf2d804f1d5a3f9efccbf29ebb6cf723 You'll have to dig into the DFL library sources to find out exactly how it loads a resource file though.

Re: type set

2011-02-28 Thread spir
On 02/28/2011 02:32 PM, Steven Schveighoffer wrote: On Mon, 28 Feb 2011 08:22:58 -0500, spir wrote: Hello, I have a template condition that looks like this: T check (T) () if ( is(T == DLogical) || is(T == DNumber) || is(T == DText) || is(T == DList) || is(T == DUnit) ) { ... } Is there a w

Re: string vs. w/char*

2011-02-28 Thread J Chapman
== Quote from Tyro[a.c.edwards] (nos...@home.com)'s article > Both implementations results in error code 1812 being returned from > GetLastError. explanation of the code reads: > ERROR_RESOURCE_DATA_NOT_FOUND > 1812 (0x714) > The specified image file did not contain a resource sec

Re: string vs. w/char*

2011-02-28 Thread Steven Schveighoffer
On Mon, 28 Feb 2011 08:30:02 -0500, Tyro[a.c.edwards] wrote: On 2/28/2011 9:58 PM, Steven Schveighoffer wrote: On Mon, 28 Feb 2011 07:34:39 -0500, Tyro[a.c.edwards] wrote: The bellow code attempts to use LoadStringA() to initialize _buf. However, regardless of what form _buf takes, the bo

Re: string vs. w/char*

2011-02-28 Thread Tyro[a.c.edwards]
On 2/28/2011 9:58 PM, Steven Schveighoffer wrote: On Mon, 28 Feb 2011 07:34:39 -0500, Tyro[a.c.edwards] wrote: The bellow code attempts to use LoadStringA() to initialize _buf. However, regardless of what form _buf takes, the body of the if statement is always executed. I've attempted to use e

Re: type set

2011-02-28 Thread Steven Schveighoffer
On Mon, 28 Feb 2011 08:22:58 -0500, spir wrote: Hello, I have a template condition that looks like this: T check (T) () if ( is(T == DLogical) || is(T == DNumber) || is(T == DText) || is(T == DList) || is(T == DUnit)

Re: Named Pipes IPC in D for windows and linux ?

2011-02-28 Thread Steven Schveighoffer
On Mon, 28 Feb 2011 08:00:28 -0500, Tarun Ramakrishna wrote: Hi Steven, Yes, I have now understood that. Is there a guidelines/best practices page somewhere that describes how should a good library be coded for acceptance into the standard library: patterns and conventions, etc ? I am very n

type set

2011-02-28 Thread spir
Hello, I have a template condition that looks like this: T check (T) () if ( is(T == DLogical) || is(T == DNumber) || is(T == DText) || is(T == DList) || is(T == DUnit) ) { ... } Is there a way to "factor out" s

Re: Named Pipes IPC in D for windows and linux ?

2011-02-28 Thread Tarun Ramakrishna
Hi Steven, Yes, I have now understood that. Is there a guidelines/best practices page somewhere that describes how should a good library be coded for acceptance into the standard library: patterns and conventions, etc ? I am very new to D, but from the mails I have read on this list so far, I ha

Re: string vs. w/char*

2011-02-28 Thread Steven Schveighoffer
On Mon, 28 Feb 2011 07:34:39 -0500, Tyro[a.c.edwards] wrote: The bellow code attempts to use LoadStringA() to initialize _buf. However, regardless of what form _buf takes, the body of the if statement is always executed. I've attempted to use every type of string available in D to includ

Re: Ini parsing library in D ?

2011-02-28 Thread Tarun Ramakrishna
Err ok, I got excited too soon. That seems to be a D1 module..anyways I am already halfway through writing my D2 Ini parser, so I guess its fine On Mon, Feb 28, 2011 at 6:07 PM, Tarun Ramakrishna wrote: > Hi Trass, > > Wow! A pure, plain simple D module for ini parsing. Nice :)) > > Thanks! > Tar

Re: Named Pipes IPC in D for windows and linux ?

2011-02-28 Thread Steven Schveighoffer
On Sun, 27 Feb 2011 13:53:05 -0500, Tarun Ramakrishna wrote: Is there anything in the standard library to do named pipes IPC in both windows and linux ? I am not necessarily looking for a unified API, anything that will allow me to setup named pipes on either OS and read/write on them will do

Re: Ini parsing library in D ?

2011-02-28 Thread Tarun Ramakrishna
Hi Trass, Wow! A pure, plain simple D module for ini parsing. Nice :)) Thanks! Tarun On Mon, Feb 28, 2011 at 3:34 PM, Trass3r wrote: > http://www.dprogramming.com/ini.php >

string vs. w/char*

2011-02-28 Thread Tyro[a.c.edwards]
The bellow code attempts to use LoadStringA() to initialize _buf. However, regardless of what form _buf takes, the body of the if statement is always executed. I've attempted to use every type of string available in D to include char* _buf[MAX_RESSTRING+1] and setting _buf[MAX_RESSTRING] = '\0'

Re: How do you test pre-/post-conditions and invariants?

2011-02-28 Thread Magnus Lie Hetland
On 2011-02-27 02:33:46 +0100, Jonathan M Davis said: [snip lots of useful stuff] Thanks for your patience, and more useful clarifications. I think I get it now (but I may very well be wrong ;) - M -- Magnus Lie Hetland http://hetland.org

Re: Initializing a class pointer

2011-02-28 Thread Tyro[a.c.edwards]
On 2/27/2011 10:39 PM, Steven Schveighoffer wrote: On Sat, 26 Feb 2011 19:46:18 -0500, Tyro[a.c.edwards] wrote: On 2/27/2011 8:52 AM, Simen kjaeraas wrote: Tyro[a.c.edwards] wrote: I'm trying to convert some c++ code that defines T func(par...) { Controller * pCtrl = WinGetLong (hwnd); .

Re: Version very simple?

2011-02-28 Thread Trass3r
Note that negation and logical and can basically be simulated: !bla -> version(bla) {} else ... bla && blub -> version(bla) version(blub) {...}

Re: Ini parsing library in D ?

2011-02-28 Thread Trass3r
http://www.dprogramming.com/ini.php

Re: Ini parsing library in D ?

2011-02-28 Thread Jacob Carlborg
On 2011-02-28 08:04, Tarun Ramakrishna wrote: Hi, Do we have a ini parser in D somewhere ? If not, is there some documentation anywhere that tells one how to wrap a simple C++ library like simple ini ? (Of course it isn't difficult to build a quick parser, just that someone would done this alrea