Hi --
On Sun, 11 Sep 2005, Gavin Kistner wrote:
> On Sep 10, 2005, at 8:40 AM, David A. Black wrote:
>> I can't think of any reason to do this other than the fact that people
>> who haven't learned how to use ERB expect it, and I don't consider
>> that a compelling reason.
>
> Others have expressed similar sentiments, so I'm responding in general:
>
> At work, our bug filing system has you rate each bug on several different
> axes, one of which is "severity". One option is "Missing functionality;
> workaround exists", and another (weightier) option is "Missing functionality,
> no workaround". In general, having *a* way to accomplish a task is not the
> same as having the 'ideal' way to accomplish a task. It's better than
> nothing, but it's not perfect.
>
> Separate from the "because it's what certain people expect" factor, I
> consider the current method of appending strings to "_erbout" less
> convenient/ideal than using muscle-memory-friendly methods like #puts.
>
> To take it to the extreme, what if ERB did not support any Kernel methods,
> but provided another mechanism for calling them? What if you couldn't write
> "myobj.foo" but instead had to write "myobj.send( :foo )" to invoke the
> method? The exact same functionality would still be there...you would just
> need to remember, when using ERB, to write your code in a different way than
> you do normally.
But code isn't normally inserted into a text template. It's a
specialized situation. There's no way, and no reason, to sweep that
under the carpet.
> My belief is that it would be a PITA. The more the code you
> have to write inside ERB blocks deviates from Ruby (syntax, idioms, or
> 'general use') the less convenient it is to use. The more ERB 'just works'
> right out of the box, the greater a tool it becomes to lure people to Ruby.
I admit I am very down on luring people to Ruby by introducing
inconsistencies and anomalies into the language and libraries. What
this particular special case would do would be to mask the fact that
puts and print are method calls with return values. That creates the
need to explain one or both of two things: the fact that, elsewhere,
they do behave like normal methods, and the fact that, in ERB, they
don't. It's a double twist in the road; so why not just learn how it
really works in the first place?
In the short term, having the puts/print exception might allow a few
people to indulge habits that correspond to a novice's first
instincts. But in the long term, what makes Ruby simple and
attractive, in my view, is in part the fact that while there *are*
advanced features and techniques, those features and techniques tend
to be built up incrementally and transparently from the simple things.
I would rather see people invest effort in really understanding method
calls and return values, than have to learn ad hoc how particular
method calls operate in different contexts. It's sort of like having
to learn irregular verbs.
David
--
David A. Black