Initial support for custom parsed functions (boolean
, if
etc.)
#3079
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So basically this is a facility for functions with arguments not following the ordinal value parsing rules.
Two such functions added with this PR,
if
andboolean
(per #3019), i.e.:Known Issues / Questions / Needs-Decisions:
[1]
Surplus parens. Notice the boolean expressions (except logical ops, i.e.:
not/and/or
) require extra parens:This is because the code uses the parsing leaf of the
when
expressions and there the parens grew inwards quite deeply. Obviously this is ideally to be improved before release, so considering possible workarounds for now - related to #2807.[2]
Ruleset args and non-rule-value calls. Consider:
Well, this is not possible with this PR because returned DR values are not allowed (DR itself has no related code anyway) to do anything if appear naked at the block level. So to achieve above goal one has to do:
instead.
I'm going to enable the non-
@result
-bloating variant too by automatically expanding returned DR values for the ruleset level function calls, but for a moment it's a bit difficult due to ruleset evaluation code trickery. On one hand this would smell pretty much like a guesswork-behaviour (I usually oppose to), on the other hand - in this particular case, imho, - the auto-expansion would perfectly fit the original spirit of the #965 thing.After all, the very idea of
@var()
syntax came only to prevent@var;
ambiguity because inside mixins the ruleset is already assigned to a variable anyway. But for the abovediv { if(not(true), ...
code where no@var
is initially involved no such ambiguity can exist (unless I'm missing something) - so it will do basically just what's written: "ruleset-in -> set-of-rules-out".[3]
P.S. Ah, and yes, no space allowed between
if
and()
- this is quite annoying but it's basically a Less/CSS function requirement, we do not want to introduce a new parsing-concept/API-node just for that space, do we? (Hmm, on the other hand though, some quick and dirty hack to allow this won't be that difficult if necessary).