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
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. :)
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
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
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
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.
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
--compiler
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
I find now flag to rdmd for choosing a specific dmd. Is there
none?
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
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
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); ?
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
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"
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)
{
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???+/)
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
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) {}
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 {
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:
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
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
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()
{
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).
>
>
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
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
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
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
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
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
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
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
33 matches
Mail list logo