-
Notifications
You must be signed in to change notification settings - Fork 856
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
Feature request: table alias #1017
Comments
I like this idea, but it raises some questions.
|
I'm not quite convinced. In this case, where the alias is just an alternative to the long name, why not use it instead of the long name in the first place? |
@ChristianSi even though I made this request I'm leaning towards your point of view as well now. One could workaround the issue without complicating the language with the following: [a]
name = "long_table_name_that_starts_with_a"
[a.field1]
null = true
options = ["a", "b", "c"]
[a.field2]
null = false
options = [1, 2, 3] |
I'll leave this open for one more day and, without more support, I'll close it. |
Thank you for posing this question. I'd like to revisit it someday, but I can open a new issue if necessary. I could see this being useful if you have an elaborate project config. In the Python world, it's possible to configure certain development tools within [@ruff = tool.ruff]
extend-include = ["*.ipynb"]
line-length = 100
python-version = "3.8"
[@ruff.lint]
extend-select = ["B", "F", "I"] |
I would prefer a way to refer to the parent table, for example with
This has been discussed before though, and was rejected. But that's a lot easier to use, because you no longer need to map table aliases to the actual names. I dislike aliases in things like SQL. It's probably also easier to implement in most cases. I think we need to wait until after 1.1 and newlines in inline tables, because what I suspect is that a lot of people will write it like:
Or at least, that's how I would write it. So that would also solve the problem, at least for this example. |
@arp242 Wow, you're describing a localized alias system that's suddenly brilliant in its simplicity! I was against the We don't need to name aliases for this to work! We start with a table section with key/value pairs defined the usual way, e.g. For as long as each table name begins with an Super quick rehash: With the examples above, we would immediately know that:
The elegance is beautiful, and I'm amazed and ashamed that it took me so long to realize it. There could be a variant that makes aliasing an explicit practice. My [@tool.ruff] # Note the additional `@`-sign.
extend-include = ["*.ipynb"]
line-length = 100
python-version = "3.8"
[@.lint] # And now we can use the `@` on its own, with a period and subtable names.
extend-select = ["B", "F", "I"] These approaches would be extremely reliant on the order of tables. But syntax highlighters could fade table names a little that use alias symbols. (Though the symbols would appear as prominent as the absolute names.) And for the use case described here, it would allow for a separation of concerns. Imagine IDEs permitting folding to conceal entire sets of tables that use the same alias. Pretty cool, hypothetically! And it would boil away another need for bloated inline tables. That would make several people happy. That would make me happy! @mcrumiller How would this compare with your suggestion? What do you think about all this? I know you decided to simply use shorter names, but users won't always have the option to change configuration keys quickly. What do you think? |
Yes this is absolutely fine and I love the suggestion. |
Previous discussion on that: #593, #744. Although I'm not strictly against it, personally I wouldn't be in favour of adding that though. "I would prefer that" meant "I would prefer having & over aliases", rather than "I would prefer if this gets added". Like I said, I suspect multi-line inline tables should solve things fairly well for most use cases. |
This comment was marked as abuse.
This comment was marked as abuse.
And "inline" has a second meaning in English. Quoting from one of the Oxford dictionaries, it also means "constituting an integral part of a continuous sequence of operations or machines". In TOML, it's clear that this is what is meant, because inline tables constitute a continuous block of text, between curly braces, as a table value. In fact, within an array, you could define two inline tables on a single line if you wanted. Nobody does that, but sensibility is hard to codify, and our minimal aesthetic compels us to avoid arbitrary restrictions. Our users can be more rigid than we allow them to be, and typically for their own sakes, they are. Anyway, table name aliasing and/or abbreviation play no part in how inline tables work, either ideally or practically. Wouldn't you prefer to expound upon the use of ellipses, or comment on any of the other proposals here? Or whether or not this exercise is worthy of our time, which I have assumed it is? |
This comment was marked as abuse.
This comment was marked as abuse.
@levicki. You know damned well what I'm talking about. I'm getting sick of this abuse. I should have spoken up more loudly when you blindsided me in #1019. And I regret having engaged with you as much as I have. So write a PR to revert what you don't like about changes to inline tables that were merged years ago after many more years of discussion (#516, #781, #904, and elsewhere). You will have free reign to make your case in your own thread. You just may come out of this a hero in the end. If you do it the right way. |
This comment was marked as abuse.
This comment was marked as abuse.
I could support either ellipses ( But unless we hear an outpouring of support for table aliases now, let's save the prospect for table aliasing after the release of TOML v1.1.0rc1. We can see what users prefer and act accordingly. Also, @pradyunsg, my apologies for blowing up the way I did in this issue. I will try to handle heated exchanges with a bit more grace in the future. |
I commonly have long-ish table names that represent, say, a database table, and I define fields within:
This is fairly unreadable, and it would be nice to alias tables, perhaps with the following syntax, or something similar
The text was updated successfully, but these errors were encountered: