-
Notifications
You must be signed in to change notification settings - Fork 407
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
Syntax of variables in actions #778
Comments
What about supporting the new syntax in dune files and the old syntax in jbuild files? I agree with the change in general. Though I think we should keep support for the make aliases, even if we add user friendly aliases. |
That's a possibility indeed, and that should be easy to remember for users. I was initially thinking that the
That seems reasonable to me |
/cc @Chris00 as well since you have been looking at syntax quite a bit |
I am fine with
In my opinion, it depends which point of view we adopt. If it is to make the files easier to read for someone coming “from the outside”, then |
I tend to agree that having only one name is better. And
That seems good to me. 0-based or 1-based? :) |
Jérémie Dimino <notifications@github.com> writes:
That seems good to me. 0-based or 1-based? :)
0 based of course :)
|
BTW, with this change we will need a way to quote Technically this means that we will have to do the parsing of variables directly in the s-expression parser. This will require a bit of refactoring, however I think it is worth doing since it can't easily be done afterwards without breaking things. |
I'm a bit worried about that because usexp isn't for internal use only anymore. We expect users (such as those of configurator) to use it as well. I think they will be unpleasantly surprised by this complication. Another escaping scheme is |
BTW, someone mentioned that instead of indexes, we could also use names. For instance |
Yeah, that sounds like it will be fine as well. Would one be able to bind multiple dependencies to the same name? It's common enough for the set of dependencies to be made of 2 groups that you just want to pass to a different flag in the command. |
As long as we can have a nice syntax for it that seems fine. |
Closing this issue since the big part of the work has been done. The renaming of variabels is tracked by #842. Possibly one thing we should do before the 1.0.0 release is decide on a syntax for naming dependencies, so that we can at least reserve the syntax to avoid a breaking change. |
Why should we remove the indexed access then? If we don't implement named deps, then how would users access the first dep then. |
I think allowing list valued bindings should be enough |
We could add a
There is an ambiguity however: does |
Okay. It's just that in your comment you said instead of indexed lookups. I agree that having both is alright
Good point. I suppose we can just have a list constructor. In this case we won't even need a concept of list valued bindings. As a list would be a valid Dep_conf.t |
Good idea |
We recently had a discussion at Jane Street about the syntax of variables in the jbuild files read by Jenga. I think the problems raised apply to Dune as well, so I'm opening this ticket to discuss whether we think the same change is worth doing in Dune and if yes, how we should do it.
Current situation
Currently Dune expands a few variables in user actions. The syntax of variables is
${var}
or$(var)
. For instance:${CC}
or$(CC)
is replaced by the C compiler in use${@}
or$(@)
is replaced by the targets of the rule${bin:prog}
is replaced byprog
searched in thePATH
When a variable is unknown to Dune, it is left as it. The syntax and the behavior directly come from the Jane Street jenga rules.
Someone made the following remarks:
(bash "...")
or(system "...")
action, since the shell interprets these forms as well@
,^
or<
to denote targets and dependencies is fine for someone familiar to make, but it's not particularly clear otherwiseI think these remarks make sense.
Proposal
The proposal is to change the syntax to the following one:
%{var}
. Since this syntax is not used by shells, Dune can just fail when encountering an unknown variable.Additionally, we could do the following replacements to make things more explicit:
@
bytargets
<
byfirst-dep
^
bydeps
Opinions?
The text was updated successfully, but these errors were encountered: