127
\$\begingroup\$

It looks like we have a consensus that we want certain defaults for the format which answers are expected in for . On that poll, the question arose twice, which input/output formats should be allowed for programs and functions.

So here is another poll. This one works different though. All the input/output methods are independent of each other, so there will be one answer per method. Upvote all you think are reasonable for the default. Downvote those which you think shouldn't be allowed unless the OP explicitly permits them.

To keep this remotely manageable, I have not posted individual answers for all possible inputs for functions. So there are only four: functions can take input/output via their arguments and return values. Or functions can use any method full programs can. I don't think there is any point in (say) allowing programs to take input from STDIN (only) and to allow functions to take input from ARGV (only) or something like that. If you disagree, please leave a comment.

If I've overlooked an I/O method, feel free to add your own answer.

Note: Some votes have been reverted because they were detected as serial voting. If you vote on multiple answers, please leave some time between votes.

A method is allowed if it has 5 net votes and at least twice as many upvotes as downvotes.

\$\endgroup\$
2
  • \$\begingroup\$ Related (Can numeric input/output be in the form of byte values) \$\endgroup\$
    – mbomb007
    Dec 13, 2016 at 16:10
  • 6
    \$\begingroup\$ "The current results of the polls are now part of the tag wiki" which tag wiki? meta wiki has nothing for code-golf tag. ppcg wiki has codegolf.stackexchange.com/tags/code-golf/info but it's missing a lot of answers here. \$\endgroup\$
    – Sparr
    Jul 18, 2018 at 18:17

116 Answers 116

1 2 3
4
3
\$\begingroup\$

Functions may take input from the output of a callback function

The callback function should be provided using a valid input method.

Complementing

\$\endgroup\$
3
\$\begingroup\$

Languages that output on program completion can assume termination even when built to hang for the purpose of providing output.

That is, if a program is built to not a terminate, and requires output while running (say, for an Internal Truth Machine, or Scream Very Loudly, etc.), the program can assume to crash or be manually stopped to verify the output scales appropriately.

The argument for this is that several languages (such as Processing[Java], for example) will not print output unless a certain state is reached (the end of a Draw statement in Processing, per se). This means that programs stuck in While Loops would never provide any output. Languages like GolfScript, though it has a Print function, also doesn't actually Print the output until the program is complete - it holds the print in a buffer until the program eventually stops (for any reason, even interrupting). Likewise, GS prints the stack when it closes for any reason (depending on your interpreter; TIO fails at this) - so filling the stack with infinite As then waiting for a crash would also be within this parameter.

Several languages would otherwise fail infinitely-printing hanging challenges due to the act they wouldn't ever be capable of printing given the assumed infinite time and memory, which is the main argument for allowing this sort of output.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ As written, this would allow a GolfScript program to “solve” the halting problem: push false onto the stack, then run a universal Turing machine, then pop false and push true. If this is to be allowed, it should only be allowed for mechanisms that don’t allow the program to change its mind later. \$\endgroup\$ Jun 9, 2021 at 2:50
  • 2
    \$\begingroup\$ I think we should not allow this. Verifying that the program is correct is essentially undecidable and if a program doesn't give output when it enters infinite loop, it will never give an output. \$\endgroup\$
    – Xwtek
    Dec 13, 2021 at 15:09
  • \$\begingroup\$ I, too, think we should not allow this. 1) It requires external input, namely some decision as to whether or not to terminate the program yet. 2) If the challenge is to output the count of objects that match a certain criterion, this would allow a program which searched an infinite search space, which would find any matching objects, but which would never know whether or not future searching would find any more. \$\endgroup\$
    – Rosie F
    Jul 8, 2022 at 5:22
2
\$\begingroup\$

Functions may output by calling a callback function or event

The callback function should be provided using a valid input method.

Example in JavaScript that outputs Hello world!:

f=>f("Hello world!")

This may be shorter than returning a value in some languages:

import random as r
def f(x):
    q=r.random()
    return(q+q/2)/2

As opposed to:

import random as r
def f(x,g):
    q=r.random()
    g((q+q/2)/2)
\$\endgroup\$
6
  • \$\begingroup\$ I don't see why this should be useful, considering you can just return the result. \$\endgroup\$ Feb 11, 2017 at 2:27
  • \$\begingroup\$ Never mind, I see why this might be useful. Upvoted. \$\endgroup\$ Feb 13, 2017 at 0:16
  • \$\begingroup\$ @Challenger5 Please explain why. \$\endgroup\$ Feb 28, 2017 at 12:34
  • 1
    \$\begingroup\$ @haykam In a language like Python, something like import os [\n] def f(k):return os.system(k) is longer than import os [\n] def f(k,g):g(os.system(k)) \$\endgroup\$ Feb 28, 2017 at 17:51
  • 5
    \$\begingroup\$ @Challenger5, the point of specifying default I/O methods is to allow answers to use idiomatic I/O, not to allow golfing a byte off print. \$\endgroup\$ Mar 1, 2017 at 15:04
  • 2
    \$\begingroup\$ @PeterTaylor Might it be more idiomatic in some languages to use continuation-passing style rather than returning? \$\endgroup\$ Apr 26, 2017 at 16:49
1
\$\begingroup\$

Classes, objects or other entities may have separate methods to read the input and return the result

This includes the constructor and destructor.

\$\endgroup\$
3
  • \$\begingroup\$ Can the destructor return the result? That seems to be along the same lines as outputting to /dev/null. \$\endgroup\$ May 23, 2017 at 3:15
  • \$\begingroup\$ I don't believe a C++ destructor is allowed to return anything. \$\endgroup\$
    – Riking
    Jan 11, 2018 at 8:21
  • \$\begingroup\$ Is it okay if the destruct function output something? \$\endgroup\$
    – l4m2
    Mar 8, 2018 at 12:09
1
\$\begingroup\$

Functions may output by setting the default variable(s)

Perl has a "default" scalar $_. Unless specifically overridden by the =~ operator, regular expressions and such will operate on this variable. It also has @_, the "default" array, and %_, the "default" hash.

\$\endgroup\$
5
  • 2
    \$\begingroup\$ I don't see how this is any different than hardcoding I/O with variables, which is not allowed. \$\endgroup\$
    – user45941
    Dec 5, 2017 at 20:35
  • \$\begingroup\$ @Mego What do you mean? I'm not entirely sure what "hardcoding I/O with variables" refers to. \$\endgroup\$
    – Nissa
    Dec 5, 2017 at 21:21
  • \$\begingroup\$ codegolf.meta.stackexchange.com/a/2423/45941 \$\endgroup\$
    – user45941
    Dec 5, 2017 at 21:23
  • \$\begingroup\$ Ah, I see then. \$\endgroup\$
    – Nissa
    Dec 5, 2017 at 21:26
  • 4
    \$\begingroup\$ This is basically Ans in TI-Basic, and isn't too different from the top of the stack in stack based languages. Following functions if defined in the right way don't need to specify the variable name to use it. It's only technically a variable, but don't need to be used like a variable. I don't see good reasons to disallow it. \$\endgroup\$
    – jimmy23013
    May 28, 2019 at 20:49
0
\$\begingroup\$

Cellular automata and 2d languages may output by interfacing with a user-built structure

Many of these languages do not have any other way to produce (non-visual) output. By "interfacing", I mean additional structures being created by the user to interact with the existing code in a way that the program provides only the necessary information (such as some sort of serial representation of the outputted values) in a way that could feasibly be used by the user's program to control another turing-complete automaton (so not in a tiny space in the middle of the program, or in an area that will be overwritten).

\$\endgroup\$
0
\$\begingroup\$

Cellular automata and 2d languages may take input by interfacing with a user-built structure

Many of these languages do not have any other way to take input. By "interfacing", I mean additional structures being created by the user to interact with the existing code in a way that provides only the necessary information (such as some sort of serial representation of the inputted values) in a way that could feasibly be used by the user's program and controlled by another turing-complete automaton (so not in a tiny space in the middle of the program, or in an area that will be overwritten).

\$\endgroup\$
1
  • \$\begingroup\$ This would seem similar to the "Languages without input like /// may input through insertion into their source code" \$\endgroup\$ Jul 25, 2021 at 14:42
0
\$\begingroup\$

Program may take one argument as one input and filename of another input

This allows "input two letters, concat them" in bash

cat $1; echo $1

Like Programs may take input based on their executable name, your filename should be possible to carry any possible input. If input may contain * and your filesystem doesn't support it, you can't use this method.

\$\endgroup\$
-1
\$\begingroup\$

Property setters may take input from the set value

\$\endgroup\$
1
  • 10
    \$\begingroup\$ This could use some elaboration. Why is this not a special case of a function taking input as function arguments? And why would anyone answer a PPCG question with a property setter? \$\endgroup\$ Mar 23, 2017 at 8:55
-1
\$\begingroup\$

Source files or libraries may output via the return value importing them

For example, this PHP code has no effects as a complete program:

<?php return 'Hello, world!';

But as a library named '1.php', the return value could be printed to stdout using this:

<?php echo include '1.php';
\$\endgroup\$
-2
\$\begingroup\$

Programs may use the camera and microphone

I wouldn't expect to see this very often, but it could be applicable to my upcoming challenge.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ This has my vote \$\endgroup\$
    – TheDoctor
    Nov 4, 2014 at 23:40
  • 67
    \$\begingroup\$ I don't think this should be a default. Definitely fine if asker specifies it as a valid input format for the question! Excited to see your upcoming challenge involving this. \$\endgroup\$
    – hmatt1
    Nov 5, 2014 at 2:12
-2
\$\begingroup\$

Program may take input from environment variables

Environment variables are generally supported by many languages:

  • C program may access environment variables from getenv
  • Python program may access environment variables from os.environ
  • etc.

Environment variables are typically a constant in program, which is quite different from a variable in languages.

Many real word software supports / suggests user config some options from environments. For example, docker docs, aws cli, even ls command ...

Environment variables are similar to function submissions which accept its arguments by name instead by position.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ I'm going to say no, because this is equivalent to taking input from a pre-defined name in e.g. Bash \$\endgroup\$
    – pxeger
    Jan 5, 2021 at 20:42
-4
\$\begingroup\$

eval is considered an interpreter and the eval'd code may output via the return value

For example, this PHP code has no effects as a complete program in the php interpreter:

return 'Hello, world!';

But the return value is accessible using the eval interpreter:

<?php echo eval("return 'Hello, world!';");
\$\endgroup\$
2
  • \$\begingroup\$ Just for clarification, this only applies in challenges that allow snippets, correct? I don't think you're suggesting we allow snippets by default, but just to be safe... \$\endgroup\$ Feb 11, 2017 at 2:22
  • \$\begingroup\$ @ETHproductions Rewrote to avoid mentioning that. \$\endgroup\$
    – jimmy23013
    Feb 12, 2017 at 2:41
-4
\$\begingroup\$

Languages that cannot obtain world-state-sensitive information can accept the information as an additional input

Some challenges may require the use of the current time, cryptographic random values, or other information present on the system used to run the program. Additionally, many languages (for various reasons) lack the ability to access this information, and thus compete at all.

To overcome this, answers may accept such information as additional input in a minimally processed format (eg: unix timestamp instead of a date string, a single random value instead of a random generator function).

\$\endgroup\$
8
  • \$\begingroup\$ Well, cryptographic random values can still be generated in Turing tarpits. \$\endgroup\$
    – Nissa
    Dec 5, 2017 at 18:29
  • 1
    \$\begingroup\$ @StephenLeppik I was thinking more of completely deterministic languages where you would need the random seed for any subsequent random values. \$\endgroup\$
    – Οurous
    Dec 5, 2017 at 18:49
  • \$\begingroup\$ I don't like this idea (it's related to this meta. Accessing system information can require quite some bytes (maybe an import and/or system calls with long function names). Taking just another input variable instead is an unfair advantage. We always had challenges which cannot be solved with all languages (e.g. graphical output), but most can, so it's not a problem. \$\endgroup\$
    – nimi
    Dec 6, 2017 at 23:03
  • 4
    \$\begingroup\$ @nimi This isn't for those languages that can access system information/resources only in an expensive manner. This proposal is for languages (like brainfuck) that have no way to access that information/those resources. Because BF has no source of randomness, this proposal would allow BF to take a seed value as an additional input to be fed into a PRNG. \$\endgroup\$
    – user45941
    Dec 12, 2017 at 6:19
  • \$\begingroup\$ @Mego: yes, I know, maybe I wasn't clear enough. My point is: getting some system information via additional input is usually much cheaper (in bytes) than having to call some system library functions. Some languages would be allowed to use the former, others not, although both compete within the same challenge. That's unfair. ... \$\endgroup\$
    – nimi
    Dec 12, 2017 at 14:36
  • 3
    \$\begingroup\$ @Mego: (cont.) Stupid example to illustrate the point: challenge: output the system time. Fictional stack based esolang #1: St (system call "time" + implicit print -> 2 bytes). Fictional stack based esolang #2: No systems calls available, therefore the time is expected as input on top of the stack + implicit print -> 0 bytes). #2 wins, because #1 has to use the system calls. Same example for non-esolangs: import Time;f=print(system_time()) vs. f(x)=print(x). \$\endgroup\$
    – nimi
    Dec 12, 2017 at 14:36
  • 1
    \$\begingroup\$ @nimi That falls afoul of this loophole. \$\endgroup\$
    – user45941
    Dec 12, 2017 at 14:38
  • \$\begingroup\$ @Mego: True for my mini example. However, the advantage for #2 remains even if the task is more complicated. \$\endgroup\$
    – nimi
    Dec 12, 2017 at 14:44
-4
\$\begingroup\$

Submissions to challenges may take no input and output a (potentially infinite) set of all possible truthy/falsey outputs.

If the challenge is "Is the number even or odd?", a submission could output a set of all even numbers (or, a set of all odd numbers).

If the challenge is "Is the number a fibonacci number?", a submission could output a set of all fibonacci numbers.

A few submissions in TypeScript’s type system have used this where the submission is a union type (like a set) and you get truthy/falsey by whether assigning a variable to the union throws an error or not. I don’t see why this wouldn’t be allowed in other languages as well.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ One weird consequence of this is allowing you to solve the halting problem as a decision challenge, even though it's formally undecidable. \$\endgroup\$
    – xnor
    Nov 1 at 3:35
  • \$\begingroup\$ @xnor Not sure that’s true, how do you get the set of all halting programs without solving the halting problem? \$\endgroup\$
    – noodle man
    Nov 1 at 10:50
  • 1
    \$\begingroup\$ Enumerate all programs. Run program \$i\$ for \$j\$ steps, for every pair \$(i,j)\$ of positive integers in some enumeration of those pairs. If program \$i\$ halted on exactly step \$j\$, output it. \$\endgroup\$
    – xnor
    Nov 1 at 17:52
  • 1
    \$\begingroup\$ Hm, interesting. I still don’t really see why this I/O format can’t be allowed, though—the true/false is just the member function \$\endgroup\$
    – noodle man
    Nov 1 at 17:54
-5
\$\begingroup\$

Languages that do have I/O capabilities may take input via hardcoding

i.e. you may insert input into the code directly, as if it were an output only language like ///

\$\endgroup\$
4
  • \$\begingroup\$ Interesting. I'd be curious to see the reasoning for these downvotes \$\endgroup\$ Jan 12, 2022 at 15:15
  • 3
    \$\begingroup\$ I think its because this becomes more of a snippet format \$\endgroup\$
    – Seggan
    Jul 7, 2022 at 17:14
  • \$\begingroup\$ This is already listed here. \$\endgroup\$
    – naffetS
    Aug 28, 2022 at 3:14
  • \$\begingroup\$ @Steffan it is not, read the titles of both very closely \$\endgroup\$ Aug 28, 2022 at 16:34
-5
\$\begingroup\$

Programs may output only one copy as two intended ones if they're always same

This usually apply to open-ended questions if possible

\$\endgroup\$
2
  • 6
    \$\begingroup\$ I'm not sure I understand this proposal (and given the lack of votes, I don't think anyone else does either) \$\endgroup\$
    – Jo King Mod
    Apr 7, 2022 at 13:22
  • \$\begingroup\$ I think the user is proposing that outputting the answer twice is reasonable. \$\endgroup\$
    – Someone
    Nov 22 at 18:51
-5
\$\begingroup\$

You can have as many newlines after your output as you want.

It doesn’t matter what type of newline.

\$\endgroup\$
4
  • 3
    \$\begingroup\$ Already covered here: codegolf.meta.stackexchange.com/a/24952/91213 \$\endgroup\$
    – mousetail
    Apr 12 at 13:37
  • \$\begingroup\$ @mousetail that’s whitespace not newline \$\endgroup\$ Apr 12 at 13:39
  • 5
    \$\begingroup\$ A newline is a type of white-space, along with tabs, spaces, and some weird Unicode chars \$\endgroup\$
    – mousetail
    Apr 12 at 13:39
  • 2
    \$\begingroup\$ I concur with @moustail: POSIX defines white space as, quote: A sequence of one or more characters that belong to the space character class as defined via the LC_CTYPE category in the current locale. In the POSIX locale, white space consists of one or more <blank> ( <space> and <tab> characters), <newline>, <carriage‑return>, <form‑feed>, and <vertical‑tab> characters. \$\endgroup\$ Apr 12 at 14:02
-6
\$\begingroup\$

Functions may get input from predefined variables in languages where this is standard

In some BASIC dialects, the standard way to implement functions is to use GOSUB (similar to CALL in assembly). You can't pass variables to GOSUB, so function arguments/returns are just global variables. If you need a function that takes a number as input, and outputs that number multiplied by 2, the normal way to do this would be something like:

@TIMES2
 OUT=IN*2
RETURN

To call it, you would do

IN=7
GOSUB @TIMES2
'result is in variable OUT

The exact same process is allowed in assembly languages.

\$\endgroup\$
4
  • 4
    \$\begingroup\$ I don't think it's necessary to allow things that are "Kind of like functions" just because a language doesn't have functions. As long as an answer can be written as a full program using existing allowed I/O I don't think we need a special exception to allow answers in "function-like behavior". \$\endgroup\$ Oct 27, 2017 at 19:26
  • \$\begingroup\$ Then why do we allow the same thing in "assembly" languages? \$\endgroup\$
    – 12Me21
    Oct 27, 2017 at 19:53
  • 3
    \$\begingroup\$ Answers talking about "Assembly" refer to any language which does not have an output other than storing things in a special register. If a program can be written in the language which inputs and outputs in a more standard way then it doesn't need those allowances. \$\endgroup\$ Oct 27, 2017 at 20:07
  • \$\begingroup\$ Registers in assembly language are analogous to local vars and temporaries (like a return-value object) in languages like C. Languages that don't have locals or return-values don't have anything like registers. I didn't downvote, though; if the language has a gosub and real-world (non-golf) usage does write "functions" this way, there's certainly an argument to be made. The justification by analogy with asm is pretty weak, though. In asm you need registers just to evaluate expressions, and there are only a small fixed number of them. \$\endgroup\$ Oct 8, 2019 at 18:17
-6
\$\begingroup\$

Functions may output by modifying a global variable

This is similar to Functions may output by modifying their arguments or writing to out arguments
The difference is that we don't pass any reference to the function, instead we declare a global variable the function is aware of and assigns the result to it.
Obviously the global variable declaration used must be included in the score.

For example a C function which was like this:

f(x,Type*r){... ;*r=result;}

May be

Type r;f(x){.... ;r=result;}
\$\endgroup\$
3
  • \$\begingroup\$ I used this method on a challenge but never seen before, no one complained but since I was not sure I searched here in the Meta.. The only similar answer was the one linked, the title mentioned "write to out arguments" but here we don't use out argument but out global variable \$\endgroup\$
    – AZTECCO
    Nov 17, 2021 at 7:51
  • \$\begingroup\$ I'm not a fan of this. I think it's basically becoming a snippet format, and I don't really feel like a case for this has been made here. \$\endgroup\$
    – Wheat Wizard Mod
    Nov 17, 2021 at 16:21
  • \$\begingroup\$ @Grain Ghost thanks, I'm not sure too, I would probably downvote this, that's why I posted it, I think it's good to clearly define if it is acceptable or not before it become used. As for now there are only 2 answers using this I'm aware of(one is mine). I'll correct mine and warn the other in a couple of days \$\endgroup\$
    – AZTECCO
    Nov 17, 2021 at 17:19
-7
\$\begingroup\$

Functions may return multiple values, even if the question only asks for one.

As long as one of them is the requested output, the function is considered valid.

\$\endgroup\$
4
  • 9
    \$\begingroup\$ This would definitely cause problems for decision problem challenges if you could just return [True, False] no matter the input. \$\endgroup\$
    – xnor
    May 13, 2021 at 11:00
  • 6
    \$\begingroup\$ Suggest editing this to “as long as a specified one of them is the requested output”. \$\endgroup\$ Jun 9, 2021 at 2:56
  • 1
    \$\begingroup\$ Anders Kaseorg's suggestion makes a lot of sense - it allows people to output extraneous information without cheating on questions. \$\endgroup\$
    – user
    Jun 25, 2021 at 20:16
  • \$\begingroup\$ Yes, @AndersKaseorg's suggestion is what I was going for here. This answer is so far in the hole I'm afraid editing it wouldn't do much. Feel free to make a new answer. \$\endgroup\$
    – chunes
    Jun 14 at 22:09
-7
\$\begingroup\$

You may output with reasonable constant trailing and leading data

This does not apply to challenges.

For example, if you need to output 3, you can output __3__.

\$\endgroup\$
2
  • \$\begingroup\$ Why the downvotes? \$\endgroup\$ Jul 21 at 16:41
  • 1
    \$\begingroup\$ I'm not sure (I didn't downvote it), but I think it's because people feel like this needs to be more restricted. Underscores feel somewhat off—maybe restrict it to whitespace and certain other characters? Plus, there are other answers exactly like this. \$\endgroup\$
    – Someone
    Aug 28 at 17:50
-8
\$\begingroup\$

Programs running under Unix may produce output by overwriting their command-line arguments, which changes what ps reports.

I'm posting this because it was brought up as a loophole in my answer to this question. I personally think it should not be allowed, because it's obscure, not available in all languages, and ephemeral (someone has to run ps while the program is still executing).

\$\endgroup\$
2
  • \$\begingroup\$ this seems to be a special case of "functions may use out parameters" \$\endgroup\$
    – Jasen
    Dec 22, 2016 at 10:55
  • \$\begingroup\$ but ps doesn't report it after the program ends :( \$\endgroup\$
    – Jasen
    Dec 22, 2016 at 11:01
-21
\$\begingroup\$

Dynamic creation of a "fake" STDIN, when one isn't present (creating also a separation between the code and the input).


For example, Javascript doesn't have STDIN(for obvious reasons).

One could make something like function(a){[code here]} and only count the content inside it + 1.

On php, one can read from STDIN using $f=fread(STDIN,1024); and this would count only as 2 chars.

On other languages, this would vary a bit.

Any questions, I may answer on the comments.

\$\endgroup\$
4
  • 5
    \$\begingroup\$ Isn't the PHP example actually reading from STDIN? In which case, why shouldn't all of those bytes count? \$\endgroup\$ Nov 3, 2014 at 0:09
  • \$\begingroup\$ Depending on the way you handle it, if you read everything on STDIN at once, you can consider it a single input. I don't know if I'm making myself clear. But if your code is restricted to only 1 read to the STDIN, you can only consider the size in bytes of the name of the var. If multiple accesses are made (loops, conditions, partial reads...), everything is counted on the code. \$\endgroup\$ Nov 3, 2014 at 0:14
  • 1
    \$\begingroup\$ @MartinBüttner He's referring to the fact that different languages have different character counts for an STDIN read. Also, shouldn't this be CW? \$\endgroup\$
    – TheDoctor
    Nov 4, 2014 at 23:42
  • 3
    \$\begingroup\$ @TheDoctor Doesn't matter anyway - no rep gain/loss for meta. \$\endgroup\$
    – user10766
    Nov 6, 2014 at 21:44
-29
\$\begingroup\$

Output is saved in a certain variable at the time the program has finished execution

This eliminates the disadvantages languages like Java have when printing System.out.println("asdf")

For languages without variables this could be top of the stack etc...

\$\endgroup\$
4
  • 24
    \$\begingroup\$ This essentially makes the submission a snippet instead of a full program, which the other meta question decided should not be a valid default. \$\endgroup\$ Sep 11, 2015 at 18:25
  • \$\begingroup\$ @MartinBüttner Unless the programming language is, of course, a turing machine. (I do vote for placing the tape head at the return value) \$\endgroup\$
    – yyny
    Jan 31, 2016 at 0:41
  • 2
    \$\begingroup\$ In C#, a lambda is more a variable than a function. Lambdas are build on top of Delegates. Are they still valid? (By this, i think so) \$\endgroup\$
    – aloisdg
    Jul 6, 2016 at 20:32
  • 1
    \$\begingroup\$ In what way is this fundamentally different from the same rule about functions? Why is it allowed for functions and not for full programs? \$\endgroup\$
    – Kaddath
    May 5, 2021 at 15:04
-47
\$\begingroup\$

Programs may take input by assuming it is stored in predefined variables.

\$\endgroup\$
6
  • 9
    \$\begingroup\$ -1 (Can't vote) \$\endgroup\$ Mar 17, 2016 at 21:43
  • 1
    \$\begingroup\$ This just skips the "reading" step of a program. I don't think programs should be allowed to assume the output of an arbitrary computation, e.g. the one asked for in the question, is stored in a predefined variable either. \$\endgroup\$
    – djechlin
    Jun 6, 2016 at 18:11
  • 1
    \$\begingroup\$ @djechlin we are intentionally separating input/output methods. Outputting on variables is listed here: meta.codegolf.stackexchange.com/a/6965/20198 \$\endgroup\$ Jun 6, 2016 at 18:14
  • \$\begingroup\$ Okay, I still don't think you can skip the "reading" step of a program any more than you can skip the "writing" step of a program. That's all I'm trying to say. \$\endgroup\$
    – djechlin
    Jun 6, 2016 at 18:15
  • 2
    \$\begingroup\$ I'm confused what you are talking about. Programs have input and output. We define valid input methods (such as reading from a file, or parameters to a function), and valid output methods (writing to a file, or return values). This post is directly targeted at input methods. There is another answer on this question targeted at output methods. We split them so people can vote separately. \$\endgroup\$ Jun 6, 2016 at 18:18
  • 2
    \$\begingroup\$ This is most relevant to the Sinclair ZX80 and ZX81 BASIC. \$\endgroup\$ Apr 4, 2017 at 9:04
1 2 3
4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .