# What is code length?

An interesting conundrum has arisen in relation to the bonus I offered for APL solutions to An Ant on a Cube. It's an old challenge that requires a "named function", such as a lambda assigned to a variable: f←{...} - that is 2+ the code length we normally consider valid for most golfing challenges. @Adám devised the following way to circumvent the need for "f←": create a named function object (in APL-speak: "fix" it) from a string, and claim the string's length as code length. Typing the string directly in the REPL or placing it in a file wouldn't have the same effect, so "fix"-ing is essential and the actual number of bytes sent to the interpreter in order to pull off this stunt is, of course, much higher.

So, in this context, how do we define code length?

• To me this looks like either an abuse of the interpreter or an abuse of the term "byte count" (particularly when it comes to interpreter flags). – Draco18s Mar 16 '18 at 19:41
• I'm pretty sure the code length is the length of code←'f',n,'{⍵≡(↓∪⊢∘⌽)/⎕,⍵}⊂⍳4', it'd be just like in C where you have to count f(int*i) before the function body. I'm not really sure I understand, though, because I don't see how it could be interpreted otherwise. – FryAmTheEggman Mar 16 '18 at 20:00
• @FryAmTheEggman In C that is sufficient to make it a valid (fragment of a) source file. In APL you're required to surround that kind of function definition (called a "tradfn"), including its header, with a pair of ∇-s, except when you pass a string to ⎕fx. – ngn Mar 16 '18 at 20:24
• Alright, so is it like how this Python code shows that the "code" is 8 bytes, but in order to make something interpreted like that you would need to do something like the third example in this answer? – FryAmTheEggman Mar 16 '18 at 23:22
• @FryAmTheEggman Yes, something like that, but with text, not bytecode. – ngn Mar 17 '18 at 0:29
• @FryAmTheEggman If an interpreter exists that can use that bytecode, you certainly could use Python function bytecode as a language. – Mego Mar 18 '18 at 3:24
• @Mego Right, if they are exactly the same then I think its a case of it being fine to submit that as a solution, but it would need to be for a different language called "APL tradfn" or something similar. I still don't think I understand enough about what the APL code is doing to answer, though. – FryAmTheEggman Mar 18 '18 at 4:35

The ∇ just opens and closes the line editor and is certainly not part of the code, as can be seen Character Representation (⎕CR'f') of the program. It was exactly to demonstrate this that I included the ⎕CR in the output.
Also placing the code in a file without ∇s is perfectly adequate for APL to import it. Try it online!
• You're just reading the file and calling ⎕fx on its content :) and you're not counting the bytes it took you to do that. – ngn Mar 17 '18 at 23:59
• @ngn What does dyalog -script have to do with it? Classic doesn't even recognise that switch, so then it isn't a programming language? And this is an invalid solution to returning [8,4,3] – Adám Mar 18 '18 at 0:30
• Huh, I don't know what you're trying to say with the last link. In any case, if we allow ⎕fx-ed APL code, surely Python code objects should be allowed too (see FryAmTheEggman's comment)? – ngn Mar 18 '18 at 0:46