On Oct 26, 2007, at 5:11 PM, James Clark wrote:
Calling the second relationship "like" seems strange to me. An
object that stands in the strong relationship to a type is just as
like the type as an object that stands in the weak relationship.
The canonical term (both in theory and in real programming languages,
e.g. C#) for the strong relation is "is", not "like".
See the overview generator example for a pretty combination of the two:
function fringe(tree) {
if (tree is like {left:*, right:*}) {
for (let leaf in fringe(tree.left))
yield leaf
for (let leaf in fringe(tree.right))
yield leaf
}
else
yield tree
}
Try it:
let tree = { left: { left: 37, right: 42 }, right: "foo" }
for ( let x in fringe(tree) )
print(x)
It prints 37, 42, and "foo".
In Firefox 2, you can do exactly this example minus the is like test.
Instead some ad-hoc property-detection is required. See attached.
/be
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss