On Fri, Apr 13, 2012 at 7:19 AM, Gabriel Wicke <wicke(a)wikidev.net> wrote:
From a language perspective, I would much prefer
return values instead
of side effects, even if those side effects could be converted into a
return value with a special print implementation.
I think I agree with Gabriel here (and looks like the quickly forming
consensus). More reasons why this seems like the right choice:
1. We should be conservative in what we initially support, and only add
more if we need it. Return values are the most general solution which
we're almost certainly going to need no matter what, whereas output via
print is an optimization.
2. We should make this environment one that is fun for good programmers to
write clear code, so as to attract good programmers and encourage
collaboration, and make everyone feel like learning how our system works
has applicability in other parts of their lives. Side effects are a paving
stone toward tangled single-programmer write-only code.
3. Premature optimization is the root of all evil.
I am no Lua expert, but would guess that the usual
collect-in-list-and--finally-join method can avoid the performance
penalty in Lua too.
If this type of technique works and becomes important, we can probably
introduce patterns and possibly helper functions to make the easy default
choice. I imagine there's going to be a lot of cut-and-paste going on, so
if we can establish best practices early (keeping a close eye on how it's
being used), we can introduce some good genetic stock into future Lua
scripts.
Rob