Re: How to create a function that behaves like std.stdio.writeln but prepends output with __FILE__:_LINE_

2022-01-25 Thread JG via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 12:27:16 UTC, Dennis wrote: On Tuesday, 25 January 2022 at 12:11:01 UTC, JG wrote: Any ideas how one can achieve what is written in the subject line? ```D void f(T...)(auto ref T args, string file = __FILE__, int line = __LINE__) { writeln(file, ":", line,

Re: How to create a function that behaves like std.stdio.writeln but prepends output with __FILE__:_LINE_

2022-01-25 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 12:27:16 UTC, Dennis wrote: On Tuesday, 25 January 2022 at 12:11:01 UTC, JG wrote: Any ideas how one can achieve what is written in the subject line? ```D void f(T...)(auto ref T args, string file = __FILE__, int line = __LINE__) { writeln(file, ":", line,

Re: How to create a function that behaves like std.stdio.writeln but prepends output with __FILE__:_LINE_

2022-01-25 Thread Dennis via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 12:11:01 UTC, JG wrote: Any ideas how one can achieve what is written in the subject line? ```D void f(T...)(auto ref T args, string file = __FILE__, int line = __LINE__) { writeln(file, ":", line, ": ", args); } ```

How to create a function that behaves like std.stdio.writeln but prepends output with __FILE__:_LINE_

2022-01-25 Thread JG via Digitalmars-d-learn
Any ideas how one can achieve what is written in the subject line? f below does achieve this but I one would expect that it produces significant template bloat. g achieves the aim but isn't very elegant. import std; void f(string file=__FILE__,size_t line=__LINE__,R...)(R r) {

Re: std.stdio.writeln

2015-03-10 Thread ketmar via Digitalmars-d-learn
On Tue, 10 Mar 2015 01:31:39 -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > it's the sort of thing that could easily be decided and then not > actually happen for ages (e.g. it was decided years ago that delete > would be deprecated, but it still isn't). sometimes i'm irritated by this,

Re: std.stdio.writeln

2015-03-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 09, 2015 22:29:23 Meta via Digitalmars-d-learn wrote: > On Monday, 9 March 2015 at 22:00:46 UTC, ketmar wrote: > > i remember that deprecation was rejected. maybe this is false > > memory, > > though. > > > > btw, there are legit uses of comma, in c-style `for`, for > > example. th

Re: std.stdio.writeln

2015-03-09 Thread Meta via Digitalmars-d-learn
On Monday, 9 March 2015 at 22:00:46 UTC, ketmar wrote: i remember that deprecation was rejected. maybe this is false memory, though. btw, there are legit uses of comma, in c-style `for`, for example. this should be left intact, i think (oh, can c-style `for` be deprecated too?! ). I think

Re: std.stdio.writeln

2015-03-09 Thread ketmar via Digitalmars-d-learn
On Mon, 09 Mar 2015 13:18:58 -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > On Monday, March 09, 2015 15:45:58 ketmar via Digitalmars-d-learn wrote: >> On Mon, 09 Mar 2015 14:48:19 +, John Colvin wrote: >> >> > Yet another excellent example of why we should abolish the comma >> > ope

Re: std.stdio.writeln

2015-03-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 09, 2015 15:45:58 ketmar via Digitalmars-d-learn wrote: > On Mon, 09 Mar 2015 14:48:19 +, John Colvin wrote: > > > Yet another excellent example of why we should abolish the comma > > operator in D. > > or at least warn about it. producing a warning for such expression will > r

Re: std.stdio.writeln

2015-03-09 Thread ketmar via Digitalmars-d-learn
On Mon, 09 Mar 2015 14:48:19 +, John Colvin wrote: > Yet another excellent example of why we should abolish the comma > operator in D. or at least warn about it. producing a warning for such expression will ring a bell in programmers head: "compiler is unhappy. i definitely doing something

Re: std.stdio.writeln

2015-03-09 Thread Dennis Ritchie via Digitalmars-d-learn
On Monday, 9 March 2015 at 14:42:35 UTC, Adam D. Ruppe wrote: On Monday, 9 March 2015 at 14:38:41 UTC, Dennis Ritchie wrote: (1, 2, 3).writeln; // prints 3 that's not an array, use [1,2,3] for that. What you wrote is a parenthesis expression with comma expressions inside. The co

Re: std.stdio.writeln

2015-03-09 Thread John Colvin via Digitalmars-d-learn
On Monday, 9 March 2015 at 14:38:41 UTC, Dennis Ritchie wrote: Hi. Why prints only the last element? import std.stdio; void main() { (1, 2, 3).writeln; // prints 3 } I think this is a misunderstanding about UFCS. 1.writeln(2, 3); is the same as writeln(1, 2, 3); and the same

std.stdio.writeln

2015-03-09 Thread Dennis Ritchie via Digitalmars-d-learn
Hi. Why prints only the last element? import std.stdio; void main() { (1, 2, 3).writeln; // prints 3 }

Re: std.stdio.writeln

2015-03-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 9 March 2015 at 14:38:41 UTC, Dennis Ritchie wrote: (1, 2, 3).writeln; // prints 3 that's not an array, use [1,2,3] for that. What you wrote is a parenthesis expression with comma expressions inside. The comma operator is a bit weird: it works like a semicolon, but in