« Return to Thread: JSON.stringify replacer array semantics

Re: JSON.stringify replacer array semantics

by Oliver Hunt-2 :: Rate this Message:

Reply to Author | View in Thread


On Jun 5, 2009, at 11:24 AM, Allen Wirfs-Brock wrote:

> The effect of a side-effect of the stringify algorithm mutating the  
> replacer array is as well defined as any other side-effect sensitive  
> aspect of the algorithm, if the entire stringify algorithm is  
> strictly implemented as specified. A strict interpretation of the  
> current specification requires that the List in JO step 5.a gets  
> recreate on each use of JO. So side-effects that modify the replacer  
> array would result in different List contents.  I think it probably  
> is a good idea to move step 5.a into the top level stringify  
> algorithm so that the List is only generated once before any  
> possible side-effect producing operations.

json2.js appears to perform JO.5.a at the top level of the stringify  
so this makes sense.  Firefox also does the copy to an internal list  
on the entry to stringify, but performs toString conversion on each  
item in replacement for each object it calls.

--Oliver

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

 « Return to Thread: JSON.stringify replacer array semantics