// Which call-site tricks compile, and which resolve to the *caller's* location?
module (module) site_probesite_probe;
import (package) stdstd.(module) std.stdioCategory Symbols File handles _popen File isFileHandle openNetwork stderr stdin stdout Reading chunks lines readf readfln readln Writing toFile write writef writefln writeln Misc KeepTerminator LockType StdioException
Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio
is publically imported when importing std.stdio.
There are three layers of I/O:
The lowest layer is the operating system layer. The two main schemes are Windows and Posix.
C's stdio.h which unifies the two operating system schemes.
std.stdio, this module, unifies the various stdio.h implementations into
a high level package for D programs.
Source
std/stdio.d
stdio : (alias template) site_probe.writeln = std.stdio.writeln(T...)(T args)Equivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln;
struct (struct) site_probe.SiteSite { (alias) object.string = stringstring (field) string site_probe.Site.filefile; (alias) object.size_t = ulongsize_t (field) ulong site_probe.Site.lineline; (alias) object.size_t = ulongsize_t (field) ulong site_probe.Site.colcol; }
// P1: plain default args.
(struct) site_probe.SiteSite site_probe.Site site_probe.p1(string file = __FILE__, ulong line = cast(ulong)__LINE__)p1((alias) object.string = stringstring (parameter) string filefile = __FILE__, (alias) object.size_t = ulongsize_t (parameter) ulong lineline = __LINE__) => (struct) site_probe.SiteSite((parameter) string filefile, (parameter) ulong lineline, 0);
// P2: special tokens nested in a default-argument expression.
(struct) site_probe.SiteSite site_probe.Site site_probe.p2(site_probe.Site s = Site(__FILE__, cast(ulong)__LINE__, 0LU))p2((struct) site_probe.SiteSite (parameter) site_probe.Site ss = (struct) site_probe.SiteSite(__FILE__, __LINE__, 0)) => (parameter) site_probe.Site ss;
// P3: default *template* alias argument holding a lambda; getLocation of it.
(struct) site_probe.SiteSite site_probe.Site site_probe.p3!(function () pure nothrow @nogc @safe
{
}
)() pure nothrow @nogc @safep3(alias tag = () {})() {
enum (constant) loc = __traits(getLocation, tag)loc = __traits(getLocation, (unresolved type) tagtag);
return (struct) site_probe.SiteSite(loc[0], loc[1], loc[2]);
}
// P4: explicit lambda passed as a `!` argument.
(struct) site_probe.SiteSite site_probe.Site site_probe.p4!(function () pure nothrow @nogc @safe
{
}
)() pure nothrow @nogc @safep4(alias tag)() {
enum (constant) loc = __traits(getLocation, tag)loc = __traits(getLocation, (unresolved type) tagtag);
return (struct) site_probe.SiteSite(loc[0], loc[1], loc[2]);
}
// P5: getLocation of a lambda inside a default (runtime) argument.
(struct) site_probe.SiteSite site_probe.Site site_probe.p5(site_probe.Site s = (*function () pure nothrow @nogc @safe => Site("/home/runner/work/sparkles/sparkles/docs/research/ui-authoring/experiments/ui-api-demo-scoped/probes/site_probe.d", 26LU, 18LU))())p5((struct) site_probe.SiteSite (parameter) site_probe.Site ss = () { enum (constant) loc = __traits(getLocation, __traits(parent, ()
{
}
))loc = __traits(getLocation, __traits(parent, {})); return (struct) site_probe.SiteSite(loc[0], loc[1], loc[2]); }()) => (parameter) site_probe.Site ss;
// P6: default template value parameter.
(struct) site_probe.SiteSite site_probe.Site site_probe.p6!(61LU, "/home/runner/work/sparkles/sparkles/docs/research/ui-authoring/experiments/ui-api-demo-scoped/probes/site_probe.d")() pure nothrow @nogc @safep6(size_t line = __LINE__, string file = __FILE__)() => (struct) site_probe.SiteSite((constant) string site_probe.file = "/home/runner/work/sparkles/sparkles/docs/research/ui-authoring/experiments/ui-api-demo-scoped/probes/site_probe.d"file, (constant) ulong site_probe.line = 61LUline, 0);
// P7: __traits(getLocation, __traits(parent, {})) in the callee.
(struct) site_probe.SiteSite site_probe.Site site_probe.p7()p7() {
enum loc = __traits(getLocation, __traits(parent, {}));
return (struct) site_probe.SiteSite(loc[0], loc[1], loc[2]);
}
// P8: __FUNCTION__ / __MODULE__ default args.
(alias) object.string = stringstring string site_probe.p8(string fn = __FUNCTION__, string mod = __MODULE__)p8((alias) object.string = stringstring (parameter) string fnfn = __FUNCTION__, (alias) object.string = stringstring (parameter) string modmod = __MODULE__) => (parameter) string modmod ~ " / " ~ (parameter) string fnfn;
// P9: struct static "here" factory with default args, used as a default argument.
struct (struct) site_probe.HereHere { (alias) object.string = stringstring (field) string site_probe.Here.filefile; (alias) object.size_t = ulongsize_t (field) ulong site_probe.Here.lineline; static (struct) site_probe.HereHere site_probe.Here site_probe.Here.make(string f = __FILE__, ulong l = cast(ulong)__LINE__)make((alias) object.string = stringstring (parameter) string ff = __FILE__, (alias) object.size_t = ulongsize_t (parameter) ulong ll = __LINE__) => (struct) site_probe.HereHere((parameter) string ff, (parameter) ulong ll); }
(struct) site_probe.HereHere site_probe.Here site_probe.p9(site_probe.Here h = make(__FILE__, cast(ulong)__LINE__))p9((struct) site_probe.HereHere (parameter) site_probe.Here hh = (struct) site_probe.HereHere.site_probe.Here site_probe.Here.make(string f = __FILE__, ulong l = cast(ulong)__LINE__)make()) => (parameter) site_probe.Here hh;
// P10: getLocation on a lambda declared at the call site as a *runtime* argument.
Site Site p10(T)(T tag)p10(T)(T (parameter) T tagtag) {
enum (constant) loc = __traits(getLocation, T)loc = __traits(getLocation, T); // a lambda's type is a function/delegate type, not a symbol
return Site(loc[0], loc[1], loc[2]);
}
// P11: alias template arg + IFTI of a local struct type declared in a mixin
// (mixin-template site): `mixin(site)` string.
enum (alias) object.string = stringstring (constant) string site_probe.here = "Site(__traits(getLocation, __traits(parent, {}))[0], __LINE__, 0)"here = q{Site(__traits(getLocation, __traits(parent, {}))[0], __LINE__, 0)};
void void D main()main()
{
void std.stdio.writeln!(string, site_probe.Site)(string __param_0, site_probe.Site __param_1) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P1 ", site_probe.Site site_probe.p1(string file = __FILE__, ulong line = cast(ulong)__LINE__)p1()); // line 54
void std.stdio.writeln!(string, site_probe.Site)(string __param_0, site_probe.Site __param_1) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P2 ", site_probe.Site site_probe.p2(site_probe.Site s = Site(__FILE__, cast(ulong)__LINE__, 0LU))p2()); // line 55
static if (__traits(compiles, site_probe.Site site_probe.p3!(function () pure nothrow @nogc @safe
{
}
)() pure nothrow @nogc @safep3())) void std.stdio.writeln!(string, site_probe.Site)(string __param_0, site_probe.Site __param_1) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P3 ", site_probe.Site site_probe.p3!(function () pure nothrow @nogc @safe
{
}
)() pure nothrow @nogc @safep3()); else writeln("P3 does not compile");
void std.stdio.writeln!(string, site_probe.Site)(string __param_0, site_probe.Site __param_1) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P4 ", site_probe.Site site_probe.p4!(function () pure nothrow @nogc @safe
{
}
)() pure nothrow @nogc @safep4!(() {})()); void std.stdio.writeln!(string, site_probe.Site)(string __param_0, site_probe.Site __param_1) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P4b ", site_probe.Site site_probe.p4!(function () pure nothrow @nogc @safe
{
}
)() pure nothrow @nogc @safep4!({})());
static if (__traits(compiles, site_probe.Site site_probe.p5(site_probe.Site s = (*function () pure nothrow @nogc @safe => Site("/home/runner/work/sparkles/sparkles/docs/research/ui-authoring/experiments/ui-api-demo-scoped/probes/site_probe.d", 26LU, 18LU))())p5())) writeln("P5 ", p5());
void std.stdio.writeln!(string, site_probe.Site)(string __param_0, site_probe.Site __param_1) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P6 ", site_probe.Site site_probe.p6!(61LU, "/home/runner/work/sparkles/sparkles/docs/research/ui-authoring/experiments/ui-api-demo-scoped/probes/site_probe.d")() pure nothrow @nogc @safep6());
void std.stdio.writeln!(string, site_probe.Site)(string __param_0, site_probe.Site __param_1) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P7 ", site_probe.Site site_probe.p7()p7());
void std.stdio.writeln!(string, string)(string __param_0, string __param_1) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P8 ", string site_probe.p8(string fn = __FUNCTION__, string mod = __MODULE__)p8());
void std.stdio.writeln!(string, site_probe.Here)(string __param_0, site_probe.Here __param_1) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P9 ", site_probe.Here site_probe.p9(site_probe.Here h = make(__FILE__, cast(ulong)__LINE__))p9());
static if (__traits(compiles, (template function) site_probe.p10(T)(T tag)p10(() {}))) writeln("P10 ", p10(() {})); else void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P10 does not compile");
void std.stdio.writeln!(string, site_probe.Site)(string __param_0, site_probe.Site __param_1) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P11 ", mixin(here));
// two P3 calls on one line: distinct?
static if (__traits(compiles, site_probe.Site site_probe.p3!(function () pure nothrow @nogc @safe
{
}
)() pure nothrow @nogc @safep3())) { void std.stdio.writeln!(string, site_probe.Site, site_probe.Site)(string __param_0, site_probe.Site __param_1, site_probe.Site __param_2) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P3 x2 ", site_probe.Site site_probe.p3!(function () pure nothrow @nogc @safe
{
}
)() pure nothrow @nogc @safep3(), site_probe.Site site_probe.p3!(function () pure nothrow @nogc @safe
{
}
)() pure nothrow @nogc @safep3()); }
void std.stdio.writeln!(string, site_probe.Site, string, site_probe.Site)(string __param_0, site_probe.Site __param_1, string __param_2, site_probe.Site __param_3) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P4 x2 ", site_probe.Site site_probe.p4!(function () pure nothrow @nogc @safe
{
}
)() pure nothrow @nogc @safep4!({})(), " ", site_probe.Site site_probe.p4!(function () pure nothrow @nogc @safe
{
}
)() pure nothrow @nogc @safep4!({})());
}
// P12: column of a lambda written inside a string mixin at the call site.
enum (alias) object.string = stringstring (constant) string site_probe.siteHere = "(){ enum l = __traits(getLocation, __traits(parent, {})); return Site(l[0], l[1], l[2]); }()"siteHere = q{(){ enum l = __traits(getLocation, __traits(parent, {})); return Site(l[0], l[1], l[2]); }()};
void void site_probe.p12main()p12main() { void std.stdio.writeln!(string, site_probe.Site, string, site_probe.Site)(string __param_0, site_probe.Site __param_1, string __param_2, site_probe.Site __param_3) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("P12 ", mixin(siteHere), " ", mixin(siteHere)); }
static this() { void site_probe.static this()p12main(); }