[clean-list] unique record fields (mk II)
Ilya Shpitser
ilyas@CSUA.Berkeley.EDU
Wed, 6 Jun 2001 12:30:32 -0700
Hello,
Thank you everyone for replying, the bit about partially applied functions
inheriting the uniqueness attribute from their arguments makes sense.
I have another question (really basic this time):
What is a Clean idiom for destructive updates of fields deep in some tree-like
data structures.
The example I am trying is updating an array element of an array that's a
field of some record with some function of that array element.
I first tried something like:
{ record & array.[index] = function record.array.[index] }
This doesn't work, I am guessing because there are two references to the
array in this expression.
After reading the language report for a while I tried:
{ record & array.[index] = function (fst (fst record!array)![index]) }
This didn't work either, I am guessing for the same reason (though
references are not named in this case).
Then I tried something like:
{ record & array = { array & [index] = function array.[index] }
where
(array, record) = record!array
This also doesn't work. I think I am missing the idiom. Also, how would
this work in general when the unique field is really deep in the data
structure, and has to be updated to some function of itself?
Thank you in advance,
Ilya
P.S. There was mention of generic programming in reference to the Clean 2.0
compiler. Does that mean that there are plans to treat representations of
graphs as first class objects in Clean, something you can type and pass
around to functions? That would be very useful indeed!