-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add missing "literal" specifier for key equality #996
base: main
Are you sure you want to change the base?
Conversation
I think this is the wrong fix? We don't define literal vs. non-literal keys anywhere to make the distinction here work. Moreover, we need to saying something about the value We have a note (which should probably be normative):
To this we need to saying something about how to have a literal that contains or consists solely of
We should also fix the location in syntax.md:
... probably by adding a note: Note The key value |
I think we should not rush this. My open issue has two sides:
The second one is the part that bothers me and I think is potentially confusing for users without any benefit. For casual user not reading the spec a lot of things are equal now (user reaction in bracket):
It's easy to explain that "everything is a string, and they compare as strings", and that would clarify the first 3 bullets. So no, I don't want to rush with a "fix" that enshrines the status quo. |
Do you have an alternative in mind? I ask because it is necessary to distinguish the catch-all key from all literal values, and the lack of quoting |
I see where you are coming from, but it isn't quite right. We provide quoting for literals whose unquoted forms would have different syntactic roles: |$a| is not syntactically the same as $a. I also disagree with the following statement:
That is incorrect. * is not a literal as a key value, any more than $a is a literal in the following.
and
A corrected statement would be:
|
My posted crossed with @gibson042 's. |
Replying to @aphillips:
The preceding paragraph does define catch-all key, and "literal key" is here used synonymously with something like "key consisting of a literal value". Also the first paragraph of this section concludes with this "A key can be either a literal value or the "catch-all" key
This formulation would be a bit misleading, as Replying to @mihnita:
It's not, though. It might be best to compare it to operands and option values, which can be either literals or variable references. Similarly, variant keys can be either literals or catch-all keys. |
I thing that a language well designed is something that one can read (and to a degree write) without knowing anything about any spec. So let's see what we have:
And also give me one other programming language where
And that is also unintuitive, to a degree.
The thing that breaks the "intuitiveness" for me I think are the numeric literals. Any attempt to explain the behavior to me by quoting the spec misses the point. |
@mihnita I'll ask again, do you have an alternative in mind? If you're arguing to remove unquoted literals you'll have sympathy from me, but unfortunately you won't get any further than that. |
Note that your examples would actually look like:
Most programming languages have syntactic quirks in which you need to escape certain things in order to use them.
"1".equals("1.0") == false ? Richard asked earlier and I'll ask again: what alternative do you propose? We don't have numbers or types and we do have a catch-all key. The string "*" has to be rare as a match value. |
Just to reiterate for @mihnita,
#996 (comment)
…On Mon, Feb 3, 2025 at 9:09 AM Addison Phillips ***@***.***> wrote:
@mihnita <https://github.com/mihnita>
Note that your examples would actually look like:
.match $something
|foo| {{ ... }}
foo {{ ... }}
* {{ this is always present }}
Most programming languages have syntactic quirks in which you need to
escape certain things in order to use them.
And also give me one other programming language where 1 != 1.0
"1".equals("1.0") == false ?
Richard asked earlier and I'll ask again: what alternative do you propose?
We don't have numbers or types and we do have a catch-all key. The string
"*" has to be rare as a match value.
—
Reply to this email directly, view it on GitHub
<#996 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACJLEMF7INGVPAKT5RZOCND2N6PEJAVCNFSM6AAAAABWKNF2FOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMZRGU4DKOBVGI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I am not sure if this is a joke :-) Those are strings, and look like strings. I would not complain AT ALL if in our case But Do you have an example where that is not the case? |
As identified in #995, the key comparison text should be specified to talk about literal keys, rather than all keys, as that's a bit misleading: Catch-all
*
keys are never compared to selector values, and they have only one source representation.