Re: Threading Questions
On Friday, 9 October 2015 at 04:04:42 UTC, bitwise wrote: Ah, I see. I thought you meant illegal meant it won't compile. Wouldn't it be more correct to say that it's undefined behaviour? I's probably not as undefined as in C case, i.e. it doesn't break safety guarantees, only the application's high-level business logic gets confused by data races.
Re: Comparing arrays of floats?
On Friday, 9 October 2015 at 22:14:09 UTC, Straivers wrote: Forgive me if this has already been discussed, but how are arrays of floating point numbers compared in D? i.e. Is it a bit-by-bit comparison, is the std.math.approxEqual function get called for each element, or is it byte-by-byte across the entire array? -Straivers If you want to compare them with approxEqual, you can do: arr1.equal!approxEqual(arr2)
Re: Comparing arrays of floats?
On Saturday 10 October 2015 00:14, Straivers wrote: > Is it a bit-by-bit comparison, no > is the std.math.approxEqual function get called for > each element, no > or is it byte-by-byte across the entire array? no After comparing the lengths, the elements are checked for equality one by one, using the usual `==` operator. `==` is different from bitwise comparison. For example, -0f and +0f are `==` equal but have different bits, and NaNs are equal no nothing, not even themselves.
Re: Array of BitArrays definition compiles in DMD but not in GDC.
On Thursday, 8 October 2015 at 21:40:02 UTC, TheGag96 wrote: 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, 1, 1, 1]), BitArray([0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), BitArray([0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), BitArray([1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1]), ]); The code compiles fine when using DMD 2.068.1 but GDC 5.2.1, I get this error for every line: error: cannot implicityly convert expression ([stuff]) of type int[] to ulong Why does this compiler difference exist and how do I get around it? Thanks! gdc is a bit out of date at the moment. If you do something like this: auto bitArray(bool[] ba) pure nothrow { BitArray tmp; tmp.init(ba); return tmp; } auto bitArray(void[] v, size_t numbits) pure nothrow { BitArray tmp; tmp.init(v, numbits); return tmp; } then replace all your calls to the constructor BitArray with bitArray, things should work OK for you.
Comparing arrays of floats?
Forgive me if this has already been discussed, but how are arrays of floating point numbers compared in D? i.e. Is it a bit-by-bit comparison, is the std.math.approxEqual function get called for each element, or is it byte-by-byte across the entire array? -Straivers
Re: AWS API Dlang, hmac sha256 function.
OK i find out error, in addRequestHeader i was using ":" after header name what casing problem. I removed it and now im getting "unauthorized". Here is how it looks right now: HTTP/1.1 401 Unauthorized\r\n [Expert Info (Chat/Sequence): HTTP/1.1 401 Unauthorized\r\n] Request Version: HTTP/1.1 Status Code: 401 Response Phrase: Unauthorized Transfer-Encoding: chunked\r\n Date: Fri, 09 Oct 2015 16:22:47 GMT\r\n Server: AmazonEC2\r\n \r\n [HTTP response 1/2] [Next request in frame: 8371] HTTP chunked response Data chunk (254 octets) Chunk size: 254 octets Data (254 bytes) In data field i can read: "AWS was not able to validate provided access credentials" Is my signing process incorrect?
Re: Array of BitArrays definition compiles in DMD but not in GDC.
On Friday, 9 October 2015 at 07:08:15 UTC, John Colvin wrote: On Thursday, 8 October 2015 at 21:40:02 UTC, TheGag96 wrote: [...] gdc is a bit out of date at the moment. If you do something like this: auto bitArray(bool[] ba) pure nothrow { BitArray tmp; tmp.init(ba); return tmp; } auto bitArray(void[] v, size_t numbits) pure nothrow { BitArray tmp; tmp.init(v, numbits); return tmp; } then replace all your calls to the constructor BitArray with bitArray, things should work OK for you. That appears to work, although the compiler was complaining that the calls to init were not pure nor nothrow. Thanks! Hopefully they'll update GDC soon.
lint? for D
Is there a lint program for D, similar to say pep8 + pyflakes for python that can warn the programmer about unused imports, unused variables etc.,?
Re: AWS API Dlang, hmac sha256 function.
I correct typo (thats whats happening when you trying to solve problem after night at 6:00 AM ).But still have same error. When use curl with same generated creditentials im getting "400". What is strange when im using same generated headers and signature with command line curl im getting "500". My headers right now: auto client = HTTP(); client.clearRequestHeaders; client.addRequestHeader("Content-Type:", "application/x-www-form-urlencoded; charset=utf-8"); client.addRequestHeader("Host:", service ~ ".amazonaws.com"); client.addRequestHeader("X-Amz-Date:", xamztime); client.addRequestHeader("Authorization:", "AWS4-HMAC-SHA256" ~ " " ~ "Credential=" ~ accKey ~ "/" ~ xamztime ~ "/" ~ zone ~ "/" ~ service ~ "/" ~ "aws4_request" ~ ", " ~ "SignedHeaders=" ~ "content-type;host;x-amz-date" ~ ", " ~ "Signature=" ~ signature); auto url = service ~ ".amazonaws.com?" ~ "Action=DescribeInstances=2013-10-15"; writeln(url); auto content = get(url, client); writeln(content); Did i set up it correctly?
Re: lint? for D
On Friday, 9 October 2015 at 12:28:50 UTC, Pradeep Gowda wrote: Is there a lint program for D, similar to say pep8 + pyflakes for python that can warn the programmer about unused imports, unused variables etc.,? https://github.com/Hackerpilot/Dscanner dscanner --syntaxCheck or dscanner --styleCheck
Re: Bug? 0 is less than -10
On Thursday, 8 October 2015 at 09:01:32 UTC, Dominikus Dittes Scherkl wrote: 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 have even improved my solution posted to fix bug #259 to use less casts: int opCmp(T, U)(const(T) a, const(U) b) pure @safe @nogc nothrow if(isIntegral!T && isIntegral!U && !is(Unqual!T == Unqual!U)) { static if(isSigned!T && isUnsigned!U && T.sizeof <= U.sizeof) ... And on comparison with number literals everything will be optimized away, so no execution timer overhead at all! I like your solution! +1