digitalmars.D.learn - getChar() vs. getChar!true()
- Peter Sommerfeld (7/7) Mar 20 2013 In std.json is a function getchar() with this signature:
- cal (6/8) Mar 20 2013 It looks like the signature (line 115) is:
- Peter Sommerfeld (3/11) Mar 20 2013 Thanks, I must look more carefully...
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (9/15) Mar 20 2013 No, in that case SkipWhitespace==true.
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (4/6) Mar 20 2013 I said "No" but kept your value. :) I meant "No, in that case
- Peter Sommerfeld (7/11) Mar 20 2013 nd =
In std.json is a function getchar() with this signature: dchar getChar(bool SkipWhitespace = false); But it is called differently: getChar(); // obviously SkipWhitespace = true; getChar!true(); // probably getchar(true) What is the reason for the different notation ? Peter
Mar 20 2013
On Wednesday, 20 March 2013 at 20:11:47 UTC, Peter Sommerfeld wrote:In std.json is a function getchar() with this signature: dchar getChar(bool SkipWhitespace = false);It looks like the signature (line 115) is: dchar getChar(bool SkipWhitespace = false)() Note the extra set of parens at the end, making the bool a template parameter.
Mar 20 2013
cal wrote:On Wednesday, 20 March 2013 at 20:11:47 UTC, Peter Sommerfeld wrote:Thanks, I must look more carefully... PeterIn std.json is a function getchar() with this signature: dchar getChar(bool SkipWhitespace = false);It looks like the signature (line 115) is: dchar getChar(bool SkipWhitespace = false)() Note the extra set of parens at the end, making the bool a template parameter.
Mar 20 2013
On 03/20/2013 01:11 PM, Peter Sommerfeld wrote:In std.json is a function getchar() with this signature: dchar getChar(bool SkipWhitespace = false);That 'false' up there is the default value of SkipWhitespace.But it is called differently: getChar(); // obviously SkipWhitespace = true;No, in that case SkipWhitespace==true.getChar!true(); // probably getchar(true) What is the reason for the different notation ?The same thing; just being explicit. Aside: bool parameters (regular or template) hurt readability. It would be better to have defined a type similar to std.stdio.KeepTerminator and its use with byLine(): Ali
Mar 20 2013
On 03/20/2013 01:27 PM, Ali Çehreli wrote:> getChar(); // obviously SkipWhitespace = true; No, in that case SkipWhitespace==true.I said "No" but kept your value. :) I meant "No, in that case SkipWhiteSpace==false." Ali
Mar 20 2013
Ali =C7ehreli:Aside: bool parameters (regular or template) hurt readability. It woul=d =be better to have defined a type similar to std.stdio.KeepTerminator a=nd =its use with byLine():I see. On the other hand: For an internal function like getChar()() the implementation seem so be a bit to intricate. But for a public API certainly preferable. Peter
Mar 20 2013