On 15/06/2015 20:51, Ben Franksen wrote:
>
> Ben Franksen <benjamin.franksen@helmholtz-berlin.de> added the comment:
>
> Hi Ganesh, don't bother. There is no better way to learn things than by
> trying to do them yourself. I spent some time today trying to re-shape
> removeRL along the lines of fastRemoveRL until I finally realized why
> this is impossible and there are two different functions for a reason:
>
> The trick with fastRemoveRL is that it relies on the meta data
> (PatchInfo) for the equality test. This makes sense because meta data
> is context independent and thus never changes when patches are commuted!
> But removeRL works on all patch types (i.e. including the anonymous
> patches that a named patch consists of). Thus removeRL must compare the
> actual patch data and this only makes sense if the contexts match up (on
> either the left or the right side), so it has no other choice than to
> commute every patch in the sequence to the end before testing for
> equality. This is of course slower, but that really can't be helped.
Doh! I guess I would also have discovered that the hard way...
> About the naming: "fast" isn't nice (why is is faster? why not always
> use the faster version?). So I have been thinking about a re-factoring
> that includes these functions in one of the classes (Commute?) so we
> would automatically get the (faster) specialization when using removeRL
> on a (PatchInfoAnd p).
One thought: PatchInfoAnd has a specialised MyEq instance that only
compares on the PatchInfo. But I'm not sure how to get from that to a
generic removeRL implementation that would be fast on PatchInfoAnd. I
had an half-baked idea involving commuting and laziness, but I don't
think it works because commuting can fail.
Ganesh
|