Jump to content

Function prototype: Difference between revisions

m
→‎{{header|Raku}}: Fix links and comments: Perl 6 --> Raku
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
m (→‎{{header|Raku}}: Fix links and comments: Perl 6 --> Raku)
Line 1,153:
=={{header|Raku}}==
(formerly Perl 6)
There is no restriction on placement of prototype declarations. (Actually, we call them "stub declarations".) In fact, stub declarations are rarely needed in Perl 6Raku because post-declaration of functions is allowed, and normal [http://design.perl6raku.org/S06.html#Subroutines_and_other_code_objects function declarations] do not bend the syntax the way they sometimes do in Perl 5.
 
Note that the <tt>...</tt> in all of these stub bodies is literally part of the declaration syntax.
Line 1,174:
<lang perl6>sub foo ($, :$faster, :$cheaper --> Int) {...}</lang>
 
Example of prototype declarations for subroutines or procedures, which in Perl 6Raku is done simply by noting that nothing is returned:
<lang perl6>sub foo ($, $ --> Nil) {...}</lang>
 
Line 1,183:
<lang perl6>sub foo ($, :$option! --> Int) {...}</lang>
 
A routine may unpack an <tt>Array</tt> automaticly. Here the first element is stored in a scalar and the rest in an <tt>Array</tt>. Other buildin types can be [http://design.perl6raku.org/S06.html#Unpacking_array_parameters unpacked] as well.
<lang perl6>sub foo ([$, @]) {...}</lang>
 
2,392

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.