www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Following up from the reddit announcement

reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
What's the matter with http://dpaste.dzfl.pl/ebd6ba43823f?

Andrei
Feb 24 2014
next sibling parent "safety0ff" <safety0ff.dev gmail.com> writes:
On Monday, 24 February 2014 at 22:05:46 UTC, Andrei Alexandrescu 
wrote:
 What's the matter with http://dpaste.dzfl.pl/ebd6ba43823f?

 Andrei
readf is returning 0 (the number of variables filled); it's not changing the variable "input".
Feb 24 2014
prev sibling next sibling parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Mon, 24 Feb 2014 17:05:46 -0500, Andrei Alexandrescu  
<SeeWebsiteForEmail erdani.org> wrote:

 What's the matter with http://dpaste.dzfl.pl/ebd6ba43823f?
This is what happens when you close input (i.e. hit ctrl-d from a console), without entering -1. readf is returning 0 meaning "I didn't get anything" and the code is ignoring it. I changed it to: if(readf("%s\n", &input) == 0) break; And it works fine. Note I had to add \n to the readf to use a one-number-per-line style (didn't make sense otherwise). -Steve
Feb 24 2014
next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Steven Schveighoffer:

 And it works fine. Note I had to add \n to the readf to use a 
 one-number-per-line style (didn't make sense otherwise).
Also the code throws if just hit enter (it means you enter no number). So the code is still bad. Also using sort instead of sort() is an anti-pattern that's going to be deprecated, hopefully in D 2.066. Bye, bearophile
Feb 24 2014
parent "bearophile" <bearophileHUGS lycos.com> writes:
 Also the code throws if just hit enter (it means you enter no 
 number). So the code is still bad.
I prefer code like this: void main() { import std.stdio, std.algorithm, std.string, std.array, std.conv; int[] even, odd; while (true) { "Enter a number (or just enter to exit): ".write; immutable txt = readln.strip; if (txt.empty) break; try { immutable input = txt.to!int; if (input % 2 == 0) { "even".writeln; even ~= input; } else { "odd".writeln; odd ~= input; } } catch (ConvException e) { "Not a number.".writeln; continue; } } odd.sort().writeln; even.sort().writeln; }
Feb 24 2014
prev sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 02/24/2014 02:15 PM, Steven Schveighoffer wrote:

 if(readf("%s\n", &input) == 0)
              break;

 And it works fine. Note I had to add \n to the readf to use a
 one-number-per-line style (didn't make sense otherwise).
I always put a space before the format specifier to ignore all whitespace: if (readf(" %s", &input) == 0) Ali
Feb 24 2014
prev sibling next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Andrei Alexandrescu:

 What's the matter with http://dpaste.dzfl.pl/ebd6ba43823f?
There are some problems there, this seems better: readf("%d\n", &input); Additionally readf() has a bug on Windows that I reported and it's still open in Bugzilla. (Extra note: I have a large D2 codebase, but I am strongly against freezing D2 development even more at this stage.) Bye, bearophile
Feb 24 2014
prev sibling next sibling parent reply Shammah Chancellor <anonymous coward.com> writes:
On 2014-02-24 22:05:46 +0000, Andrei Alexandrescu said:

 What's the matter with http://dpaste.dzfl.pl/ebd6ba43823f?
 
 Andrei
Not sure what this is about, but when can we expect dlint? -S.
Feb 24 2014
next sibling parent "Brian Schott" <briancschott gmail.com> writes:
On Tuesday, 25 February 2014 at 03:25:09 UTC, Shammah Chancellor 
wrote:
 Not sure what this is about, but when can we expect dlint?

 -S.
https://github.com/Hackerpilot/Dscanner#style-check
Feb 24 2014
prev sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 2/24/14, 7:25 PM, Shammah Chancellor wrote:
 On 2014-02-24 22:05:46 +0000, Andrei Alexandrescu said:

 What's the matter with http://dpaste.dzfl.pl/ebd6ba43823f?

 Andrei
Not sure what this is about, but when can we expect dlint?
After std.lexer. I'm hoping us to also develop a "perfectpull" utility that ensures a pull request is phobos-compatible at nitpick level. Andrei
Feb 25 2014
prev sibling parent reply "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Monday, 24 February 2014 at 22:05:46 UTC, Andrei Alexandrescu 
wrote:
 What's the matter with http://dpaste.dzfl.pl/ebd6ba43823f?

 Andrei
The exception is fairly clear: Unexpected ' ' when converting from type LockingTextReader to type int Though maybe: Unexpected '\n' when converting from type LockingTextReader to type int would be better.
Feb 24 2014
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Jesse Phillips:

 Unexpected '
 ' when converting from type LockingTextReader to type int

 Though maybe:

 Unexpected '\n' when converting from type LockingTextReader to 
 type int

 would be better.
This little problem should go in Bugzilla. Bye, bearophile
Feb 25 2014
parent "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Tuesday, 25 February 2014 at 10:26:09 UTC, bearophile wrote:
 Jesse Phillips:

 Unexpected '
 ' when converting from type LockingTextReader to type int

 Though maybe:

 Unexpected '\n' when converting from type LockingTextReader to 
 type int

 would be better.
This little problem should go in Bugzilla. Bye, bearophile
Done: https://d.puremagic.com/issues/show_bug.cgi?id=12260
Feb 25 2014