Rules for function submissions
What are our rules for function submission? What constitutes a function, and what makes a submission valid? Language agnostic answers are allowed.
2 answers
General requirements
You need to have all the code that is necessary to create the function within your submission.
For most languages, this may include the syntax for defining the name and argument list of the function, and delimiters for the function body.
Some languages have first class functions or assignable function bodies, so they can just put the value in a submission and ask the user to assign it in order to use it more than once.
0 comment threads
Function parameters should not be allowed to be used in place of a return value.
Reasons:
-
Terms like return value and function result are explicitly specified as a specific, formal language item in most languages.
Therefore, interpreting a challenge asking for a return value as "return through parameter" is creating a local code golf dialect of the language (as was done on Stack Exchange).
New users of the site should not need to study local, site-specific dialects of programming languages in order to contribute. It's bad enough to allow non-standard extensions.
-
Not all languages support pass by reference.
-
Some languages separate subroutines (do not return a value) from functions (returns a value).
-
Assuming that things like memory allocation are handled by the caller might give contributions an unfair advantage.
0 comment threads