Skip to content
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

Improve delimited identifier syntax #1269

Open
hasithaa opened this issue Oct 17, 2023 · 4 comments
Open

Improve delimited identifier syntax #1269

hasithaa opened this issue Oct 17, 2023 · 4 comments
Labels
Area/Lang Relates to the Ballerina language specification design/usability Design does not work well for some tasks Type/Improvement Enhancement to language design

Comments

@hasithaa
Copy link
Contributor

hasithaa commented Oct 17, 2023

With #656, we are using Option I described #243 (comment);

We have noticed an increased usage of this syntax in URLs for services, particularly those that include underscores, such as foo\-bar\-baz. One piece of feedback from users indicates that readability is compromised when more special characters are present in the identifier due to the escape characters.

A viable solution could be improving the quoted identifier syntax for this purpose. For example, by using 'foo-bar-baz'.

@jclark @sameerajayasoma @shafreenAnfar thoughts?

@jclark jclark added Area/Lang Relates to the Ballerina language specification design/usability Design does not work well for some tasks labels Oct 18, 2023
@jclark
Copy link
Collaborator

jclark commented Oct 18, 2023

Is the user problem specifically in resource paths?

Changing syntax for identifiers generally is going to be very constrained by compatibility issues. There's more scope for a more flexible syntax specifically in resource paths (in resource method definitions and resource-access-action), because they are occur in contexts where arbitrary expressions are not allowed. The cost would be another lexical mode.

@hasithaa
Copy link
Contributor Author

Is the user problem specifically in resource paths?

Yes,

@jclark
Copy link
Collaborator

jclark commented Oct 18, 2023

It would be difficult to extend the syntax in the client-resource-access-action, because that occurs nested within other constructs and isn't always followed by an opening parenthesis, so a resource-method-name can be followed by an operator.

But within a resource-method-definition, there is more flexibility.

The relevant URL syntax is:

psegment       = *[ uchar | "?" | ":" | "@" | "&" | "=" ]
uchar          = unreserved | escape
unreserved     = alpha | digit | safe | extra
safe           = "$" | "-" | "_" | "." | "+"
extra          = "!" | "*" | "'" | "(" | ")" | ","

which gives these characters not allowed in identifiers but allowed in URL path segments ?:@&=$-.+!*'"(),

I see two characters there that won't work:

  • ( because it starts the function signature;
  • ' because it has a meaning of starting a delimited identifier.

Another possibility would be to support a completely different syntax approach to resource-path based on backticks. This might tie into #1238.

@jclark
Copy link
Collaborator

jclark commented Oct 18, 2023

Another possibility is to allow the user to provide the HTTP listener with a split function that the HTTP listener will call to split the URL into segments, instead of/in addition to splitting the URL into segments as defined by the URL spec.

@anupama-pathirage anupama-pathirage added the Type/Improvement Enhancement to language design label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Lang Relates to the Ballerina language specification design/usability Design does not work well for some tasks Type/Improvement Enhancement to language design
Projects
None yet
Development

No branches or pull requests

3 participants