Re: print function

2016-02-05 Thread cy via Digitalmars-d-learn
On Friday, 5 February 2016 at 12:35:14 UTC, Artur Skawina wrote: D's std lib implementations are sometimes really awful, but in this case it's not actually that bad: print("hi","there"); -> fwrite("hi", 1, 2, 0x7ff68d0cb640) = 2 fwrite(" ", 1, 1,

Re: print function

2016-02-05 Thread Marc Schütz via Digitalmars-d-learn
On Friday, 5 February 2016 at 07:04:27 UTC, cy wrote: Mind if I elaborate on this a bit? If that is unrolled, I understand it will unroll into several calls to write, as in print("1","2","3") => write("1"," ");write("2"," ");write("3","\n"); Up to here, yes. And presumably, write()

Re: print function

2016-02-05 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 22:13:36 UTC, Ola Fosheim Grøstad wrote: Well, it is probably not the best point in time to have absolute beginners use D anyway. That is a ridiculous thing to say and a great way of ensuring a language dies. Good starting resources help everyone.

Re: print function

2016-02-05 Thread Artur Skawina via Digitalmars-d-learn
On 02/05/16 08:04, cy via Digitalmars-d-learn wrote: > On Thursday, 4 February 2016 at 15:32:48 UTC, Artur Skawina wrote: >>void print(A...)(A a) { >> foreach (N, ref e; a) >> write(e, N==A.length-1?"\n":" "); >>} > >>> will be unrolled at compile time > > Mind if I

Re: print function

2016-02-05 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Friday, 5 February 2016 at 12:35:14 UTC, Artur Skawina wrote: call used to print diagnostics. What I saw made me never use or look at D's std lib again. Except for meta programing and toy/example programs where it doesn't matter. What do you use instead? A buffer and Posix write() and

Re: print function

2016-02-05 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Friday, 5 February 2016 at 07:04:27 UTC, cy wrote: tl;dr speed demons use std.stream.InputStream.read() whenever you can, and std.stream.OutputStream.write() its result. Isn't std.stream deprecated?

Re: print function

2016-02-05 Thread Artur Skawina via Digitalmars-d-learn
On 02/05/16 14:38, Ola Fosheim Grøstad via Digitalmars-d-learn wrote: > On Friday, 5 February 2016 at 12:35:14 UTC, Artur Skawina wrote: >> call used to print diagnostics. What I saw made me never use or look at D's >> std lib again. Except for meta programing and toy/example programs where it

Re: print function

2016-02-04 Thread cym13 via Digitalmars-d-learn
On Thursday, 4 February 2016 at 10:18:35 UTC, ixid wrote: Do you think your knowledge and experience is a good model for how a new user who hasn't done much if any programming before would approach this? A design choice had to be made and made it was. Adding another function now (or worse,

Re: print function

2016-02-04 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Thursday, 4 February 2016 at 10:59:50 UTC, Mike Parker wrote: IMO, while giving beginner's a helping hand is a great thing, I don't think it's a good basis to use as a design for a standard library. Yes, better to have a "beginners toolkit" starting-point-codebase and build a tutorial

Re: print function

2016-02-04 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 11:04:23 UTC, cym13 wrote: On Thursday, 4 February 2016 at 10:18:35 UTC, ixid wrote: Do you think your knowledge and experience is a good model for how a new user who hasn't done much if any programming before would approach this? A design choice had to be

Re: print function

2016-02-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 04, 2016 00:40:55 ixid via Digitalmars-d-learn wrote: > On Thursday, 4 February 2016 at 00:30:03 UTC, cym13 wrote: > > On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: > >> It would be nice to have a simple writeln that adds spaces > >> automatically like Python's

Re: print function

2016-02-04 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 4 February 2016 at 10:18:35 UTC, ixid wrote: On Thursday, 4 February 2016 at 10:05:15 UTC, Jonathan M Davis wrote: I would normally expect someone to do that with writefln, which would be cleaner. e.g. writefln("%s %s %s %s", a, b, c, d); Personally, I've never felt the need for

Re: print function

2016-02-04 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 10:05:15 UTC, Jonathan M Davis wrote: I would normally expect someone to do that with writefln, which would be cleaner. e.g. writefln("%s %s %s %s", a, b, c, d); Personally, I've never felt the need for a function like you're describing. - Jonathan M Davis

Re: print function

2016-02-04 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Thursday, 4 February 2016 at 14:25:21 UTC, bachmeier wrote: Unfortunately there is no such thing and it is unlikely to exist in the next decade. Well, it is probably not the best point in time to have absolute beginners use D anyway. But a well commented library, that don't focus on

Re: print function

2016-02-04 Thread cy via Digitalmars-d-learn
On Thursday, 4 February 2016 at 15:32:48 UTC, Artur Skawina wrote: void print(A...)(A a) { foreach (N, ref e; a) write(e, N==A.length-1?"\n":" "); } will be unrolled at compile time Mind if I elaborate on this a bit? If that is unrolled, I understand it will unroll

Re: print function

2016-02-04 Thread bachmeier via Digitalmars-d-learn
On Thursday, 4 February 2016 at 11:04:15 UTC, Ola Fosheim Grøstad wrote: On Thursday, 4 February 2016 at 10:59:50 UTC, Mike Parker wrote: IMO, while giving beginner's a helping hand is a great thing, I don't think it's a good basis to use as a design for a standard library. Yes, better to

Re: print function

2016-02-04 Thread Kagamin via Digitalmars-d-learn
On Thursday, 4 February 2016 at 14:25:21 UTC, bachmeier wrote: Unfortunately there is no such thing and it is unlikely to exist in the next decade. There is http://forum.dlang.org/post/mtsd38$16ub$1...@digitalmars.com

Re: print function

2016-02-04 Thread Dejan Lekic via Digitalmars-d-learn
On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: It would be nice to have a simple writeln that adds spaces automatically like Python's 'print' in std.stdio, perhaps called print. There are many implementations of string interpolation in D (that is what you want, basically). One of

Re: print function

2016-02-04 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 13:46:46 UTC, Dejan Lekic wrote: On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: It would be nice to have a simple writeln that adds spaces automatically like Python's 'print' in std.stdio, perhaps called print. There are many implementations of

Re: print function

2016-02-04 Thread Artur Skawina via Digitalmars-d-learn
On 02/04/16 15:02, ixid via Digitalmars-d-learn wrote: > On Thursday, 4 February 2016 at 13:46:46 UTC, Dejan Lekic wrote: >> On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: >>> It would be nice to have a simple writeln that adds spaces automatically >>> like Python's 'print' in

Re: print function

2016-02-04 Thread bachmeier via Digitalmars-d-learn
On Thursday, 4 February 2016 at 15:10:18 UTC, Kagamin wrote: On Thursday, 4 February 2016 at 14:25:21 UTC, bachmeier wrote: Unfortunately there is no such thing and it is unlikely to exist in the next decade. There is http://forum.dlang.org/post/mtsd38$16ub$1...@digitalmars.com The

Re: print function

2016-02-04 Thread sigod via Digitalmars-d-learn
On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: It would be nice to have a simple writeln that adds spaces automatically like Python's 'print' in std.stdio, perhaps called print. It seems Andrei decided to add such function:

Re: print function

2016-02-04 Thread Artur Skawina via Digitalmars-d-learn
On 02/04/16 16:32, Artur Skawina wrote: > >void print(A...)(A a) { > foreach (N, ref e; a) > write(e, N==A.length-1?"\n":" "); >} BTW, that was *deliberately* written that way as a compromise between efficiency and template bloat. It can of course be done like void

Re: print function

2016-02-04 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 17:34:33 UTC, Artur Skawina wrote: On 02/04/16 16:32, Artur Skawina wrote: but that seems too expensive, when the use is just in toy programs and debugging. I hadn't really considered the relative cost-benefit, it's just a habit to try to hardcode things at

Re: print function

2016-02-04 Thread Artur Skawina via Digitalmars-d-learn
On 02/04/16 18:53, ixid via Digitalmars-d-learn wrote: > On Thursday, 4 February 2016 at 17:34:33 UTC, Artur Skawina wrote: >> On 02/04/16 16:32, Artur Skawina wrote: >> but that seems too expensive, when the use is just in toy programs and >> debugging. > > I hadn't really considered the

Re: print function

2016-02-03 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 00:30:03 UTC, cym13 wrote: On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: It would be nice to have a simple writeln that adds spaces automatically like Python's 'print' in std.stdio, perhaps called print. Sounds way too redundant to me. Normally

Re: print function

2016-02-03 Thread cym13 via Digitalmars-d-learn
On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: It would be nice to have a simple writeln that adds spaces automatically like Python's 'print' in std.stdio, perhaps called print. Sounds way too redundant to me.

Re: print function

2016-02-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 04, 2016 00:23:07 ixid via Digitalmars-d-learn wrote: > It would be nice to have a simple writeln that adds spaces > automatically like Python's 'print' in std.stdio, perhaps called > print. If that's what you're looking for, I expect that most of us would think that it's