TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Sweet.js – Hygienic Macros for JavaScript

76 点作者 ekzy将近 8 年前

9 条评论

jaywunder将近 8 年前
The last thing the JS community needs is macros IMO. From what I've seen in other languages, macros are difficult to maintain and document, and they add syntax constructs to languages that aren't supported by code highlighters. The difference between this and babel, is documentation. Babel is working off of a specification of how the language should work, whereas I doubt someone will document their macros as well as TC39 does the JS syntax
评论 #14697671 未加载
eatonphil将近 8 年前
Coming from a Scheme background, if there's one thing I can't believe we live without in Javascript, it's macros. Hell even C has macros... I've looked at Sweet.js a few times to add support for macros to the Linode Manager. Between m4, the gcc preprocessor, and something native, this seemed like the easiest potential sell. However, I've been turned off by how complicated this looks compared to any of the other options and I'm not sure it actually even supports the feature I want: allow some code to show up in "development" mode but for that code to not even exist in the compiled output of "production" mode. (The other feature that's just as important though is being able to wrap shared code up in a single function that gets compiled in at compile time, but I think Sweet.js supports that.)
评论 #14697260 未加载
评论 #14697666 未加载
couchand将近 8 年前
The in-the-wild code I've seen that uses Sweet.js has been atrocious. Of course I'm not saying that this is necessarily the case. I'd love to see some real world examples whter this is used effectively.
评论 #14697419 未加载
评论 #14698873 未加载
lmeyerov将近 8 年前
We were looking into sweetjs for adding cross-module contracts to the graphistry stack, but nixed the project when it became too much to generate code that passed our basic linters. TS largely scratches that itch, so we've been moving to that. I'm still hopeful though :)
lamlam将近 8 年前
I personally prefer MetaScript [1] as it&#x27;s comment based so JavaScript highlighters&#x2F;linters don&#x27;t have issues with it.<p>It is also essentially JavaScript so no special syntax had to be learned.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;dcodeIO&#x2F;MetaScript" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dcodeIO&#x2F;MetaScript</a>
longlho将近 8 年前
this is already covered in basically any AST transform systems (babylon, acorn, TS...)
评论 #14696663 未加载
评论 #14697077 未加载
评论 #14696818 未加载
devdad将近 8 年前
Can someone please explain macros, in an easy to grasp way?
评论 #14698532 未加载
评论 #14698364 未加载
评论 #14698710 未加载
评论 #14699864 未加载
评论 #14708613 未加载
alnitak将近 8 年前
What would hygienic mean in this context?
评论 #14698526 未加载
评论 #14699127 未加载
d--b将近 8 年前
Also known as: &#x27;how to build your own javascript dialect that you won&#x27;t be able to hire for&#x27;