-
Notifications
You must be signed in to change notification settings - Fork 446
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
Document special case - mixins return values #80
Comments
It makes sense.. I wonder where it is to be documented as so far we don't have any detailed "inter-scope" documentation. There're only very very basic "Overview:Scope" and "Mixins as functions". I also would love to have some more detailed scope documentation but for the moment there're a few dark corners (e.g. #1316) that make writing of such article not so easy (indeed, it's not always evident if something is a feature or an issue). |
I don't see the issue? That the property in mixin 2 is not set based on the assignment in 1 or 3? |
@matthew-dean, yes, taking lazy-loading into account someone would expect (in a perfect world) the result to be |
@matthew-dean You are right, that was bad example. Compilation result is good, because mixin1 hits global This one is better, I removed global variable definition:
compiles into:
If you try the same with same name mixins on one call, less.js throws in exception:
compiles into
Edit: This is real equivalent of the same on multiple calls:
It compiles into:
|
@seven-phases-max Pretty much yes, as a feature, quirk or wont fix :). It could go somewhere in scoping section. What would be scary is something like this:
It is hard to define, would be much useful (imho) and the only gain would be theoretical purity. So, I through we can simply define it as is, in easy to define and understand version. |
@SomMeri Btw., for the last example I think it should not work even theoretically (with or without default), i.e. assuming that expansion "rule" is:
and not:
I.e. I would expect it to behave more like Hmm, interesting... that points me to the fact that mixin argument list and its guard actually have their own scope which sits somewhere in between caller's scope and "normal" scope of the mixin itself. e.g.:
There's nothing really new but I did not think of that another scope from formal point of view before (e.g. #1316). |
@seven-phases-max I did not through about such "expansion rule", but it makes sense. Then it could be possible to make this "perfect" and fix instead of mentioning it in docs. I'm not saying it is worth effort, it may stay in "we will fix it once everything else is done and we are all old, retired and bored" category. |
On the general topic, we should be careful documenting behavior of Less.js which is not "designed". If it wasn't specifically built a certain way but just happens to exhibit strange edge cases, then we'd not want to imply that the behavior is supported (i.e. it could change). |
Mixins returned within one call do not see each others return values. This:
compiles into:
I briefly considered to file it as an "issue", but we do not have to over-complicate things. It is good as it is.
The text was updated successfully, but these errors were encountered: