Thanks John for pointing this. I read that section but seemed too obscure to me initially...
regards Carlos ----- Original Message ---- From: John van Groningen <[email protected]> To: Carlos Aya <[email protected]> Cc: [email protected] Sent: Sat, 28 November, 2009 12:59:16 AM Subject: Re: [clean-list] observers in your plans? Carlos Aya wrote: >Just curious if you have among the plans, implementation of so-called observer >types, i.e. variables that do not add as counting occurences. Clean already observer references, see section 9.4 of the reference manual. For example, size can be used in a guard or in a #! as an observer. >The problem with the following function ... > >doIt :: *(a e) (Int -> e) -> *(a e) | Array a e >doIt arr f = {arr & [i] = f i \\ i <- [0.. (size arr)]} > >... is that (size arr) counts as occurrence in the body of doIt, so arr cannot >be unique. But as seen in the _SystemArray implementation, size only reads the >size of the array which we know is fixed. So, truly its signature should be > >size :: 0:arr -> Int > >(I put 0: to indicate an "observed" parameter, out of my ignorance.. and based >on Odersky paper...) This should work: doIt arr f #! s = size arr = {arr & [i] = f i \\ i <- [0.. s-1]} or you could use usize instead: doIt arr f # (s,arr) = usize arr = {arr & [i] = f i \\ i <- [0.. s-1]} Kind regards, John van Groningen __________________________________________________________________________________ Win 1 of 4 Sony home entertainment packs thanks to Yahoo!7. Enter now: http://au.docs.yahoo.com/homepageset/ _______________________________________________ clean-list mailing list [email protected] http://mailman.science.ru.nl/mailman/listinfo/clean-list
