52
\$\begingroup\$

One of the things many (new?) users forget to specify in challenges is whether the answers should provide a full program or a function (or even just a snippet). For most such things, we have defaults in the tag wiki (like scoring by bytes), but not for this.

The conclusion in chat was that such a default would be useful, so let's vote on what it should be.

See here for the follow-up poll on input/output methods.

\$\endgroup\$
5
  • 2
    \$\begingroup\$ I have not added an answer which excludes full programs as the default, because there might be languages where that isn't even possible. \$\endgroup\$ Commented Oct 29, 2014 at 20:23
  • \$\begingroup\$ Supposing functions are allowed, should functions that accept an argument and print the result of a calculation to stdout, or functions that read from argv and return a value be allowed? \$\endgroup\$
    – feersum
    Commented Oct 29, 2014 at 20:25
  • \$\begingroup\$ @feersum I think we should worry about I/O defaults after coming to a consensus on this, because the cross product of all possible options doesn't seem manageable. \$\endgroup\$ Commented Oct 29, 2014 at 20:28
  • 3
    \$\begingroup\$ I think it would be nice if all the code could be run by people who don't know the language. That is it could be a complete piece of source code. \$\endgroup\$
    – user9206
    Commented Jan 21, 2015 at 14:54
  • \$\begingroup\$ What exactly is the difference between answering with a snippet and "defining a dialect" (a la the 'sed with implied input' at codegolf.meta.stackexchange.com/questions/5476/… ), particularly in cases where the standard interpreter has a built-in mode such as a REPL for running so-called "snippets"? \$\endgroup\$
    – Random832
    Commented Oct 22, 2019 at 21:04

6 Answers 6

102
\$\begingroup\$

The default should be "programs or functions"

This includes function-like constructs, including J's verbs and GolfScript's and CJam's blocks.

\$\endgroup\$
11
  • \$\begingroup\$ Would functions be allowed to print rather than return the output? \$\endgroup\$
    – xnor
    Commented Oct 29, 2014 at 20:25
  • \$\begingroup\$ @xnor I think we should worry about I/O defaults after coming to a consensus on this, because the cross product of all possible options doesn't seem manageable. \$\endgroup\$ Commented Oct 29, 2014 at 20:27
  • \$\begingroup\$ This excludes some languages, such as J. \$\endgroup\$ Commented Oct 30, 2014 at 8:08
  • \$\begingroup\$ @PeterTaylor Doesn't J have functions? \$\endgroup\$ Commented Oct 30, 2014 at 8:13
  • \$\begingroup\$ J is weird. It's the reason that I always include "named verb" in my list of acceptable submission styles. (And "named block" for GolfScript, although in GS it's nearly always shorter to write a program). \$\endgroup\$ Commented Oct 30, 2014 at 8:24
  • \$\begingroup\$ This still leaves one question open: Does the functions/blocks/verbs have to be named? \$\endgroup\$
    – Dennis
    Commented Oct 30, 2014 at 18:02
  • 2
    \$\begingroup\$ @Dennis Not unless the OP requires them to be named. \$\endgroup\$ Commented Oct 30, 2014 at 18:04
  • \$\begingroup\$ Function bodies? Or complete function declarations with function main()-like boilerplate? \$\endgroup\$
    – user16402
    Commented Nov 1, 2014 at 20:32
  • 1
    \$\begingroup\$ @professorfish Complete functions. Function bodies would be "snippets" (see this answer). \$\endgroup\$ Commented Nov 1, 2014 at 20:34
  • 2
    \$\begingroup\$ This seems to be the correct default, because the general rule is that whatever is left unspecified gets interpreted in the way most advantageous to the answerer. On the other hand, those who intend "program or function" in their questions often absentmindedly write "your program" which then implies that a program is required, when they should write "your code." \$\endgroup\$ Commented Nov 10, 2014 at 13:45
  • 1
    \$\begingroup\$ me downvote, there are programs without functions and the definition of function can be diffent. the startup is part of the language, if you keep that part out, you can skip every part. \$\endgroup\$ Commented May 5, 2017 at 8:29
54
\$\begingroup\$

Restricting to just programs requires explicitly specifying "full program" rather than just "program"

If the question requests a program, this can still be answered with a function. This allows for the fact that many people state "program" without thinking, not intending to exclude functions.

For questions that wish to exclude functions, this should be stated explicitly, for example: "full program", "complete program" or "program, not function".

\$\endgroup\$
2
  • 10
    \$\begingroup\$ This is an especially good idea for challenges by newer users who aren't familiar with our customs/defaults. \$\endgroup\$
    – Alex A. Mod
    Commented Sep 8, 2015 at 16:57
  • \$\begingroup\$ Is it even possible to write and then execute an incomplete program⁇ I mean, of course people can submit buggy code, code that doesn’t compile, but I don’t think this is meant by saying “full” program. Frankly, to me this answer sounds like encouraging a pleonasm. \$\endgroup\$ Commented Nov 10, 2022 at 10:38
-4
\$\begingroup\$

A set of different "defaults"

I think many questions require one of a few different ways, some require...

  1. ... a full program that accepts input and prints output throu standard I/O
  2. ... files as input/output (e.g. Images)
  3. ... only functions (or similar constructs)
  4. ... snippets, where input/output is stored in a variable (or similar construct)

This is of course just a rough draft, but you get the idea. My suggestion is making a definition for each of these in order that everyone writing challenges only has to declare which of those apply, instead of writing a whole novel on what is allowed and what is not.

\$\endgroup\$
2
  • 3
    \$\begingroup\$ We have a separate question for which I/O methods should be allowed. \$\endgroup\$
    – Martin Ender Mod
    Commented Sep 8, 2015 at 10:30
  • 1
    \$\begingroup\$ Having the defaults we already do (separately) means that the question already doesn't need to spend time on defining them. Only those things which are non-standard need be mentioned. \$\endgroup\$ Commented Sep 8, 2015 at 17:30
-9
\$\begingroup\$

We don't need a default

Every question has to specify this.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ This has my downvote. \$\endgroup\$ Commented Oct 29, 2014 at 20:24
  • 7
    \$\begingroup\$ +1 Questions which don't have it should be closed as "Unclear what you're asking". \$\endgroup\$ Commented Oct 29, 2014 at 21:34
  • 1
    \$\begingroup\$ @PeterTaylor plenty of good existing questions would have been under that ruling, I'm afraid. \$\endgroup\$ Commented Nov 3, 2014 at 7:03
  • 2
    \$\begingroup\$ @JanDvorak, sorry, I'm using old terminology. I should say "put on hold" and clarified. \$\endgroup\$ Commented Nov 3, 2014 at 9:31
-10
\$\begingroup\$

The default should be "programs only"

\$\endgroup\$
2
  • 10
    \$\begingroup\$ This has my downvote. \$\endgroup\$ Commented Oct 29, 2014 at 20:24
  • 3
    \$\begingroup\$ mine too. significant disadvantage for languages that have a large overhead (huge trivial program) \$\endgroup\$
    – Titus
    Commented Jul 7, 2016 at 7:41
-17
\$\begingroup\$

The default should be "programs, functions or snippets"

By "snippets" I mean just a piece of code which expects the input to be stored in a hardcoded variable and stores the output in another hardcoded variable, or prints it.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ The question is which one of these \$\endgroup\$
    – rydwolf
    Commented Apr 19, 2018 at 13:56

You must log in to answer this question.

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