Hi Bernd!
I'm not defending 'last_string' certainly (last_*, new* are nothing but
trouble frankly).
I much prefer your notion of a buffer, but the name 'read_buffer' is
very bad because it is a verb followed by a noun - this indicates to
most western language speakers that this is an imperative. This
confusion is further reinforced by all of the similarly named IO
features, like read_stream, read_integer, etc.
A name more clearly denoting a query is in order; perhaps
'buffer_content' or perhaps 'input_buffer_content' (though both input
and buffer can be considered verbs too), or maybe
content_of_input_buffer, just to send all of our keystrroke counting
friends over the edge.
What I don't want to see is existing code broken. It's as simple as
that. Eiffel users have been punished enough already.
If we want to deprecate last_string (and all the other last_* features),
I'm quite fine with that. For consistency, we would need to replace them
with queries of the form "*_as_integer" where '*' is whatever the actual
buffer contents gets named. For example, content_of_buffer_as_integer.
R
==================================================
Roger F. Osmond
> -------- Original Message --------
> Subject: Re: [eiffel_software] unexpected behavior of IO.read_line
> From: Bernd Schoeller <
[hidden email]>
> Date: Wed, November 04, 2009 7:20 am
> To:
[hidden email]
> Hi Roger,
> The name 'last_string' is bad. I do not think that a comment will
> rectify this. The comment is not present when the feature is used.
> The 'last_string' is not the last string. It is the same string. Naming
> it 'last_string' implies that there are also "non-last" strings. But
> there are not. 'last_string' is just a string buffer for the IO.
> The following code make it easy to explain the 'twin':
> io.read_string
> line1 := io.read_buffer.twin
> io.read_string
> line2 := io.read_buffer.twin
> With 'last_string', this just looks awkward. Good naming should make it
> possible to read code without having to go to the definition of its
> features (not that I am saying that this is always possible, but here it
> is).
> Bernd
> On 11/3/09 9:09 PM,
[hidden email] wrote:
> >
> >
> > Hi Bernd
> >
> > Actually, the irony comes from wanting to change the semantics of
> > last_string, but not the "traditional" name. We should keep the name
> > and semantics as they are, but provide a twin-ing function as an
> > alternative (hardly a techno stretch). No breaks, no whining, etc. All
> > that needs changing then (versus creating anew) is the documentation
> > that says how to use it. All old code (and old programmers) can remain
> > as they were. The original goal of leaving (potentially wasteful)
> > object creation to the user's discretion remains, so those who adore
> > copy semantics can have their way just as much as those who worship
> > reference semantics.
> >
> > last_string_read: STRING
> > do
> > Result := last_string.twin
> > end
> >
> > No big deal; No endless committee meetings, no broken code, no angst.
> >
> > R
> --
> Bernd Schoeller, PhD, CTO, Partner
> Comerge AG, Bubenbergstrasse 11, CH-8045 Zurich, www.comerge.net