Re: Bug? 0 is less than -10

2015-10-06 Thread Laeeth Isharc via Digitalmars-d-learn
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 -Steve It seems unnatural to use such a

Re: What is the postfix for min long value?

2015-10-06 Thread anonymous via Digitalmars-d-learn
On Tuesday 06 October 2015 17:39, Ali Çehreli wrote: > I would expect the following to work: > > writeln( -9_223_372_036_854_775_808L); > > But it doesn't compile: > >Error: signed integer overflow > > It looks like a compiler bug to me. If so, a very embarrassing one. :)

What is the postfix for min long value?

2015-10-06 Thread tcak via Digitalmars-d-learn
While writing max ulong value, I added the "u" postfix. So compiler accepted it as ulong value (That's my interpretation if correct on compiler's side). writeln( 18_446_744_073_709_551_615u ); But when I try to print out minimum value of long, compiler says Error: signed integer overflow

Bug? 0 is less than -10

2015-10-06 Thread tcak via Digitalmars-d-learn
Maybe I am just too stressed out to see the problem. [code] import std.stdio; void main(){ size_t dec = 0; writeln( dec, " ", (dec <= -10), " ", (dec >= 10), " ", ((dec <= -10) || (dec >= 10)) ); } [/code] [output] 0 true false true [/output] How is it generating "true" for (dec

Re: Bug? 0 is less than -10

2015-10-06 Thread anonymous via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 14:46:56 UTC, tcak wrote: Maybe I am just too stressed out to see the problem. [code] import std.stdio; void main(){ size_t dec = 0; writeln( dec, " ", (dec <= -10), " ", (dec >= 10), " ", ((dec <= -10) || (dec >= 10)) ); } [/code] [output] 0 true

Re: Bug? 0 is less than -10

2015-10-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 14:46:56 UTC, tcak wrote: void main(){ size_t dec = 0; How is it generating "true" for (dec <= -10) ? Is there a special casting or something? size_t is unsigned, so the -10 is cast to unsigned too for the comparison which yields some huge number.

Re: SysTime bug or feature?

2015-10-06 Thread tchaloupka via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 05:54:44 UTC, Jonathan M Davis wrote: It is by design, albeit undesirable. When SysTime was originally written, it was impossible to have a default value for a class reference other than null. So, unless SysTime was going to take the performance hit of constantly

Re: Picking specific D compiler with rdmd

2015-10-06 Thread Dicebot via Digitalmars-d-learn
--compiler

Re: Picking specific D compiler with rdmd

2015-10-06 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 07:16:39 UTC, Nordlöw wrote: I find now flag to rdmd for choosing a specific dmd. Is there none? Doh, there was already: --compiler

Picking specific D compiler with rdmd

2015-10-06 Thread Nordlöw via Digitalmars-d-learn
I find now flag to rdmd for choosing a specific dmd. Is there none?

Re: std.Algebraic alias this

2015-10-06 Thread Radu via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 06:37:16 UTC, Nicholas Wilson wrote: On Monday, 5 October 2015 at 11:31:32 UTC, Radu wrote: There is a weird rule on how compiler treats alias this for the N and S types bellow. [...] Please file a bug report. Also do the errors change if you reverse the order

Re: std.Algebraic alias this

2015-10-06 Thread Radu via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 06:37:16 UTC, Nicholas Wilson wrote: On Monday, 5 October 2015 at 11:31:32 UTC, Radu wrote: There is a weird rule on how compiler treats alias this for the N and S types bellow. [...] Please file a bug report. Also do the errors change if you reverse the order

Re: std.Algebraic alias this

2015-10-06 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 5 October 2015 at 11:31:32 UTC, Radu wrote: There is a weird rule on how compiler treats alias this for the N and S types bellow. [...] Please file a bug report. Also do the errors change if you reverse the order in T i.e. alias T = Algebraic!(S,N); ?

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

2015-10-06 Thread Borislav Kosharov via Digitalmars-d-learn
I'm using std.json for parsing json. I need to check if a specific string key is in JSONValue.object. The first thing I tried was: JSONValue root = parseJSON(text); if(root["key"].isNull == false) { //do stuff with root["key"] } But that code doesn't work, because calling root["key"] will

Re: Varargs and default arguments

2015-10-06 Thread anonymous via Digitalmars-d-learn
On Tuesday 06 October 2015 22:01, Nick Sabalausky wrote: > Ok, D-style varargs can accept a parameter length of zero: > > --- > void foo(T...)(T args) { > //... > } > foo(); > foo(t1, t2); > --- Terminology fun: The spec uses the term "D-style variadic function"

Problem with type cast in if condition

2015-10-06 Thread NiRu via Digitalmars-d-learn
Hi there, I have a problem with the typecast within my if condition, the dmd2 compiler says he can not cast int to User, but it never reaches an int type the condition (at most, the else branch). my try: struct User { string name; } void printName(T)(T value) {

Varargs and default arguments

2015-10-06 Thread Nick Sabalausky via Digitalmars-d-learn
Ok, D-style varargs can accept a parameter length of zero: --- void foo(T...)(T args) { //... } foo(); foo(t1, t2); --- Is there any way to stick a param with a default value before that? --- void foo(T...)(string str=null, T args=/+what goes here???+/)

Re: Problem with type cast in if condition

2015-10-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 20:35:28 UTC, NiRu wrote: if(is(typeof(value) == User)){ Use `static if` instead of plain `if` here. Regular if does a runtime branch, so both true and else branches must compile with the same types. Static if does a compile time branch, allowing

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

2015-10-06 Thread via Digitalmars-d-learn
On Tue, Oct 06, 2015 at 08:28:46PM +, Borislav Kosharov via Digitalmars-d-learn wrote: > JSONValue root = parseJSON(text); > if(root["key"].isNull == false) { try if("key" in root) { // it is there } else { // it is not there } you can also do if("key" !in root) {}

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

2015-10-06 Thread Fusxfaranto via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 20:44:30 UTC, via Digitalmars-d-learn wrote: On Tue, Oct 06, 2015 at 08:28:46PM +, Borislav Kosharov via Digitalmars-d-learn wrote: JSONValue root = parseJSON(text); if(root["key"].isNull == false) { try if("key" in root) { // it is there } else {

Re: AWS API Dlang, hmac sha256 function.

2015-10-06 Thread holo via Digitalmars-d-learn
Congrats on getting it working! @Rikki Thanks :) I was trying to write my own lib from beginning based on examples but after some time i resign from that idea (will back to it when i will have some more experience) and right now im trying to customize that one from link which yawniek paste:

Re: AWS API Dlang, hmac sha256 function.

2015-10-06 Thread Rikki Cattermole via Digitalmars-d-learn
On 07/10/15 3:18 PM, holo wrote: Congrats on getting it working! @Rikki Thanks :) I was trying to write my own lib from beginning based on examples but after some time i resign from that idea (will back to it when i will have some more experience) and right now im trying to customize that one

Re: Bug? 0 is less than -10

2015-10-06 Thread Steven Schveighoffer via Digitalmars-d-learn
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 -Steve

Re: Varargs and default arguments

2015-10-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/6/15 4:27 PM, anonymous wrote: You can put an expression tuple ("expression AliasSeq"??) there. T.init is one that always fits T's types. But you could generate one with different values, too. void foo(T...)(string str=null, T args = T.init) { //... } void main() {

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

2015-10-06 Thread Marco Leise via Digitalmars-d-learn
Am Tue, 06 Oct 2015 21:39:28 + schrieb Fusxfaranto : > Additionally, just like associative arrays, if you need to access > the value, you can get a pointer to it with the in operator (and > if the key doesn't exist, it will return a null pointer). > >

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-06 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 05:38:36 UTC, Jonathan M Davis wrote: Your suggestion only works by assuming that the result will fit in a char, which doesn't fit at all with how coversions are currently done in D. It would allow for narrowing conversions which lost data. And there's no way that

Re: Bug? 0 is less than -10

2015-10-06 Thread Laeeth Isharc via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 14:55:23 UTC, Adam D. Ruppe wrote: On Tuesday, 6 October 2015 at 14:46:56 UTC, tcak wrote: void main(){ size_t dec = 0; How is it generating "true" for (dec <= -10) ? Is there a special casting or something? size_t is unsigned, so the -10 is cast to

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-06 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 09:28:29 UTC, Marc Schütz wrote: I see, this is a new problem introduced by `char + int = char`. But at least the following could be disallowed without introducing problems: int a = 'a'; char b = 32; But strictly speaking, we already accept overflow

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 06, 2015 09:28:27 Marc Schütz via Digitalmars-d-learn wrote: > I see, this is a new problem introduced by `char + int = char`. > But at least the following could be disallowed without > introducing problems: > > int a = 'a'; > char b = 32; Sure, it would be nice, but

Re: What is the postfix for min long value?

2015-10-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 06, 2015 15:16:12 tcak via Digitalmars-d-learn wrote: > While writing max ulong value, I added the "u" postfix. So > compiler accepted it as ulong value (That's my interpretation if > correct on compiler's side). > > writeln( 18_446_744_073_709_551_615u ); > > But when I try to

Re: Bug? 0 is less than -10

2015-10-06 Thread Meta via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 14:46:56 UTC, tcak wrote: Maybe I am just too stressed out to see the problem. [code] import std.stdio; void main(){ size_t dec = 0; writeln( dec, " ", (dec <= -10), " ", (dec >= 10), " ", ((dec <= -10) || (dec >= 10)) ); } [/code] [output] 0 true

Re: Linker error with dmd

2015-10-06 Thread Chris via Digitalmars-d-learn
On Friday, 2 October 2015 at 14:03:08 UTC, John Colvin wrote: On Friday, 2 October 2015 at 09:43:54 UTC, Chris wrote: Why do I get this error msg with dmd 2.067.1 and 2.068.0 in release mode: $ dub --build=release

Re: What is the postfix for min long value?

2015-10-06 Thread Ali Çehreli via Digitalmars-d-learn
On 10/06/2015 08:16 AM, tcak wrote: > While writing max ulong value, I added the "u" postfix. Better to use U to be consistent with L (see below). > But when I try to print out minimum value of long, compiler says > Error: signed integer overflow > > writeln( -9_223_372_036_854_775_808 ); I