Modulinos: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
m (→‎{{header|Phix}}: now builtin)
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 1,274:
print "Life means " . Life::meaning_of_life . ".\n";
print "Death means invisible scary skeletons.\n";</lang>
=={{header|Perl 6}}==
Perl 6 automatically calls MAIN on direct invocation, but this may be a multi dispatch, so a library may have multiple "scripted mains".
<lang perl6>class LUE {
has $.answer = 42;
 
multi MAIN ('test') {
say "ok" if LUE.new.answer == 42;
 
multi MAIN ('methods') {
say ~LUE.^methods;
}</lang>
 
=={{header|Phix}}==
Line 1,363 ⟶ 1,350:
print("Life means %s." % meaning_of_life())
print("Death means invisible scary skeletons.")</lang>
 
=={{header|R}}==
A way to check if code is running at "top level" is to check <code>length(sys.frames())</code>. This value will be zero for a file being run with <code>Rscript</code>, the <code>--file=</code> argument, or at the command line, and will be greater than 0 in all other conditions (such as package loading or code being sourced from another file.)
Line 1,410 ⟶ 1,398:
(require "scriptedmain.rkt")
(printf "Test: The meaning of life is ~a\n" (meaning-of-life)))</lang>
 
=={{header|Perl 6Raku}}==
(formerly Perl 6)
Perl 6 automatically calls MAIN on direct invocation, but this may be a multi dispatch, so a library may have multiple "scripted mains".
<lang perl6>class LUE {
has $.answer = 42;
 
multi MAIN ('test') {
say "ok" if LUE.new.answer == 42;
 
multi MAIN ('methods') {
say ~LUE.^methods;
}</lang>
 
=={{header|REXX}}==
Line 1,572 ⟶ 1,575:
$ ./test
Test: The meaning of life is 42</lang>
 
=={{header|Scala}}==
{{libheader|Scala}}
Line 1,726 ⟶ 1,730:
 
Transcript show: 'Test: The meaning of life is ', ((ScriptedMain meaningOfLife) printString); cr.</lang>
 
 
=={{header|Swift}}==
10,327

edits