Re: Prollyfills and the global namespace / multi-fills

On Wednesday, July 3, 2013 at 7:18 PM, François REMY wrote:

> > IMO, the right (™) way to do it is like Promises are done here (wrap in  
> > anonymous function):
>  
>  
>  
> Yes, of course you want to use a wrapper, I'm speak about what you export in  
> the global namespace here. In this case, Alex just expose "Promise" directly  
> into the global namespace. This is an issue because its implementation is  
> not what will be written in the spec.  

Yes it is, it's supposed to exactly match (as much as it can in JS).   
> He should use  
> "global.alexRussel.Promise" instead, because then when we use them we know  
> we speak about "Alex Russel's implementation of Promises"  

The goal of that project is to implement:
http://dom.spec.whatwg.org/#promises

It's not implementing "AlexRussel's promises". If it was, then I would agree.  

This is where you and I are speaking past each other: When I implement a prollyfill, I often implement a W3C spec. If there was no W3C spec, then yes! your rule of "don't put your dirty prollything-a-maggig into the global namespace!" applies :)  
> and if a browser  
> ever implements Promises, that won't conflict. Actually, because everybody  
> shipped with the name "Promise", the w3c was forced to use another name  
> ("Future") for the final implementation...

No, they changed again… it's promise:
http://dom.spec.whatwg.org/#promises

But they promised not to change it again in the future ;-P
  
> > Depends on who you are building it for.
> > If you are building it for a standards org,
> > then you want it to be as close to the
> > metal as it can be (See Promises prollyfill…
>  
>  
>  
> This is certainly not the number one use case of most developpers. If we  
> actually want to use on a real website (and most will want that), you need  
> prefixes.
>  
> That would not be that hard to do
>  
> var Promise = window.alexRussel.Promise;
>  
> at the top of your function to import the right things.
I want to be able to use window.Promise.whatever() like the real thing was there. I don't want to have to alias my code.  

--  
Marcos Caceres

Received on Wednesday, 3 July 2013 18:27:15 UTC