print function

Marc Schütz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 5 02:47:14 PST 2016


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() unrolls its arguments too. Each string 
> argument to write() unrolls to a put(). And put("abc") unrolls 
> into put("a");put("b");put("c"), each of which that call the C 
> routine fwrite with a length 1.

No, (explicit) unrolling with foreach could only happen if 
there's either a variadic argument list, or if "abc" were a 
template argument. (In the latter case you'd need more than a 
simple foreach.) Of course, I don't know whether put() call 
fwrite() for every single character (these are written with 
single quotes, btw), but that wouldn't be unrolling strictu sensu.


More information about the Digitalmars-d-learn mailing list