Re: Input from a newbie

2012-04-09 Thread Stefan
On Monday, 9 April 2012 at 20:18:29 UTC, Ali Çehreli wrote: The GCC C compiler proves you wrong :) They have warnings. I guess it's a hack (because printf really doesn't belong into the compiler) but that doesn't matter. What matters is user-friendliness. Indeed. dmd should warn about any i

Re: A problem with mutable toString

2012-04-09 Thread Kenji Hara
On Monday, 9 April 2012 at 00:25:57 UTC, bearophile wrote: Currently this code compiles and runs with no errors: class Foo { override string toString() const { return "Foo"; } } void main() { import std.stdio; const Foo[] foos = [new Foo]; writeln(foos); }

Re: "How to set up QTD?".

2012-04-09 Thread Kevin Cox
On Apr 9, 2012 12:09 PM, "vmars316" wrote: > > On Monday, 9 April 2012 at 12:52:47 UTC, Kevin Cox wrote: > >> I think rcc is the Qt resource compiler. I'm not at my computer at the >> moment to check, but if so it will translate xml resource files into D >> source. > > > "I think rcc is the Qt re

Re: isRandomAccessRange on static array

2012-04-09 Thread Brad Anderson
On Monday, 9 April 2012 at 23:22:57 UTC, Jonathan M Davis wrote: On Tuesday, April 10, 2012 00:20:20 Brad Anderson wrote: A user in IRC was having difficulty using std.algorithm.sort on a static array. It appears to be due to static arrays don't pass the isRandomAccessRange constraint. static

Re: isRandomAccessRange on static array

2012-04-09 Thread Jonathan M Davis
On Tuesday, April 10, 2012 00:20:20 Brad Anderson wrote: > A user in IRC was having difficulty using std.algorithm.sort on a > static array. It appears to be due to static arrays don't pass > the isRandomAccessRange constraint. > > static assert(isRandomAccessRange!(uint[5])); > > Results in: >

Re: isRandomAccessRange on static array

2012-04-09 Thread Ali Çehreli
On 04/09/2012 03:20 PM, Brad Anderson wrote: A user in IRC was having difficulty using std.algorithm.sort on a static array. It appears to be due to static arrays don't pass the isRandomAccessRange constraint. static assert(isRandomAccessRange!(uint[5])); Results in: Error: static assert (isRa

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread q66
On Monday, 9 April 2012 at 17:24:35 UTC, Andrej Mitrovic wrote: On 4/9/12, q66 wrote: Positional specifier works just fine for me. Which version are you using? I'm on 2.058. git

isRandomAccessRange on static array

2012-04-09 Thread Brad Anderson
A user in IRC was having difficulty using std.algorithm.sort on a static array. It appears to be due to static arrays don't pass the isRandomAccessRange constraint. static assert(isRandomAccessRange!(uint[5])); Results in: Error: static assert (isRandomAccessRange!(uint[5u])) is fa

Re: Input from a newbie

2012-04-09 Thread Ali Çehreli
On 04/09/2012 08:50 AM, Jonas H. wrote: On 04/09/2012 05:39 PM, Andrej Mitrovic wrote: I don't think the compiler can warn about this. Isn't printf one of those unsafe C variadic functions? Someone correct me if I'm wrong. The GCC C compiler proves you wrong :) They have warnings. I guess it's

Re: Latest versions of Entice Designer and DFL?

2012-04-09 Thread vmars316
On Monday, 9 April 2012 at 18:34:36 UTC, Jesse Phillips wrote: You're going to need to step back from the build system for a moment and either use dfl.exe or the dmd command suggested. If your program is more than one file, make a program that is only one file. My only observation is -gui is

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread Ali Çehreli
On 04/09/2012 10:35 AM, Andrej Mitrovic wrote: On 4/9/12, Jonathan M Davis wrote: Posix positional arguments seem to work for writefln but not format for whatever reason. Report it as a bug. Thanks, http://d.puremagic.com/issues/show_bug.cgi?id=7877 Thanks. I hadn't seen this branch of the

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread Ali Çehreli
On 04/09/2012 10:24 AM, Andrej Mitrovic wrote: On 4/9/12, q66 wrote: Positional specifier works just fine for me. Which version are you using? I'm on 2.058. Positional parameters[*] are supported in 2.058. This example prints the same argument in decimal, hexadecimal, octal, and binary:

Re: Latest versions of Entice Designer and DFL?

2012-04-09 Thread Jesse Phillips
On Monday, 9 April 2012 at 17:35:41 UTC, vmars316 wrote: and my Bud.Bat looks like this: bud myForm.d -info -gui -version=gui -run -V pause Well, now you've added a level of indirection, which just makes identifying an issue even harder. You're going to need to step back from the build syst

Re: Input from a newbie

2012-04-09 Thread Jonas H.
On 04/09/2012 07:22 PM, Andrej Mitrovic wrote: I think most mentions of printf should just be removed from the dpl docs except maybe a few special places. People (or rather C++ refugees) seem to expect D to be a syntax sugared version of C++, but this myth has to be busted. I don't think that's

Re: Issue with const

2012-04-09 Thread Jacob Carlborg
On 2012-04-09 19:56, Steven Schveighoffer wrote: Then c.data cannot be the same reference as foo.data. Counter-case: void bar( const Foo foo) { auto c = foo.clone(); // assume this works; *(cast(int*)c.data) = 6; // note even though I'm casting, there is no removal of const, so this should be

Re: Issue with const

2012-04-09 Thread Jonathan M Davis
On Monday, April 09, 2012 19:51:17 Jacob Carlborg wrote: > On 2012-04-09 17:30, Steven Schveighoffer wrote: > > // untested > > inout(Foo) clone() inout { > > return new inout(Foo)(data); > > } > > > > Note, you can't post-assign data, since inout is effectively const > > inside an inout function.

Re: Issue with const

2012-04-09 Thread Steven Schveighoffer
On Mon, 09 Apr 2012 13:51:17 -0400, Jacob Carlborg wrote: On 2012-04-09 17:30, Steven Schveighoffer wrote: // untested inout(Foo) clone() inout { return new inout(Foo)(data); } Note, you can't post-assign data, since inout is effectively const inside an inout function. -Steve Ok, that wor

Re: A problem with mutable toString

2012-04-09 Thread bearophile
Maybe related to this? http://d.puremagic.com/issues/show_bug.cgi?id=7864

Re: Issue with const

2012-04-09 Thread Jacob Carlborg
On 2012-04-09 17:30, Steven Schveighoffer wrote: // untested inout(Foo) clone() inout { return new inout(Foo)(data); } Note, you can't post-assign data, since inout is effectively const inside an inout function. -Steve Ok, that works. But then I want to modify the clone: void bar (const Foo

Re: Latest versions of Entice Designer and DFL?

2012-04-09 Thread vmars316
On Monday, 9 April 2012 at 03:23:52 UTC, Jesse Phillips wrote: Thanks, I have DFL here: C:\D\dmd2\windows\bin\DFL and Entice here: C:\D\dmd2\windows\bin\Entice I decided to take the BUD route from here: http://www.dsource.org/projects/build And I installed it here: C:\D\dmd2\vmPrograms\BUDsrc a

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread Andrej Mitrovic
On 4/9/12, Jonathan M Davis wrote: > Posix positional arguments seem to work for writefln but not format for > whatever reason. Report it as a bug. Thanks, http://d.puremagic.com/issues/show_bug.cgi?id=7877

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread Jonathan M Davis
On Monday, April 09, 2012 19:08:54 Andrej Mitrovic wrote: > import std.string; > > void main() > { > string foo = "foo"; > string bar = format("%s %s %s", foo); > } > > format expects 3 arguments, but what I really want is foo to be used > for all 3 specifiers and not repeat 'foo' 3 times manuall

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread Andrej Mitrovic
On 4/9/12, q66 wrote: > Positional specifier works just fine for me. Which version are you using? I'm on 2.058.

Re: Input from a newbie

2012-04-09 Thread Andrej Mitrovic
On 4/9/12, Artur Skawina wrote: > However, there's no reason why *std.stdio* should expose the raw printf > function - i didn't even realize it did until now... > It either shouldn't be available via std.stdio at all, or something > like this wrapper should be added there, to catch the inevitable

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread q66
On Monday, 9 April 2012 at 17:09:03 UTC, Andrej Mitrovic wrote: import std.string; void main() { string foo = "foo"; string bar = format("%s %s %s", foo); } format expects 3 arguments, but what I really want is foo to be used for all 3 specifiers and not repeat 'foo' 3 times manually.

Multiple %s format specifiers with a single argument

2012-04-09 Thread Andrej Mitrovic
import std.string; void main() { string foo = "foo"; string bar = format("%s %s %s", foo); } format expects 3 arguments, but what I really want is foo to be used for all 3 specifiers and not repeat 'foo' 3 times manually. Are there any format specifiers that do what I want? I've tried usi

Re: Input from a newbie

2012-04-09 Thread Artur Skawina
On 04/09/12 17:39, Andrej Mitrovic wrote: > On 4/9/12, Jonas wrote: >> On Saturday, 7 April 2012 at 22:42:19 UTC, Stefan wrote: >>> printf is a C function which expects 0-terminated strings. D's >>> strings are variable-length arrays and not zero-terminated. >>> >>> Don't use printf. Try using wri

Re: Input from a newbie

2012-04-09 Thread bearophile
Jonas: Could you please elaborate on this a bit more? What's the problem with helpful compiler messages? Walter likes helpful error messages, but I think he doesn't want to: 1) Use too much time to improve them. There are usually more important problems to fix. 2) Slow down the compiler (or

Re: Input from a newbie

2012-04-09 Thread Jonas H.
On 04/09/2012 05:39 PM, Andrej Mitrovic wrote: I don't think the compiler can warn about this. Isn't printf one of those unsafe C variadic functions? Someone correct me if I'm wrong. The GCC C compiler proves you wrong :) They have warnings. I guess it's a hack (because printf really doesn't b

Re: string concatenation

2012-04-09 Thread Steven Schveighoffer
On Sun, 08 Apr 2012 01:08:09 -0400, dnewbie wrote: I have a wchar[] and I want to convert it to UTF8 then append a string. This is my code. import std.c.windows.windows; import std.string; import std.utf; int main() { wchar[100] v; v[0] = 'H'; v[1] = 'e'; v[2] = 'l'; v[3] = 'l'

Re: "How to set up QTD?".

2012-04-09 Thread vmars316
On Monday, 9 April 2012 at 12:52:47 UTC, Kevin Cox wrote: I think rcc is the Qt resource compiler. I'm not at my computer at the moment to check, but if so it will translate xml resource files into D source. "I think rcc is the Qt resource compiler." I don't know what the above means. What

Re: Input from a newbie

2012-04-09 Thread Andrej Mitrovic
On 4/9/12, Jonas wrote: > On Saturday, 7 April 2012 at 22:42:19 UTC, Stefan wrote: >> printf is a C function which expects 0-terminated strings. D's >> strings are variable-length arrays and not zero-terminated. >> >> Don't use printf. Try using writef instead. Same arguments. > > http://d.puremag

Re: Issue with const

2012-04-09 Thread Steven Schveighoffer
On Mon, 09 Apr 2012 11:22:54 -0400, Jacob Carlborg wrote: On 2012-04-09 16:52, Timon Gehr wrote: On 04/09/2012 04:49 PM, Jacob Carlborg wrote: But now when I compile this code I get this error: Error: cannot implicitly convert expression (this.data) of type const(void*) to void* Any idea h

Re: Input from a newbie

2012-04-09 Thread Jonas
On Sunday, 8 April 2012 at 03:55:33 UTC, Jonathan M Davis wrote: On Sunday, April 08, 2012 00:21:35 Jonas wrote: 1) First off, I really couldn't figure out were I was supposed to post this sort of message. Apparently there aren't any mailing lists (a la Google groups) for D? These are both n

Re: Issue with const

2012-04-09 Thread Jacob Carlborg
On 2012-04-09 16:52, Timon Gehr wrote: On 04/09/2012 04:49 PM, Jacob Carlborg wrote: But now when I compile this code I get this error: Error: cannot implicitly convert expression (this.data) of type const(void*) to void* Any idea how to solve this? Or would I need to drop const. -- /Jacob C

Re: Input from a newbie

2012-04-09 Thread Jonas
On Saturday, 7 April 2012 at 23:58:20 UTC, bearophile wrote: Jonas: Hello D community! :-) Welcome here. I was looking for a sane, object-oriented, possible-to-go-low-level programming language, so I decided to give D a try today. D supports OOP well enough, but template-based programmi

Re: Input from a newbie

2012-04-09 Thread Jonas
On Saturday, 7 April 2012 at 22:42:19 UTC, Stefan wrote: printf is a C function which expects 0-terminated strings. D's strings are variable-length arrays and not zero-terminated. Don't use printf. Try using writef instead. Same arguments. http://d.puremagic.com/issues/show_bug.cgi?id=7872

Re: Issue with const

2012-04-09 Thread Timon Gehr
On 04/09/2012 04:49 PM, Jacob Carlborg wrote: But now when I compile this code I get this error: Error: cannot implicitly convert expression (this.data) of type const(void*) to void* Any idea how to solve this? Or would I need to drop const. -- /Jacob Carlborg Either clone the data too or u

Issue with const

2012-04-09 Thread Jacob Carlborg
Say I have type and a function look like this: class Foo { void* data; Foo clone () { auto c = new Foo; c.data = data; return c; } } void bar (Foo foo) { auto c = foo.clone(); ... } Since I'm not changing anything on "foo" I thought that it coul

Re: "How to set up QTD?".

2012-04-09 Thread Kevin Cox
On Apr 8, 2012 10:59 PM, "vmars316" wrote: > > Greetings, > I would also like to try out QTD. > > So far, I have set things up this: > C:\D\dmd2\QT > > I made a .batch file for both drcc.exe and duic.exe . > duic.exe gave no feedback. > > drcc.exe gave the following feedback: > > C:\D\dmd2\QT\bin>

Re: Operator Overloading with class template

2012-04-09 Thread Eyyub
On Monday, 9 April 2012 at 09:09:05 UTC, James Miller wrote: * Eyyub [2012-04-09 01:14:32 +0200]: Hello, How can I rewrite the exemple 2 (http://pastebin.com/q50903Zh) in D lang. ? This source code doesn't work...why ? http://paste.pocoo.org/show/wy1kDIpqTi2ApRuOxRRb/ Thx. :) What you

Re: Operator Overloading with class template

2012-04-09 Thread James Miller
* Eyyub [2012-04-09 01:14:32 +0200]: > Hello, > > How can I rewrite the exemple 2 (http://pastebin.com/q50903Zh) in D > lang. ? > This source code doesn't work...why ? > http://paste.pocoo.org/show/wy1kDIpqTi2ApRuOxRRb/ > > Thx. :) > What you want is something like this: class Value(int