couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Smith (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (COUCHDB-1302) Fix couchjs
Date Thu, 06 Oct 2011 03:12:32 GMT

    [ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13121691#comment-13121691
] 

Jason Smith commented on COUCHDB-1302:
--------------------------------------

Couch Javascript are expressions, not statements. Everything is an implicit var map = eval(ddoc.views.by_name.map).
You put function expressions in them. Helpers must go in inside. If helpers don't fit in new
couchjs, that can't be helped. It is not a breaking change so much, except that couch permitted
a convenient but severe syntax error and now it doesn't.

One can also argue that the place for helper code is CommonJS modules.

We discussed parsing JS with uglify.js and identifying the final function defined. This allows
unmodified ddocs to work. But developers communicate to CouchDB extremely implicitly and through
an invisible mechanism. It feels like "being an enabler."

Assuming uglify.js can do it, how would you feel about a correction tool which converts bad
code to good code? We could test it in the real world as a couchapp or web service that converts
bad ddocs to good ddocs. If it works well, maybe even bundle it into couchjs and couch could
be told to correct the errors. When asked, couch could feed the design doc to couchjs with
the uglify fixer tool and update the ddoc with the correction. Maybe /_config/couchdb/fix_my_js
= true. The fix could run when ddocs are read, or perhaps saved, or who knows! even during
compaction.

This is a crazy idea but IMO less crazy than permitting invalid Javascript that upstream code
has sought to eliminate. To me the best trade-off is to mark it in the change log and provide
third-party tools to correct ddocs.
                
> Fix couchjs
> -----------
>
>                 Key: COUCHDB-1302
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1302
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: JavaScript View Server
>    Affects Versions: 1.1.1, 1.2, 1.3
>            Reporter: Paul Joseph Davis
>            Priority: Blocker
>
> Figure out why some spidermonkeys have an error when doing: eval("function(){}")

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message