Louis J Scoras
12/7/2006 1:45:00 PM
On 12/6/06, Trans <transfire@gmail.com> wrote:
> The violation is much worse with a global var. With a local var the
> violation is very minimal, plus the varaible can be specifically
> designated as "method mode".
You are exactly right: it is _less_ of a violation. However, I think
this is the part where I'm supposed to mention something about a
``slippery slope.''
> So it's actually very similar to keyword arguments. Eg.
>
> each(:separator => //)
>
> Just with a little extra flexability in that the method mode can apply
> to multiple calls in the same local scope and the mode variable doesn't
> have to intermingle with true data parameters.
Again, you are right, but why do this when you already have an
objects, whose entire reason for existence is to track state
information. Why not make it an honest to goodness part of the
interface?
enumerable.separator = //
# use each
> As for expressiveness. I'm not sure how youre measuring that, the
> to_enum version is clearly more convoluted (with exception of the $/
> var, but that could be called $input_separator or some such name
> instead too).
No, it's perfectly clear. What it lacks is concision, and while
concision is a desirable quality, it is not worth trading for clarity
and transparency. Saving a few keystrokes is not a good reason for
adding a new mechanism that acts at a distance.
> In anycase, perhaps any breakage of the local encapsulation is too
> much, and matz will never grant us Binding.of_caller. But then why does
> this global default on String#each persist?
I can't offer much insight on that, but I'd suspect it's historical.
--
Lou.