For many code golf questions, we allow functions as answers. What exactly does it mean for some code to be a valid submission as a function?
This question came up during a discussion on built-ins, but is a separate discussion from that one.
Here are some examples in Python, where I'm not sure which should be allowed.
Cases that seem clearly allowed:
Defining a wholly new function, where defining means giving the function a name by which it can be later called:
limit = 10 def func(a): for i in range(limit): if a[i % len(a)]: return i
An expression which evaluates to a function:
Cases that seem like they shouldn't be allowed:
Causing a function to exist and be usable, but without interacting with it directly:
This causes the function
math.gcdto exist, without directly interacting with it.
This case is particularly problematic, because a golfing language could be defined to cause literally every possible function to become defined when given a 1 (or 0) character command, which defeats the purpose.
Causing a very large number of functions to be defined, where the function in question is one of them:
for index, code in enumerate(all_possible_strings): eval("func" + str(index) + "=" + code)
Assume that all_possible_strings is a generator which yields all possible strings. Somewhere in that sequence, the string
lambda a:a.count(a)/len(a)must have occurred, so the function
func<very large number>is now defined as that function. This also seems problematic and like a loophole.
Cases I'm not sure about/what the consensus is:
Submissions that contain an expression that evaluates to the desired function, as well as other code:
A =  for i in range(50): A.append(sum(A) * i) A.count
A.countsolved the challenge, would this be valid?
Given these cases, what should our standard of a valid function submission be?