-
Notifications
You must be signed in to change notification settings - Fork 415
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 for naming dependencies #950
Conversation
Actual, naming dependencies is trickier than I thought. Since you can also name template variables this way: Btw, since such named deps can be bound to variables. I'm thinking that we might need to do the expansion in stages. First expand user named dependencies, and then the other variables. |
The description of the feature looks good to me. Allowing We should allow
and the following dependencies:
we should obtain the following environment:
|
I'm not sure I understand what this does: does |
@diml I've added some validation for duplicate bindings. Okay, I think what you're describing is similar to what I said. @emillon In your example, you would create 2 bindings
Which seems more reasonable than using indices. |
Thanks, I see the use case now. Have you considered using an association list syntax?
Or a dedicated
I'm not particularly in favor of a particular one, but if it's a binding construct we can consider the alternatives. |
I like |
No, I haven't considered any alternatives apart from the I think that eventually we'll have to introduce a let construct anyways, but it seems quite heavy weight just for user rules. I'm not such a fan of |
And with that last note, I could probably make my implementation more generic by allowing for bindings in any list valued field:
Of course, the concrete syntax still remains under discussion. |
Duplicating every field does not look too great, indeed, so how would the concrete syntax for a
Some questions:
|
Actually my idea would to simplify have 1 named constructor where you can introduce both named and unnamed deps:
Although tbh, this doesn't really look convincing anymore and the original syntax suggestion is the same thing just with less clutter. |
I'm not a big fan of the nested Looking at this again, I prefer the original syntax. My thinking is as follow: filenames pretty much never start with BTW, I realized that we don't need the
If we wanted to exclude |
The problems I see with the short syntax is that it does not look like a binding, and is hard to search documentation for, since there's no keyword. But as long as it's documented in |
Would it be clearer if we used an equal sign? For instance:
|
IMO, the original syntax is more clean. It's also fairly intuitive for those who are familiar with elisp or the like where
Sure but I think that this kind of order dependence is a weakness of the syntax. Why can't have parens for grouping again. Looking back at the example you've brought up before:
I actually think that it should just be a constructor and an incorrect number of arguments should be an error. The user can easily just quote the constructor name to get around this and we could in fact include that point in the error message: "To use the constructor name literally, surround it with double quotes" |
I agree that the original syntax is cleaner. I don't have a particular opinion on the concrete syntax for lists. |
Actually, maybe avoiding the parens on the RHS is best. Neither the list constructor nor my suggestion are satisfactory. Doing something like |
Great, that's settled then. @rgrinberg do you consider that this feature is ready, modulo the last discussed changes? If yes, we can review it today and include it in 1.0.0 sine it's a nice addition, otherwise we should just make a PR to reserve the |
Yeah, I'd like to get it done today or this weekend. But there are other pre-reqs for 1.0 that need to be merged so let's focus on those before this PR. |
BTW, looking at the example I wrote before, we don't even need to re-order dependencies to exclude
However I'm not sure that's very clear. Another possibility is to allow parentheses around the bindings. Since we don't have constructors starting with
|
I like your last suggestion the most. Requiring parens around bindings seems acceptable boilerplate to me over adding things like artificial separators. If anything, I'd prefer if we added another form of braces specifically for lists. For example:
But I think surrounding the entire pair is a good compromise. The dummy variable idea is alright too, but I feel that it's too clever to be intuitive for users. |
Me too. Should we also allow this:
? i.e. we allow to bind at different levels. This can be useful to avoid duplicating a dependency. |
Yeah, I think it's fine. Though perhaps we should save it post 1.0 as I'd like to think about whether this cleverness will pay off. Also I'm wondering if we should change the meaning of |
Additionally if we get rid of |
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This preserves the order of things Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
We need to know the bindings statically whenever they overwrite existing vars Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Use a single map for both variables and percent forms Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
A last minute bug fix was necessary. I accidentally renamed |
This PR is WIP but I'd like to make sure we agree on the syntax before I clean things up and implement the rest.
@diml I've ended up not including a general
List
constructor inDep_conf.t
because I think nesting such a constructor would make things awkward. Instead, I only allowlist
as a "top level" constructor.Also, I made
(list ..)
available to unnamed dependencies for symmetric even though it's fairly useless there. I believe that if we have:x (foo bar baz)
and deleting:x
causing an error is a bit unnatural.Refer to the tests for what it currently looks like, as the implementation is still hairy.