Function prototype: Difference between revisions

Content added Content deleted
(D entry: D has function declarations.)
Line 149: Line 149:


Other special forms are described in the User's Guide to the PARI library, section 5.7.3.
Other special forms are described in the User's Guide to the PARI library, section 5.7.3.

=={{header|Perl}}==

The perl scripting language allows prototypes to be checked during JIT compilation. Prototypes should be placed before subroutine definitions, declarations, or anonymous subroutines. The sigil [http://rosettacode.org/wiki/Special_characters#Perl|special symbols] act as argument type placeholders.

<lang perl>sub noargs(); # Declare a function with no arguments that returns an integer
sub twoargs($$); # Declare a function with two scalar arguments. The two sigils act as argument type placeholders
</lang>

=={{header|Perl 6}}==
=={{header|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 6 because post-declaration of functions is allowed, and normal function declarations do not bend the syntax the way they sometimes do in Perl 5.
There is no restriction on placement of prototype declarations. (Actually, we call them "stub declarations".) In fact, stub declarations are rarely needed in Perl 6 because post-declaration of functions is allowed, and normal function declarations do not bend the syntax the way they sometimes do in Perl 5.