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.  The problem is I'm not sure I can do this with an implicit trigger since, with the use of RecordC, if I try to use Node.x12 and the x12 field has not been added to Node, the program will just suspend.  (I tried the following:

{ByNeed proc {$ X} {LazyCaret Node X} end Node.X}

proc {LazyCaret Node X}
     Node^X = {MakeNode Foo Bar Baz}
end

but was quickly meant with a suspended program waiting on Node.X, somewhat ironically considering what I was trying to do).

Can I do this in some other fashion with an implicit trigger or do I need to build in an explicit trigger in order to get the particular results I'm looking for?

Rob Van Dam

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to