site_probe.dhover×121all
// Which call-site tricks compile, and which resolve to the *caller's* location?
module 
(module) site_probe
site_probe
;
import
(package) std
std
.
(module) std.stdio
Category 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:

  1. The lowest layer is the operating system layer. The two main schemes are Windows and Posix.

  2. C's stdio.h which unifies the two operating system schemes.

  3. std.stdio, this module, unifies the various stdio.h implementations into a high level package for D programs.

Source

std/stdio.d

@copyrightCopyright The D Language Foundation 2007-.@licenseBoost License 1.0.@authorsWalter Bright, Andrei Alexandrescu, Alex Rønne Petersen
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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
;
struct
(struct) site_probe.Site
Site
{
(alias) object.string = string
string
(field) string site_probe.Site.file
file
;
(alias) object.size_t = ulong
size_t
(field) ulong site_probe.Site.line
line
;
(alias) object.size_t = ulong
size_t
(field) ulong site_probe.Site.col
col
; }
// P1: plain default args.
(struct) site_probe.Site
Site
site_probe.Site site_probe.p1(string file = __FILE__, ulong line = cast(ulong)__LINE__)
p1
(
(alias) object.string = string
string
(parameter) string file
file
= __FILE__,
(alias) object.size_t = ulong
size_t
(parameter) ulong line
line
= __LINE__) =>
(struct) site_probe.Site
Site
(
(parameter) string file
file
,
(parameter) ulong line
line
, 0);
// P2: special tokens nested in a default-argument expression.
(struct) site_probe.Site
Site
site_probe.Site site_probe.p2(site_probe.Site s = Site(__FILE__, cast(ulong)__LINE__, 0LU))
p2
(
(struct) site_probe.Site
Site
(parameter) site_probe.Site s
s
=
(struct) site_probe.Site
Site
(__FILE__, __LINE__, 0)) =>
(parameter) site_probe.Site s
s
;
// P3: default *template* alias argument holding a lambda; getLocation of it.
(struct) site_probe.Site
Site
site_probe.Site site_probe.p3!(function () pure nothrow @nogc @safe { } )() pure nothrow @nogc @safe
p3
(alias tag = () {})() {
enum
(constant) loc = __traits(getLocation, tag)
loc
= __traits(getLocation,
(unresolved type) tag
tag
);
return
(struct) site_probe.Site
Site
(loc[0], loc[1], loc[2]);
} // P4: explicit lambda passed as a `!` argument.
(struct) site_probe.Site
Site
site_probe.Site site_probe.p4!(function () pure nothrow @nogc @safe { } )() pure nothrow @nogc @safe
p4
(alias tag)() {
enum
(constant) loc = __traits(getLocation, tag)
loc
= __traits(getLocation,
(unresolved type) tag
tag
);
return
(struct) site_probe.Site
Site
(loc[0], loc[1], loc[2]);
} // P5: getLocation of a lambda inside a default (runtime) argument.
(struct) site_probe.Site
Site
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.Site
Site
(parameter) site_probe.Site s
s
= () { enum
(constant) loc = __traits(getLocation, __traits(parent, () { } ))
loc
= __traits(getLocation, __traits(parent, {})); return
(struct) site_probe.Site
Site
(loc[0], loc[1], loc[2]); }()) =>
(parameter) site_probe.Site s
s
;
// P6: default template value parameter.
(struct) site_probe.Site
Site
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 @safe
p6
(size_t line = __LINE__, string file = __FILE__)() =>
(struct) site_probe.Site
Site
(
(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 = 61LU
line
, 0);
// P7: __traits(getLocation, __traits(parent, {})) in the callee.
(struct) site_probe.Site
Site
site_probe.Site site_probe.p7()
p7
() {
enum loc = __traits(getLocation, __traits(parent, {})); return
(struct) site_probe.Site
Site
(loc[0], loc[1], loc[2]);
} // P8: __FUNCTION__ / __MODULE__ default args.
(alias) object.string = string
string
string site_probe.p8(string fn = __FUNCTION__, string mod = __MODULE__)
p8
(
(alias) object.string = string
string
(parameter) string fn
fn
= __FUNCTION__,
(alias) object.string = string
string
(parameter) string mod
mod
= __MODULE__) =>
(parameter) string mod
mod
~ " / " ~
(parameter) string fn
fn
;
// P9: struct static "here" factory with default args, used as a default argument. struct
(struct) site_probe.Here
Here
{
(alias) object.string = string
string
(field) string site_probe.Here.file
file
;
(alias) object.size_t = ulong
size_t
(field) ulong site_probe.Here.line
line
; static
(struct) site_probe.Here
Here
site_probe.Here site_probe.Here.make(string f = __FILE__, ulong l = cast(ulong)__LINE__)
make
(
(alias) object.string = string
string
(parameter) string f
f
= __FILE__,
(alias) object.size_t = ulong
size_t
(parameter) ulong l
l
= __LINE__) =>
(struct) site_probe.Here
Here
(
(parameter) string f
f
,
(parameter) ulong l
l
); }
(struct) site_probe.Here
Here
site_probe.Here site_probe.p9(site_probe.Here h = make(__FILE__, cast(ulong)__LINE__))
p9
(
(struct) site_probe.Here
Here
(parameter) site_probe.Here h
h
=
(struct) site_probe.Here
Here
.
site_probe.Here site_probe.Here.make(string f = __FILE__, ulong l = cast(ulong)__LINE__)
make
()) =>
(parameter) site_probe.Here h
h
;
// 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 tag
tag
) {
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 = string
string
(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) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
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) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
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 @safe
p3
()))
void std.stdio.writeln!(string, site_probe.Site)(string __param_0, site_probe.Site __param_1) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("P3 ",
site_probe.Site site_probe.p3!(function () pure nothrow @nogc @safe { } )() pure nothrow @nogc @safe
p3
()); else writeln("P3 does not compile");
void std.stdio.writeln!(string, site_probe.Site)(string __param_0, site_probe.Site __param_1) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("P4 ",
site_probe.Site site_probe.p4!(function () pure nothrow @nogc @safe { } )() pure nothrow @nogc @safe
p4
!(() {})());
void std.stdio.writeln!(string, site_probe.Site)(string __param_0, site_probe.Site __param_1) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("P4b ",
site_probe.Site site_probe.p4!(function () pure nothrow @nogc @safe { } )() pure nothrow @nogc @safe
p4
!({})());
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) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
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 @safe
p6
());
void std.stdio.writeln!(string, site_probe.Site)(string __param_0, site_probe.Site __param_1) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("P7 ",
site_probe.Site site_probe.p7()
p7
());
void std.stdio.writeln!(string, string)(string __param_0, string __param_1) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
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) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
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) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("P10 does not compile");
void std.stdio.writeln!(string, site_probe.Site)(string __param_0, site_probe.Site __param_1) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
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 @safe
p3
())) {
void std.stdio.writeln!(string, site_probe.Site, site_probe.Site)(string __param_0, site_probe.Site __param_1, site_probe.Site __param_2) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("P3 x2 ",
site_probe.Site site_probe.p3!(function () pure nothrow @nogc @safe { } )() pure nothrow @nogc @safe
p3
(),
site_probe.Site site_probe.p3!(function () pure nothrow @nogc @safe { } )() pure nothrow @nogc @safe
p3
()); }
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) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("P4 x2 ",
site_probe.Site site_probe.p4!(function () pure nothrow @nogc @safe { } )() pure nothrow @nogc @safe
p4
!({})(), " ",
site_probe.Site site_probe.p4!(function () pure nothrow @nogc @safe { } )() pure nothrow @nogc @safe
p4
!({})());
} // P12: column of a lambda written inside a string mixin at the call site. enum
(alias) object.string = string
string
(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) @safe

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);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("P12 ", mixin(siteHere), " ", mixin(siteHere)); }
static this() {
void site_probe.static this()
p12main
(); }