-
Notifications
You must be signed in to change notification settings - Fork 2k
feature request: module
, namespace
or similar for grouping related classes and functions
#881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Could you give an example of exactly what you're proposing, in terms of either JavaScript output or the existing CoffeeScript this new keyword would replace? |
Sure thing. I should have done this already, but I was in a bit of a hurry.
would be approximately equivalent to this code using the current syntax:
and would therefore compile to something like this:
Hope that's clear. And not too ugly. I'm not sure if maybe the @Property |
For a recent, similar discussion, see #821. |
Fair deuce; I'll roll my own for what I need. :) |
It's also worth noting that the
It's also worth mentioning that Here's a good roll-your-own approach:
Not too bad, right? |
Oh wow, I completely missed the addition of executable class bodies in my excitement over default arguments. As for roll-my-own, here's what I did (targeted at the web, of course):
That way my namespaces/modules automatically get put into the global namespace (web browser of course), which is what I want in this case—and, if I declare the same namespace more than once, the new declaration is added to the old one instead of replacing it entirely. Yours looks prettier, though, and I might rework mine. |
Something kind of like Ruby's
module
or C++'snamespace
would be pretty useful for larger codebases.module Foo
should be roughly equivalent toFoo ?= { }
(so that multiple occurrences don't clobber previous classes and such) and declarations of classes within the module would follow as property assignments in the compiled JavaScript code.I'm not sure, but it might be advantageous to stick the module in the global namespace too. I suppose that could be left up to the developer with a compiler switch, though.
The text was updated successfully, but these errors were encountered: