multidimensional array

2014-09-28 Thread Joel via Digitalmars-d-learn
I'm trying to make a multidimensional array. I feel I've tried every thing. Is there a good guide explaining it? struct Spot { bool dot; } spots = new Spot[][](800,600); assert(spots[800-1][600-1].dot, Out of bounds);

Re: multidimensional array

2014-09-28 Thread JKPdouble via Digitalmars-d-learn
On Sunday, 28 September 2014 at 04:24:25 UTC, Joel wrote: I'm trying to make a multidimensional array. I feel I've tried every thing. Is there a good guide explaining it? struct Spot { bool dot; } spots = new Spot[][](800,600); assert(spots[800-1][600-1].dot, Out of bounds); dot is

Re: multidimensional array

2014-09-28 Thread JKPdouble via Digitalmars-d-learn
On Sunday, 28 September 2014 at 04:38:56 UTC, JKPdouble wrote: On Sunday, 28 September 2014 at 04:24:25 UTC, Joel wrote: I'm trying to make a multidimensional array. I feel I've tried every thing. Is there a good guide explaining it? struct Spot { bool dot; } spots = new Spot[][](800,600);

Re: multidimensional array

2014-09-28 Thread ketmar via Digitalmars-d-learn
On Sun, 28 Sep 2014 04:24:19 + Joel via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: struct Spot { bool dot; } spots = new Spot[][](800,600); btw, does anybody know why i can do `new ubyte[256];` but not `new ubyte[256][256];`? hate that. signature.asc Description: PGP

isArray and std.container.Array

2014-09-28 Thread Nordlöw
Is there a reason why isArray!T doesn't match T when T is a std.container.Array? I'm asking because after looking into msgpack-d because of http://forum.dlang.org/thread/aclapseyptgcwntda...@forum.dlang.org#post-aclapseyptgcwntdavwt:40forum.dlang.org I realized that this is the reason why

Re: std.container.Array support in msgpack

2014-09-28 Thread Nordlöw
On Saturday, 27 September 2014 at 21:24:14 UTC, Nordlöw wrote: How do I add the leading byte 146? Update: This is achieved by calling stream_.put() which is only allowed in members of PackerImpl.

Re: multidimensional array

2014-09-28 Thread Stefan Frijters via Digitalmars-d-learn
On Sunday, 28 September 2014 at 04:24:25 UTC, Joel wrote: I'm trying to make a multidimensional array. I feel I've tried every thing. Is there a good guide explaining it? struct Spot { bool dot; } spots = new Spot[][](800,600); assert(spots[800-1][600-1].dot, Out of bounds); You

Non-const std.container.Array.opIndex and alikes blocks serialization

2014-09-28 Thread Nordlöw
In my strive to add msgpacking support for std.container.Array I've been blocked by the fact that std.container.Array.opIndex only has one overload which is non-const probably because it returns a ref T. This doesn't place nicely with serialization. Shouldn't inout be used here?

Re: Non-const std.container.Array.opIndex and alikes blocks serialization

2014-09-28 Thread Nordlöw
On Sunday, 28 September 2014 at 08:58:27 UTC, Nordlöw wrote: In my strive to add msgpacking support for std.container.Array I've been blocked by the fact that std.container.Array.opIndex only has one overload which is non-const probably because it returns a ref T. This doesn't place nicely

How do you get T from shared(T) ?

2014-09-28 Thread Marco Leise via Digitalmars-d-learn
For head-unshared there is `static if (is(T U : shared U))`. But how do you get the unshared type for anything from `shared void*` to `shared uint` ? -- Marco

Re: How do you get T from shared(T) ?

2014-09-28 Thread tcak via Digitalmars-d-learn
On Sunday, 28 September 2014 at 09:11:07 UTC, Marco Leise wrote: For head-unshared there is `static if (is(T U : shared U))`. But how do you get the unshared type for anything from `shared void*` to `shared uint` ? shared int a; int b = cast()a;

Prompting using stdio

2014-09-28 Thread Nordlöw
I thought int main(string[] args) { import std.stdio; write(`Press enter to continue: `); stdout.flush; auto line = readln(); writeln(Read , line); return 0; } would function as a good prompting but it doesn't. I outputs the string given to write *after* I've pressed

DUB warnings causing failure?

2014-09-28 Thread Nordlöw
My https://github.com/nordlow/justd/blob/master/dub.json fails as WARNING: A deprecated branch based version specification is used for the dependency dchip. Please use numbered versions instead. Also note that you can still use the dub.selections.json file to override a certain dependency

Re: How do you get T from shared(T) ?

2014-09-28 Thread Marco Leise via Digitalmars-d-learn
Am Sun, 28 Sep 2014 14:07:22 + schrieb tcak t...@gmail.com: On Sunday, 28 September 2014 at 09:11:07 UTC, Marco Leise wrote: For head-unshared there is `static if (is(T U : shared U))`. But how do you get the unshared type for anything from `shared void*` to `shared uint` ? shared

Re: DUB warnings causing failure?

2014-09-28 Thread Nordlöw
On Sunday, 28 September 2014 at 14:31:33 UTC, Nordlöw wrote: https://github.com/nordlow/justd/blob/master/dub.json fails as Shouldn't buildRequirements: [allowWarnings], affect build rules of dependencies aswell?

Re: multidimensional array

2014-09-28 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Sep 28, 2014 at 10:48:45AM +0300, ketmar via Digitalmars-d-learn wrote: On Sun, 28 Sep 2014 04:24:19 + Joel via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: struct Spot { bool dot; } spots = new Spot[][](800,600); btw, does anybody know why i can do `new

Re: Prompting using stdio

2014-09-28 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Sep 28, 2014 at 02:16:29PM +, Nordlöw via Digitalmars-d-learn wrote: I thought int main(string[] args) { import std.stdio; write(`Press enter to continue: `); stdout.flush; auto line = readln(); writeln(Read , line); return 0; } would function as

Re: DUB warnings causing failure?

2014-09-28 Thread Mike Parker via Digitalmars-d-learn
On 9/28/2014 11:31 PM, Nordlöw wrote: Running dmd... ../../.dub/packages/dchip-master/src/dchip/cpCollision.d(350): Warning: instead of C-style syntax, use D-style syntax 'MinkowskiPoint[3] hull' FAIL

Re: Prompting using stdio

2014-09-28 Thread via Digitalmars-d-learn
On Sunday, 28 September 2014 at 14:48:03 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Sun, Sep 28, 2014 at 02:16:29PM +, Nordlöw via Digitalmars-d-learn wrote: I thought int main(string[] args) { import std.stdio; write(`Press enter to continue: `); stdout.flush; auto

Re: Prompting using stdio

2014-09-28 Thread Nordlöw
On Sunday, 28 September 2014 at 15:36:17 UTC, Marc Schütz wrote: However, I can't reproduce it with DMD master on Linux, it works for me as intended. My fault. I was too clever and call the program through a wrapper to rdmd I call rdmd-dev containing #!/usr/bin/env bash # See also:

Re: Prompting using stdio

2014-09-28 Thread Nordlöw
On Sunday, 28 September 2014 at 16:01:06 UTC, Nordlöw wrote: The piping to ddemangle messed things up... Thanks anyway. Does anybody have a better solution to this? I would still like the linker error output be ddemangled...

Re: isArray and std.container.Array

2014-09-28 Thread Meta via Digitalmars-d-learn
On Sunday, 28 September 2014 at 08:01:00 UTC, Nordlöw wrote: Is there a reason why isArray!T doesn't match T when T is a std.container.Array? I'm asking because after looking into msgpack-d because of

Re: isArray and std.container.Array

2014-09-28 Thread via Digitalmars-d-learn
On Sunday, 28 September 2014 at 16:12:53 UTC, Meta wrote: On Sunday, 28 September 2014 at 08:01:00 UTC, Nordlöw wrote: Is there a reason why isArray!T doesn't match T when T is a std.container.Array? I'm asking because after looking into msgpack-d because of

is there any reason UFCS can't be used with 'new'?

2014-09-28 Thread Jay via Digitalmars-d-learn
i want to chain 'new' with method calls on the created object. i found this on the internet: window.mainWidget = (new Button()).text(Hello worldd).textColor(0xFF); it would look much nicer with UFCS: window.mainWidget = Button.new().text(Hello worldd).textColor(0xFF); well, it's

Re: Prompting using stdio

2014-09-28 Thread via Digitalmars-d-learn
On Sunday, 28 September 2014 at 16:02:44 UTC, Nordlöw wrote: On Sunday, 28 September 2014 at 16:01:06 UTC, Nordlöw wrote: The piping to ddemangle messed things up... Thanks anyway. Does anybody have a better solution to this? I would still like the linker error output be ddemangled... You

Re: is there any reason UFCS can't be used with 'new'?

2014-09-28 Thread Foo via Digitalmars-d-learn
On Sunday, 28 September 2014 at 19:11:23 UTC, Jay wrote: i want to chain 'new' with method calls on the created object. i found this on the internet: window.mainWidget = (new Button()).text(Hello worldd).textColor(0xFF); it would look much nicer with UFCS: window.mainWidget =

Re: is there any reason UFCS can't be used with 'new'?

2014-09-28 Thread Jay via Digitalmars-d-learn
thanks! but i'm still interested *why* you can't have this with 'new'. if there's no good reason i will file a bug report. On Sunday, 28 September 2014 at 19:19:56 UTC, Foo wrote: mixin template New(T) if (is(T == class)) { static T New(Args...)(Args args) { return new

Re: is there any reason UFCS can't be used with 'new'?

2014-09-28 Thread Idan Arye via Digitalmars-d-learn
On Sunday, 28 September 2014 at 19:32:11 UTC, Jay wrote: thanks! but i'm still interested *why* you can't have this with 'new'. if there's no good reason i will file a bug report. Because `new` is not a function - it's an operator.

Re: is there any reason UFCS can't be used with 'new'?

2014-09-28 Thread Jay via Digitalmars-d-learn
On Sunday, 28 September 2014 at 19:41:29 UTC, Idan Arye wrote: Because `new` is not a function - it's an operator. do you think the function call syntax has any chance to be implemented? is it just me who needs it?

Re: isArray and std.container.Array

2014-09-28 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 28 September 2014 at 19:06:09 UTC, Marc Schütz wrote: On Sunday, 28 September 2014 at 16:12:53 UTC, Meta wrote: On Sunday, 28 September 2014 at 08:01:00 UTC, Nordlöw wrote: Is there a reason why isArray!T doesn't match T when T is a std.container.Array? I'm asking because after

Re: is there any reason UFCS can't be used with 'new'?

2014-09-28 Thread Jay via Digitalmars-d-learn
On Sunday, 28 September 2014 at 19:19:56 UTC, Foo wrote: mixin template New(T) if (is(T == class)) { static T New(Args...)(Args args) { return new T(args); } } fwiw here's what i wrote: template New(T) if (is(T == class)) { T New(Args...) (Args args) {

Re: Non-const std.container.Array.opIndex and alikes blocks serialization

2014-09-28 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 28 September 2014 at 09:04:42 UTC, Nordlöw wrote: On Sunday, 28 September 2014 at 08:58:27 UTC, Nordlöw wrote: In my strive to add msgpacking support for std.container.Array I've been blocked by the fact that std.container.Array.opIndex only has one overload which is non-const

Re: is there any reason UFCS can't be used with 'new'?

2014-09-28 Thread Meta via Digitalmars-d-learn
On Sunday, 28 September 2014 at 19:11:23 UTC, Jay wrote: i want to chain 'new' with method calls on the created object. i found this on the internet: window.mainWidget = (new Button()).text(Hello worldd).textColor(0xFF); it would look much nicer with UFCS: window.mainWidget =

Re: is there any reason UFCS can't be used with 'new'?

2014-09-28 Thread Jay via Digitalmars-d-learn
On Sunday, 28 September 2014 at 20:30:42 UTC, Meta wrote: class Button { typeof(this) text(string t) { return this; } typeof(this) textColour(int c) { return this; } } void main() { auto b = new

Localizing a D application - best practices?

2014-09-28 Thread Cliff via Digitalmars-d-learn
Coming from the C# world, all of localization we did was based on defining string resource files (XML-formatted source files which were translated into C# classes with named-string accessors by the build process) that would get included in the final application. For log messages, exception

Re: multidimensional array

2014-09-28 Thread Stewart Gordon via Digitalmars-d-learn
On 28/09/2014 08:48, ketmar via Digitalmars-d-learn wrote: On Sun, 28 Sep 2014 04:24:19 + Joel via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: struct Spot { bool dot; } spots = new Spot[][](800,600); btw, does anybody know why i can do `new ubyte[256];` but not `new

Re: is there any reason UFCS can't be used with 'new'?

2014-09-28 Thread Meta via Digitalmars-d-learn
On Sunday, 28 September 2014 at 20:50:07 UTC, Jay wrote: On Sunday, 28 September 2014 at 20:30:42 UTC, Meta wrote: class Button { typeof(this) text(string t) { return this; } typeof(this) textColour(int c) { return

Re: multidimensional array

2014-09-28 Thread ketmar via Digitalmars-d-learn
On Sun, 28 Sep 2014 07:40:23 -0700 H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: File a bug. https://issues.dlang.org/show_bug.cgi?id=13556 signature.asc Description: PGP signature

Re: multidimensional array

2014-09-28 Thread ketmar via Digitalmars-d-learn
On Sun, 28 Sep 2014 22:33:40 +0100 Stewart Gordon via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: You can do `new ubyte[256][256]`, if the destination type is a ubyte[256][]. The reason is that you are performing an allocation of the form `new T[n]`, which means allocate an