[darcs-devel] darcs patch: Replace colour by color to uniformise a ... (and 7 more)
Nicolas Pouillard
nicolas.pouillard at gmail.com
Wed Apr 23 14:49:35 UTC 2008
Excerpts from David Roundy's message of Wed Apr 23 15:28:25 +0200 2008:
> Hi Nicolas,
Hello,
> Thanks for your response. I'm now applying all these patches--with an
> additional one to make the default be to not color hunk contents, since I
> find it too much myself.
Great! I find colored patches a lot easier to read, but I know that this kind
of things is highly user dependent.
> On Wed, Apr 23, 2008 at 02:08:10PM +0200, Nicolas Pouillard wrote:
> > > > hunk ./src/Darcs/ColourPrinter.lhs 211
> > > > -make_bold :: Doc -> Doc
> > > > -make_bold x = unsafeBoth "\x1B[01m" (packString "\x1B[01m")
> > > > - <> x
> > > > - <> reset_color
> > > > +-- memoized version of make_color'
> > > > +make_color Blue = make_color' Blue
> > > > +make_color Red = make_color' Red
> > > > +make_color Green = make_color' Green
> > >
> > > I don't see how this achieves any memoization... and perhaps that's the
> > > reason why your code seems to be a regression. Can you explain how this
> > > occurs?
> >
> > Because something like "make_color' Blue" is a pure constant expression, it
> > will be then floated as constant, like in:
> >
> > __make_color_Blue = make_color' Blue
> > ...
> >
> > make_color Blue = __make_color_Blue
> > ...
> >
> > I'm pretty sure to haven't lost the optimization, because loosing seems to
> > leads to stack-overflows.
>
> This is still a bit mysterious to me, but I'm now satisfied that you've
> done your homework. I still wonder if there's a way this could be done
> more clearly, but without too much extra work. That is to say, in a way
> that it's obvious that sharing is going on even in the absence of tricky
> optimizations (or at least ones that seem tricky to me). With just a few
> additional lines we could float these constants ourselves. What do you
> think?
I think that there is no problem to rely on this optimization, that's very
common in this kind of languages, however being forced to manually memoize
them shows me that in this case one should perhaps give them names. The
problem with adding names is that this tend to pollute the mind of the
reader.
--
Nicolas Pouillard aka Ertai
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
Url : http://lists.osuosl.org/pipermail/darcs-devel/attachments/20080423/74b4c173/attachment.pgp
More information about the darcs-devel
mailing list