On 3/14/06, Luis Quesada <[EMAIL PROTECTED]> wrote:
> How about using RecordC.reflectArity and accessing the fields of the
> record with '^':
>
> fun lazy{CreateBranch Id}
> 'branch '#Id
> end
> T=tree(...) {Browse T}
> thread
> for Id in {RecordC.reflectArity T} do
> T.Id={CreateBranch Id}
> end
> end
> {Wait T^x1}
> {Browse T^x1}
I don't understand. What do you gain from wrapping the FOR loop in
another thread? This code seems to bind each field of T to a lazy
value, but only for fields which exist at the time the FOR loop is
started (since reflectArity doesn't update itself). When I run this
code, about half the time I get "tree(...)" and half the time I get
"tree(x1:'branch'#x1 ...). (It's nondeterministic because
reflectArity's result depends upon whether {Wait T^x1} has already
executed.)
Executing T^R = Val makes R needed (but not Val), so you can use ^ to
create lazy field values but not lazy features. As far as I know
there's no way to make a record create new features only as they are
called. Of course I would be pleased to learn if there was a way...
Max Wilson
P.S. Of course, you could give up on using records and use objects or
functions instead. An object O is more than capable of calculating
O(x1) if and only if someone requests it, then caching it for future
use, which is essentially how Robert is trying to use lazy trees. Or
so it seems to me.
--
Be pretty if you are,
Be witty if you can,
But be cheerful if it kills you.
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users