Hello world/Standard error: Difference between revisions

(→‎dt: add)
 
(6 intermediate revisions by 6 users not shown)
Line 503:
 
=={{header|J}}==
<syntaxhighlight lang="j">stderr =: 1!:2&4 stderr
1!:2&5
stderr 'Goodbye, World!'</syntaxhighlight>
 
0 0 $ stderr 'Goodbye, World!'</syntaxhighlight>
 
=={{header|Java}}==
Line 533 ⟶ 535:
 
=={{header|Julia}}==
 
Julia 0.7 or newer:
 
<syntaxhighlight lang="julia">println(stderr, "Goodbye, World!")</syntaxhighlight>
 
In versions prior to Julia 0.7, the standard I/O streams were capitalized:
 
<syntaxhighlight lang="julia">println(STDERR, "Goodbye, World!")</syntaxhighlight>
 
Line 544 ⟶ 553:
 
=={{header|langur}}==
<syntaxhighlight lang="langur">writelnErr "goodbyeGoodbye, peopleworld."</syntaxhighlight>
 
=={{header|Lasso}}==
Line 572 ⟶ 581:
sx.shell_cmd("logger Goodbye, World!")</syntaxhighlight>
 
=={{header|Lean}}==
In lean4
<syntaxhighlight lang="lean4">
def main : IO Unit := do
let stderr ← IO.getStderr
stderr.putStrLn s!"Goodbye, World!"
</syntaxhighlight>
=={{header|LLVM}}==
<syntaxhighlight lang="llvm">; This is not strictly LLVM, as it uses the C library function "printf".
Line 737 ⟶ 753:
=={{header|Nim}}==
<syntaxhighlight lang="nim">stderr.writeLine "Hello World"</syntaxhighlight>
 
=={{header|Nu}}==
<syntaxhighlight lang="nu">
print -e "Goodbye, World!"
</syntaxhighlight>
 
=={{header|Oberon-2}}==
Line 1,226 ⟶ 1,247:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">Fiber.abort("Goodbye, World!")</syntaxhighlight>
 
=={{header|X86 Assembly}}==
Line 1,274 ⟶ 1,295:
 
=={{header|Zig}}==
'''Works with:''' 0.10.x, 0.11.x, 0.12.0-dev.1357+10d03acdb
 
Variant with error handling:
<syntaxhighlight lang="zig">const std = @import("std");
 
pub fn main() !void {
pub fn main() std.fs.File.WriteError!void {
try std.io.getStdErr().writer().writeAll("Goodbye, World!\n");
const stderr = std.io.getStdErr();
// debug messages are also printed to stderr
 
//std.debug.print("Goodbye, World!\n");
try std.io.getStdErr().writer()stderr.writeAll("Goodbye, World!\n");
}</syntaxhighlight>
'''Works with:''' 0.10.x, 0.11.x, 0.12.0-dev.1357+10d03acdb
 
Variant with no error handling (useful when debugging):
<syntaxhighlight lang="zig">const std = @import("std");
 
pub fn main() !void {
// Silently returns if writing to stderr fails.
//std.debug.print("Goodbye, World!\n", .{});
}</syntaxhighlight>
 
885

edits