Deprecate =
in assignments, aliases, and exports in favor of :=
#413
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.
This PR adds
:=
as a synonym for=
in assignments, aliases and exports, and adds a deprecation warning=
in those same contexts.The deprecation warning looks like this:
Since this is a disruptive change, I'd like to go over the rationale, just in case anyone is curious.
Currently,
=
is used in assignments, aliases, exports, and default arguments:The just language doesn't have keywords in the conventional sense, so the parser uses lookahead to disambiguate conflicting constructs.
However, lookahead is limited and messy, and some conflicts cannot be resolved. So for example, these constructs fail to parse:
Also, there are additional constructs that I'd like to add that will produce further conflicts, like settings.
In order to fix this, there are a few options:
A. Use more lookahead to disambiguate expressions
B. Use a token other than
=
to introduce default arguments to recipesC. Use a token other than
=
in assignments, exports and aliasesUsing more lookahead, as in A, gets messy very quickly, especially as it's extended to longer and more complex constructs, which would limit extension of the grammar in the future, so I think ruling that out is reasonable.
B is reasonable, but I don't think that there is a good alternative to
=
for default argument values.:
is already used to end recipe argument lists.On the other hand,
:=
is a good alternative for assignments, exports, aliases, and a futureset setting := value
notation.:=
is used inmake
, whichjust
is most similar to, and is also used for assignment in Go and Algol. So, I think C is the best choice.My current plan is to release this as
v0.4.3
, and follow up after some time has passed with a version, probablyv0.5.0
that removes the old meaning of=
. I don't know what the most popular ways of getting just are, but I'd like to give v0.4.3 a chance to appear in package managers so that nobody is in the unfortunate situation of needing to run the same justfile on< 0.4.3
and>= 0.5.0
, and not having a construct available that will work on both.I was thinking of supplying a
--fix
flag, as I mentioned in #379, but just's current parse-and-dump functionality re-orders constructs and strips comments, so using it to implement fixup functionality would be harder than I thought.