Skip to content
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

implicit macros? #36

Open
hax opened this issue Nov 20, 2014 · 2 comments
Open

implicit macros? #36

hax opened this issue Nov 20, 2014 · 2 comments

Comments

@hax
Copy link
Contributor

hax commented Nov 20, 2014


:def video:auto-fallback
        source:type(*, attr(src))
        source:type(mp4, attr(src))

:implicit
  video { auto-fallback:on }

video @src=sample.webm
@HerringtonDarkholme
Copy link
Contributor

implicit macro能否用Jedi中的闭包完成?按照我猜的意思,这里自动给video标签加source的功能可以通过在闭包调用里加参数和条件判断完成。当然这样会需要多加参数会在书写上比较烦,如果闭包里能套闭包的话就能currying解决的话也可以。多引入一个implicit是否有必要呢?以及引入之后,implicit的作用域、implicit是否会引发可读性问题(如同一个标签在两个文件里表现完全不同等等)

@hax
Copy link
Contributor Author

hax commented Nov 21, 2014

目前类似auto fallback之类的转换要么是显式的写一个macro要么是hard code在编译的某个环节。这两个都不算好的方法。implicit确实有你说的问题,隐式的东西至少都有“可见性”的问题。但是本身auto fallback之类的需求就是希望一般开发者不要关心这个。你也可以看到例子里我加了个 :implicit 块来显式配置开启哪些宏,也是考虑到了可见性问题。

当然这个issue只是记录一下我想到的问题,未必就是好的解决方案。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants