-
Notifications
You must be signed in to change notification settings - Fork 339
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
FR: Make special forms not look like functions #4921
Comments
(I suspect this also applies to |
Interestingly,
I took a look at the fileset language just now as well, but it seems to be simple enough that there's no unusual functions for now. |
Sorry, I meant to say “in templates”. We don’t have Fatal errors aren’t necessarily a semantic problem as long as the language semantics are consistent with non‐strict evaluation (at most, perhaps |
Here's another weird quirk which seems related: you can have a revset alias like this which uses an argument as both a commit ID and a number: [revset-aliases]
"test(cond, n)" = "coalesce(cond & n, ancestors(@, n))" If |
FYI, another oddity is that referring to a hidden commit makes it temporarily visible in some ways. For example, if |
Is your feature request related to a problem? Please describe.
Most functions in the revset language are pure and referentially-transparent. You can evaluate them in any order and produce the same result, and substitute any expression for its resolved value without changing the result of the entire query.
Currently, there's one exception:
at_operation(op, rev)
is not referentially-transparent, since the result of evaluatingrev
depends on the result of evaluatingop
. You can't evaluaterev
separately, then substitute its literal contents as the operand toat_operation
and be guaranteed to get the same results.Describe the solution you'd like
There should be a syntactic distinction between "special forms", which indicate non-referentially-transparent computations, to avoid potential user surprise. It might also make script authors more likely to generate robust revset expressions as parts of queries, since it'll be more obvious that you can't just splice expressions textually in all cases.
Possible future special forms:
@
operator (which, incidentally, doesn't seem to be in the revset docs?). Since it's an operator, it's probably less surprising that it has unusual evaluation semantics.git
.set()
syntax form.hidden:
modifier here, which would be similar toat_operation
if it were implemented (although it doesn't seem likely): Rebasing (and some other operations) is confusing for hidden commits #4544 (comment)Describe alternatives you've considered
Some ideas:
at_operation
only would be too much overhead.foo(bar(at_op(baz): qux()))
.!
; we could writeat_operation!(<op>, <rev>)
instead.@
operator.jj
already had--at-op
when theat_operation
function was requested.)Additional context
at_operation
was originally created to address FR: revset syntax to resolve an expression at an old operation #1283 and implemented in revset: add at_operation(op, expression) #4614.The text was updated successfully, but these errors were encountered: