[m-rev.] for review: add string.word_wrap/2

Julien Fischer juliensf at cs.mu.OZ.AU
Mon Mar 14 09:48:21 AEDT 2005


On Sun, 13 Mar 2005, Ian MacLarty wrote:

> On Sun, Mar 13, 2005 at 03:41:23PM +1100, Julien Fischer wrote:
> >
> > On Sat, 12 Mar 2005, Ian MacLarty wrote:
> >
> > > How do I adjust the NEWS file for this?  I don't want to include this in
> > > the 0.12 release, but it should go in the news for the 0.13 release.
> > >
> > Just put a temporary section at the top of the NEWS file on the main
> > branch. e.g. Changes since 0.12 fork, and put any changes there.  I'll
> > clean it all up closer to the release.
> >
>
> Okay:
> Index: NEWS
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/NEWS,v
> retrieving revision 1.375
> diff -u -r1.375 NEWS
> --- NEWS	25 Feb 2005 08:02:09 -0000	1.375
> +++ NEWS	13 Mar 2005 08:36:56 -0000
> @@ -1,3 +1,8 @@
> +NEWS since Mercury release 0.12.0:
> +----------------------------------

There cannot yet be any NEWS since release 0.12.0 because that's still
in the future.  I suggest saying since the 0.12 fork.

> > > +	% Wrapped is Str with newlines inserted between words so that at most
> > > +	% N characters appear on a line and each line contains as many
> > > +	% whole words as possible.  If any one word exceeds N characters in
> > > +	% length then it will be broken over two (or more) lines.
> > I think that you should be able to insert a hyphen between the two parts
> > of the word in this case.  (Perhaps, make this an optional argument).
>
> I don't think this'll be particularly useful since words that are longer than
> a line typically aren't real words anyway.

That rather depends on how large the line width is.  What if the user
sets it to say 16 (which is sensible in some contexts, e.g a small text
window) but still smaller than some real words.

> > > +		string.length(Str) =< N
> > It may be worth keeping track of the length of the strings as you go,
> > rather than recomputing it all the time.
> >
>
> I doubt it, since it won't be very often that a word needs to be broken up over
> multiple lines (with english text and a sensible line width at least).

Again, the notion of sensible line width is application dependent.  Since
you are putting this in the standard library, as opposed to the debugger,
I think that it should be as general as possible.

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list