-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Allow Semicolon as Function Argument Separator #1505
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
But mixins are a less concept where as functions exist in css (and cannot |
What exactly would be the benefit of having semi-colons as separators? |
The reason I raised the issue is just for internal consistency—not because it made some new feature possible. The point about the shared syntax with CSS functions is a good one though. |
@Soviut You could easily pass comma separated lists into them e.g. the same reason why there are semicolons in mixins. There are plans to make functions pluginable so it is not hard to imagine that some people might create lists manipulating functions then. For example, the |
With the merge of |
Should I remove the "Consider Closing" tag? (Maybe consider leaving open?) |
See #2270 for a real use-case example where semi-colon separaters in a user-defined function would be necessary, or at least desirable. (The "each" example passes in a CSS list.) |
just a thought… |
@chharvey What you say sounds logical, but would be a bit of a challenge. In the first stage of evaluation, Less is only parsing your code. Evaluation of functions only happens after you have a complete tree. Which makes sense, if you think about it, because a custom function can receive an entire ruleset, spanning multiple lines and property / value pairs (and arguments). When functions are evaluated, Less.js checks to see if there's a matching function name within the current scope. If not, it outputs the function as is. When it writes CSS, the operation happens in reverse, with arguments output with comma separators. However... I think mixin nodes are already marked as having comma or semi-colon separators, so maybe the same could happen for functions. So that: if a Less function is not found during evaluation AND the function has semi-colon separators, then Less could throw an error. |
The initial idea was actually to not have distinction between two (just because both CSS and Less function-sets are not something set in stone). So parser does not and cannot have any distinction between those. More over some CSS functions (e.g. P.S. Ah, @matthew-dean is faster :) But anyway keeping my comment just for "in other words". |
@seven-phases-max Looks like we commented at the same time. The parser wouldn't know if they're valid, but could mark the type of separator. |
Does not look like something useful since it can't cover 0..1-parameter functions anyway. Besides, some (radical purists like me) not just do not favor So to target that problem (e.g. throw a error for |
No, no, not forced. Never forced. The request is actually just as an option. And you misunderstood. Less would not throw an error for |
Yes, but if I'd want to use that nice new feature ("throw a error if Less function is not found") I would have to use semicolons (and could not get the same with commas) :) But never mind, I get what you mean in general. |
Ohhh okay, now I get what you mean. Ha, yes. This is true. Which is probably why we should pass on that idea. I was just spitballing how Less could distinguish Less/CSS functions, as @chharvey was suggesting, but yeah, it's probably better to avoid that. |
Optional semi-colons in functions are supported in Less 2.7.0. |
Since semicolons are the recommended way to separate arguments for mixins, it seems to me that it would be a good idea to allow them to be used for functions as well.
The text was updated successfully, but these errors were encountered: