1
\$\begingroup\$

My understanding is that, when stdout is used for output, stderr is ignored. Similarly, it would seem that, when a function's return value is used for output, stdout and stderr should be ignored. After all, this Racket code prints #<procedure>, and yet no one would complain about it:

(lambda (x) x)

My use case is that, in an answer I'm working on, defining a function prints its name because of the requirements of the problem and a quirk of the language. This is not just about code golf (actually, it's for a cops-and-robbers challenge).

\$\endgroup\$
  • 2
    \$\begingroup\$ Related discussion for code golf. meta.codegolf.stackexchange.com/questions/8871/… \$\endgroup\$ – Dennis Mar 16 '17 at 5:52
  • \$\begingroup\$ @Dennis Hmm, I think that answers my question. I don't see why the same principle shouldn't apply to cops-and-robbers. \$\endgroup\$ – Brian McCutchon Mar 16 '17 at 6:04
  • 1
    \$\begingroup\$ If this is for a CnR, then it would be fair to mention any such side-effects in the cop, because otherwise robbers might be searching explicitly for clean solutions if they're not aware that this is legitimate. \$\endgroup\$ – Martin Ender Mar 16 '17 at 8:53
  • 1
    \$\begingroup\$ It is useful to point out that it is permitted to write a function that does output to stdout. In which case it seems common place to ignore the return of the function all together. \$\endgroup\$ – Wheat Wizard Mar 17 '17 at 4:54
3
\$\begingroup\$

The policy we have in place for code golf makes the most sense: you can choose exactly one acceptable output format, and ignore all others. There's no reason not to apply this to CnR challenges as well. You should make it clear which output method is being used if it's not blatantly obvious.

\$\endgroup\$
  • \$\begingroup\$ The problem is, It's not code-golf. \$\endgroup\$ – Matthew Roh Mar 18 '17 at 13:05
  • 1
    \$\begingroup\$ @Mathew No, but he's saying that the policy makes sense for cops and robbers as well, I think. \$\endgroup\$ – Brian McCutchon Mar 18 '17 at 14:31
  • \$\begingroup\$ @BrianMcCutchon That's exactly right - there's no reason not to apply the same policy to CnR. \$\endgroup\$ – Mego Mar 18 '17 at 19:12

You must log in to answer this question.

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