Halt and catch fire: Difference between revisions

Added Easylang
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
(Added Easylang)
 
(15 intermediate revisions by 9 users not shown)
Line 101:
</pre>
 
=={{header|CBinary Lambda Calculus}}==
BLC forces normal programs to start with a closed lambda term, by mapping free variables to the divergent Omega = <code>(\x.x x)(\x.x x)</code>, the lambda calculus equivalent of an infinite loop. That makes the following 2-bit BLC program the smallest to catch fire:
<syntaxhighlight lang="c">int main(){int a=0, b=0, c=a/b;}</syntaxhighlight>
 
<pre>10</pre>
 
=={{header|BQN}}==
Line 110 ⟶ 112:
 
Other runtime errors are possible, but not as easy to use.
 
=={{header|Bruijn}}==
Bruijn does not have runtime errors. For debugging you can either write tests (which are run before evaluating main) or use tactical infinite loops:
<syntaxhighlight lang="bruijn">
:test ([[0]]) ([[1]])
 
main [[0 0] [0 0]]
</syntaxhighlight>
 
=={{header|C}}==
<syntaxhighlight lang="c">int main(){int a=0, b=0, c=a/b;}</syntaxhighlight>
 
=={{header|C++}}==
Line 138 ⟶ 151:
=={{header|Crystal}}==
<syntaxhighlight lang="crystal">raise "fire"</syntaxhighlight>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,SysUtils,StdCtrls}}
The program uses Delphi's builtin exception processing to throw an exception. Uncaught exceptions abort a program
 
<syntaxhighlight lang="Delphi">
procedure HaltAndCatchFire;
begin
raise Exception.Create('Burning to the ground');
end;
 
</syntaxhighlight>
{{out}}
[[File:DelphiHaltCatchFire.png|thumb|none]]
<pre>
 
</pre>
 
=={{header|EasyLang}}==
<syntaxhighlight>
a[] = [ ]
print a[1]
</syntaxhighlight>
{{out}}
<pre>
*** ERROR: index out of bounds
</pre>
 
=={{header|F_Sharp|F#}}==
Line 229 ⟶ 270:
#define B() A()
A()</syntaxhighlight>
 
=={{header|GDScript}}==
An empty script will run and immediately error due to not inheriting from Node:
<code>Script inherits from native type 'RefCounted', so it can't be assigned to an object of type: 'Node'</code>
 
A script with zero warnings:
<syntaxhighlight lang="gdscript">
extends Node
func _init():$a.a()
</syntaxhighlight>
<pre>
E 0:00:00:0321 halt_and_catch_fire.gd:2 @ _init(): Node not found: "a" (relative to "Node").
<C++ Error> Method/function failed. Returning: nullptr
<C++ Source> scene/main/node.cpp:1364 @ get_node()
<Stack Trace> halt_and_catch_fire.gd:2 @ _init()
</pre>
 
This attempts to call a method on a nonexistent child node (just accessing without calling will produce a warning <code>Standalone expression (the line has no effect).</code>
 
=={{header|Go}}==
Line 252 ⟶ 311:
 
It's probably more effective to use <syntaxhighlight lang="j"> exit 0</syntaxhighlight> -- this approach would eliminate dependence on a variety of implementation details.
 
=={{header|Java}}==
<syntaxhighlight lang="java">
public final class HaltAndCatchFire {
 
public static void main(String[] aArgs) {
// Any one of the lines below, when uncommented, will cause a program halt.
// throw new AssertionError("Stop now!");
// System.out.println(0/0);
// Runtime.getRuntime().exit(1);
}
 
}
</syntaxhighlight>
 
=={{header|jq}}==
{{works with|jq}}
 
Also works with gojq, the Go implementation of jq
 
The polite way to halt a running jq program is to use `error` or `halt_error`, both of which come in two flavors.
For example:
<syntaxhighlight lang=jq>
"whoops" | error
</syntaxhighlight>
or
<syntaxhighlight lang=jq>
0 | error("whoops")
</syntaxhighlight>
It is worth noting that the text of a run-time error can be captured using `error/1`, e.g.
 
<pre>
$ jq -n '0 as $x | try (1/$x) catch error("The error text is: \(.)")'
jq: error (at <unknown>): The error text is: number (1) and number (0) cannot be divided because the divisor is zero
</pre>
 
"Catching fire" is not so easily done.
 
=={{header|Julia}}==
Line 290 ⟶ 387:
Another solution with the same number of characters (we could also use <code>mod</code> instead of <code>div</code>):
<syntaxhighlight lang="text">echo 1 div 0</syntaxhighlight>
 
But the shortest solution may be:
<syntaxhighlight lang="nim">assert 1==0</syntaxhighlight>
 
=={{header|Pascal}}==
Line 534 ⟶ 634:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">Fiber.abort("")</syntaxhighlight>
 
=={{header|XBS}}==
2,056

edits