[Pharo-dev] About cr and lf

Damien Pollet damien.pollet at gmail.com
Fri Aug 4 14:23:25 EDT 2017


On 4 August 2017 at 18:52, Peter Uhnak <i.uhnak at gmail.com> wrote:

> On Fri, Aug 04, 2017 at 03:41:05PM +0200, Damien Pollet wrote:
>
> > Stream >> newLineForWindows "convenience for the most common platforms
> > Stream >> newLineForUnix
> > Stream >> newLineForHistoricReasons
>
> Practically speaking this looks insanely wordy. In 102% (est.) you want to
> use the same consistent newline and not thinking about for which platform
> you are writing every time you want to write a new line.
>

Hmm, granted :)


> I think that most WriteStream miss what MultiByteFileStream has --
> lineEndConvention.
>
> fileStream lineEndConvention: #lf.
>

Agreed.


> fileStream cr. "<- this will be autoconverted to #lf"
>

No… please don't abuse a low-level explicit selector to mean something
context-dependent.

Also I would like to see a situation where you actually _want_ to use
> different line endings at the same time, so converting lf/cr to the global
> one shouldn't break things.
>

But it's ugly…


> So maybe instead of stating what kind of line ending you want to write,
> you would specify them for the whole stream
>
> > Stream >> newLineForWindows "convenience for the most common platforms
> > Stream >> newLineForUnix
> > Stream >> newLineForHistoricReasons
>
> Stream>>beForCurrentPlatform (would be the default maybe?)
>
> Stream>>beForWindows "crlf"
> Stream>>beForUnix "lf"
> Stream>>beAnnoyingOutsideOfPharo "cr"


Yes, I actually prefer that to my own proposition, just don't make #cr and
#lf contextually put something else than their name implies.

#newline (or #nl if you prefer it concise) should be the contextual message

-- 
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20170804/833000d4/attachment.html>


More information about the Pharo-dev mailing list