From: "David A. Black" Date: 2005-09-12T09:15:11+09:00 Subject: Re: RCR to modify #puts and #print inside ERB Hi -- On Mon, 12 Sep 2005, Mark Hubbart wrote: > Hi, > > On 9/11/05, David A. Black wrote: >> >> If you want puts and print to behave anomalously, that's OK. But >> there's no mystery to why they don't. They behave exactly the same >> way every other method behaves. I don't think the *absence* of a >> "magic" or special case should be a source of wonder :-) > > That's the thing; to those of us who don't see it as just "fancy > string interpolation", the *current* behavior is anomalous, not the > suggested behavior. The current behavior actually seems rather magic, > until you discover why it behaves that way, after which it just feels > poorly implemented. When a method is called in a <%= %> block, that part of the template gets filled in with a string representation of its return value. This behavior, as far as I know, is consistent across all method calls. If any one or two methods get special treatment, that's an anomaly (or exception, or special case, or whatever). That's all I mean. There is *already* a technical principle at work. [...] > I don't see this as being about adding "magic" to the implementation. > If you are of the mindset that the template is concatting to a string, > the puts idea doesn't make sense; but if you see it as printing to an > output stream (with the whole _erbout thing just being an > implementation issue), then the lack of a working print/puts is what > doesn't make sense. If you decide a priori that ERB is a failed implementation of something other than itself, rather than a successful implementation of what it actually is, then of course you will conclude that it needs to be changed :-) But I don't know of any reason to think that the _erbout design is a failed implementation of an output stream, rather than a successful implementation of a string buffer. (It's more than possible that I'm not familiar with all the past discussions and statements from the author(s) though.) In any case, I think the wind-up toy has hit the wall, and I'd like to turn it around so it can keep moving. I guess the main thing I'd like to see, if ERB is to gain a way to do the kind of streaming you're describing, would be for it to happen without loss: that is, without loss of consistency (don't just shoehorn the behavior into methods that already have a clearly defined behavior) and without loss of functionality (make sure that stringwise template-filling is not discarded or made difficult). David -- David A. Black dblack@wobblini.net