[clean-list] Semantics of selectors and projection functions

Vag vag.vagoff at gmail.com
Tue Mar 3 15:39:02 MET 2009


Hello All!

Addison-Wesley book and in Clean 2.1 Specification state that selector
patterns are translated to projection functions. But (without strictness
analysis and using small heap) test1 terminates ok but test2 fails with out
of heap error. How it must be explained in semantics?

Start = test4 [0..100*1000*1000]

test1 xs = case ab of (_,_) -> n
where
    ab = decouple1 xs
    (a,b) = ab
    n = xsum 0 a xs

test2 xs = case ab of (_,_) -> n
where
    ab = decouple1 xs
    a = first ab
    n = xsum 0 a xs

decouple1 [x:xs] = (x,xs)

first (a,b) = a

xsum 0 a xs = xsum 1 a xs
xsum n a [x:xs] = xsum (n+1) a xs
xsum n a [] = a + n
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.science.ru.nl/pipermail/clean-list/attachments/20090303/374b4100/attachment.html


More information about the clean-list mailing list