>> How would a new object abstraction T customize them just for instances of T?
> 
> By writing its own custom iteration protocol via proxies with the iterate() 
> trap implemented appropriately. E.g.:
> 
>    function MyCollection() { }
>    MyCollection.prototype = {
>        iterator: function() {
>            var self = this;
>            return Proxy.create({
>                iterate: function() { ... self ... },
>                ...
>            });
>        }
>    }

I left out the last step: clients would then use this via:

    var coll = new MyCollection();
    ...
    for (var x in coll.iterator()) {
        ...
    }

Dave

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to