Robert Van Dam wrote:
I've been attempting to create a tree in a lazy fashion and I'm more or
less getting the results I want with one minor exception. Currently,
I'm building nodes lazily with one node for each element of a list so:
Node = {RecordC.tell node}
for X in Xs do
Node^X = {MakeNode Foo Bar Baz}
end
fun lazy {MakeNode Foo Bar Baz} ... end
This works reasonably well but what I would prefer is to actually have
the branches created lazily as well. That is, I want the '^' operation
to be done lazily since currently I get something like
node(x1:_ x2:_ x3:_ x4:_ x5:_ x6:_ x7:_ etc ...)
but I would prefer to have
node(x1:foo(bar) x6:foo(bar) x19:foo(bar) ...)
where only the Xs that are eventually needed are ever added to the
record. [...]
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}
Luis
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users