Does Julia specifically has a function definition? If yes what is the BNF for it?
For example it has a function declaration and function call with a BNF
•Function Declaration
function name ( arguments :: type )
#expressions
End
<function> → (function <identifier> ( <arguments> ) <expressionList> end) |
<identifier>( <arguments> ) <expressionList> end
<arguments> → <identifier> :: <type> | (<identifier> :: <type>),arguments>|e
•Function Call
x = sum (12 , y :: Int32 )
<funcall> → <identifier> = <identifier> ( <parameterList> )
<parameterList> → <parameter> :: <type>, < parameterList> | <parameter> ::<type> | < parameter >, <parameterList>
<parameter> → <identifier> | <element> | e
As Matt B. mentioned in the comments, the Julia syntax is not context-free.
If
<...>
is a valid function call, then in general the following are valid method definitions:Furthermore, it is allowed to add a return type annotation to the function call:
Any number of
where
clauses is also allowed, either instead or in addition to the return type, for both short and long forms:Both short and long forms support certain qualifiers:
Note that the function call itself can come in several forms; for example each of these are valid: