and / or

John Meacham john at repetae.net
Tue Aug 19 06:48:07 UTC 2014


On Mon, Aug 18, 2014 at 11:34 PM, David Feuer <david.feuer at gmail.com> wrote:
> "and/cons" forall x y . and (x:xs) = x && and xs
> "or/cons"   forall x y . or (x:xs) = x || or xs

&& and || may be tiny, but inlining them a few hundred or thousand
times in one place gets big.
In general, open ended RULES like this can lead to a code explosion,
strings turn into really long lists that if one of these RULES gets
ahold of it it will turn your constant string into a huge amount of
code even if they are just inlinings of && and ||.

If the RULES are just restating the branches of the function, then the
compiler already has that information at its disposal to decide
whether to inline.

A better idea is a worker wrapper split, where the wrapper pulls of a
single argument (for when you know the list has at least one entry)
and the worker takes the extra argument and can be written in a very
fusible way and code expansion potential is capped.

    John


-- 
John Meacham - http://notanumber.net/


More information about the Libraries mailing list