Re: Bug? 0 is less than -10

2015-10-08 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Wednesday, 7 October 2015 at 16:25:02 UTC, Marc Schütz wrote: Lionello Lunesu posted a PR that should fix this: https://github.com/D-Programming-Language/dmd/pull/1913 See also the discussion in the linked bug report. Unfortunately it seems it's been forgotten since then... Meanwhile I

Re: Tell GC to use shared memory

2015-10-08 Thread tcak via Digitalmars-d-learn
On Thursday, 8 October 2015 at 05:46:31 UTC, ketmar wrote: On Thursday, 8 October 2015 at 04:38:43 UTC, tcak wrote: Is it possible to modify GC (without rebuilding the compiler), so it uses a given shared memory area instead of heap for allocations? sure. you don't need to rebuild the

Check template parameter whether it has "length"

2015-10-08 Thread tcak via Digitalmars-d-learn
I am "trying" to write a function that takes an array of items, and returns the length of longest item. [code] size_t maxLength(A)( const A[] listOfString ) if( __traits( hasMember, A, "length" ) ) { return 0; // not implemented yet } [/code] I tried it with if( __traits( compiles,

Re: Check template parameter whether it has "length"

2015-10-08 Thread John Colvin via Digitalmars-d-learn
On Thursday, 8 October 2015 at 09:29:30 UTC, tcak wrote: I am "trying" to write a function that takes an array of items, and returns the length of longest item. [code] size_t maxLength(A)( const A[] listOfString ) if( __traits( hasMember, A, "length" ) ) { return 0; // not

Re: Threading Questions

2015-10-08 Thread Kagamin via Digitalmars-d-learn
On Thursday, 8 October 2015 at 02:31:24 UTC, bitwise wrote: If you have System.Collections.Generic.List(T) static class member, there is nothing wrong with using it from multiple threads like this: The equivalent of your D example would be class Foo { static List numbers = new List();

Re: Check template parameter whether it has "length"

2015-10-08 Thread Artur Skawina via Digitalmars-d-learn
On 10/08/15 11:29, tcak via Digitalmars-d-learn wrote: > I am "trying" to write a function that takes an array of items, and returns > the length of longest item. > > [code] > size_t maxLength(A)( const A[] listOfString ) if( __traits( hasMember, A, > "length" ) ) > { > return 0; // not

Re: Tell GC to use shared memory

2015-10-08 Thread Kagamin via Digitalmars-d-learn
GC is chosen at link time simply to satisfy unresolved symbols. You only need to compile your modified GC and link with it, it will be chosen instead of GC from druntime, no need to recompile anything else.

Re: Check template parameter whether it has "length"

2015-10-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 8 October 2015 at 09:29:30 UTC, tcak wrote: I am "trying" to write a function that takes an array of items, and returns the length of longest item. [code] size_t maxLength(A)( const A[] listOfString ) if( __traits( hasMember, A, "length" ) ) { return 0; // not

Re: Threading Questions

2015-10-08 Thread bitwise via Digitalmars-d-learn
On Thursday, 8 October 2015 at 10:11:38 UTC, Kagamin wrote: On Thursday, 8 October 2015 at 02:31:24 UTC, bitwise wrote: If you have System.Collections.Generic.List(T) static class member, there is nothing wrong with using it from multiple threads like this: The equivalent of your D example

Re: Bug? 0 is less than -10

2015-10-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/7/15 1:27 AM, Laeeth Isharc wrote: On Wednesday, 7 October 2015 at 02:53:32 UTC, Steven Schveighoffer wrote: On 10/6/15 7:21 PM, Laeeth Isharc wrote: could we have ssize_t defined in phobos somewhere so your code ends up being portable ;) (It's trivial to do, obviously). ptrdiff_t

Re: Check template parameter whether it has "length"

2015-10-08 Thread tcak via Digitalmars-d-learn
On Thursday, 8 October 2015 at 09:50:12 UTC, John Colvin wrote: On Thursday, 8 October 2015 at 09:29:30 UTC, tcak wrote: [...] I'm 99% sure something like __traits(hasMember, int[], "length" ) should evaluate to true. Please file a bug at issues.dlang.org I notice it also doesn't work for

Re: Check template parameter whether it has "length"

2015-10-08 Thread John Colvin via Digitalmars-d-learn
On Thursday, 8 October 2015 at 15:22:02 UTC, tcak wrote: BTW, there is nothing like std.traits.hasLength. yeah, that's because __traits(hasMember, ...) should be good enough, but obviously not in this case at the moment.

Re: Check template parameter whether it has "length"

2015-10-08 Thread Meta via Digitalmars-d-learn
On Thursday, 8 October 2015 at 15:22:02 UTC, tcak wrote: BTW, there is nothing like std.traits.hasLength. You're just looking in the wrong place =) http://dlang.org/phobos/std_range_primitives.html#hasLength

Re: Threading Questions

2015-10-08 Thread Kagamin via Digitalmars-d-learn
On Thursday, 8 October 2015 at 13:44:46 UTC, bitwise wrote: That still doesn't explain what you mean about it being illegal in other languages or why you brought up C# in the first place. Illegal means the resulting program behaves incorrectly, potentially leading to silent failures and data

Array of BitArrays definition compiles in DMD but not in GDC.

2015-10-08 Thread TheGag96 via Digitalmars-d-learn
In my code I'm passing an array of BitArrays to a constructor like this (though mostly as a placeholder): Terrain t = new Terrain(1, 15, [ BitArray([1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), BitArray([1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), BitArray([0, 0, 1, 1, 1, 0, 1, 1, 1, 1,

Re: How to check if JSONValue of type object has a key?

2015-10-08 Thread Borislav Kosharov via Digitalmars-d-learn
Thanks guys that was I was looking for!

Re: Threading Questions

2015-10-08 Thread bitwise via Digitalmars-d-learn
On Thursday, 8 October 2015 at 20:42:46 UTC, Kagamin wrote: On Thursday, 8 October 2015 at 13:44:46 UTC, bitwise wrote: That still doesn't explain what you mean about it being illegal in other languages or why you brought up C# in the first place. Illegal means the resulting program behaves

Re: AWS API Dlang, hmac sha256 function.

2015-10-08 Thread holo via Digitalmars-d-learn
I was fighting with it a little bit and after all i just leave original function which was in code, removed dependencies from vibe.d and finally tried to contact api. Here is my present code: #!/usr/bin/rdmd -L-lcurl import std.stdio; import std.string; import std.file; import std.datetime;

Re: AWS API Dlang, hmac sha256 function.

2015-10-08 Thread Laeeth Isharc via Digitalmars-d-learn
On Friday, 9 October 2015 at 04:04:57 UTC, holo wrote: r.dateString = client.addRequestHeader("Authoryzation:", "AWS4-HMAC-SHA256" ~ " " ~ "Credential=" ~ accKey ~ "/" ~ xamztime ~ "/" ~ zone ~ "/" ~ service ~ "/" ~ "aws4_request" ~ ", " ~ "SignedHeaders=" ~ "content-type;host;x-amz-date" ~

Re: Bug? 0 is less than -10

2015-10-08 Thread Laeeth Isharc via Digitalmars-d-learn
On Thursday, 8 October 2015 at 13:32:17 UTC, Steven Schveighoffer wrote: On 10/7/15 1:27 AM, Laeeth Isharc wrote: On Wednesday, 7 October 2015 at 02:53:32 UTC, Steven Schveighoffer wrote: On 10/6/15 7:21 PM, Laeeth Isharc wrote: could we have ssize_t defined in phobos somewhere so your code