Hacker Newsnew | comments | show | ask | jobs | submitlogin

Ah, but all of your compiled code is already wrapped in a safety function. (perhaps that's what Trevor was referring to). As for attaching to exports or window, that's going to have to be something that you do by hand regardless. If everything is added to the exports, then there's no point in wrapping in the first place...



Well, what I'd like to do is have e.g.

mymodule.coffee:

    x: 5
    y: (z) -> z * z
main.coffee:

    load("mymodule")
    puts mymodule.y(5)
I could set this up manually, of course, but if I wanted to do things manually I wouldn't be using CoffeeScript. :p

-----


Yes, I meant that the JavaScript "module pattern" is implemented by default, and the language prevents you from declaring globals by mistake. So, you get most of the benefits of the proposed JS module syntax.

-----




Guidelines | FAQ | Support | API | Lists | Bookmarklet | DMCA | Y Combinator | Apply | Contact

Search: