couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: CouchDB 1.1.1
Date Thu, 06 Oct 2011 08:55:28 GMT
On Thu, Oct 6, 2011 at 3:29 AM, Dirkjan Ochtman <dirkjan@ochtman.nl> wrote:
> On Thu, Oct 6, 2011 at 10:25, Paul Davis <paul.joseph.davis@gmail.com> wrote:
>> +1 on removing the paren hack for sure.
>
> Can you elaborate on what the paren hack is?

Unfotunately, SM 1.8.5 breaks the ability to evaluate anonymous
functions at global scope. So all CouchDB code examples are
effectively broken. The "fix" is to wrap the function in parentheses
to trick the parser into returning the anonymous function. Ie,

Given a standard CouchDB map function like:

    function(doc) {
        if(doc.my_type) emit(doc.my_type, 1);
    }

The "fix" is to do:

    (function(doc) {
        if(doc.my_type) emit(doc.my_type, 1);
    })

However, if people are using helper functions at global scope, it
turns into this:

    (var f = function() {return 2;};

    function(doc) {
        if(doc.my_type) emit(doc.my_type, f());
    })

Which is an error on all versions of SpiderMonkey.

Basically, SpiderMonkey got stricter about following the spec by hard
coding a check for the exact type of anonymous function declarations
that CouchDB has relied on (unknowingly in my case) for years.

>
>> Not sure about removing 1.8.5 support completely. On the one hand, it
>> would prevent breakage because people couldn't link against the
>> breaking SM. On the other hand, it prevents people from linking
>> against 1.8.5 which means it won't build on Ubuntu 11.x.
>
> That seems problematic. With my packager hat on, I would also prefer
> if 1.8.5 support came sooner rather than later.
>
> Cheers,
>
> Dirkjan
>

Mime
View raw message