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

x/talks: possible mix-up of semantic and syntactic #21065

Closed
stemar94 opened this issue Jul 18, 2017 · 4 comments
Closed

x/talks: possible mix-up of semantic and syntactic #21065

stemar94 opened this issue Jul 18, 2017 · 4 comments

Comments

@stemar94
Copy link

stemar94 commented Jul 18, 2017

The 2012/splash.article says:

The first example was a -r (rewrite) flag on gofmt itself, which uses a simple pattern-matching language to enable expression-level rewrites. For instance, one day we introduced a default value for the right-hand side of a slice expression: the length itself. The entire Go source tree was updated to use this default with the single command:

gofmt -r 'a[b:len(a)] -> a[b:]'

A key point about this transformation is that, because the input and output are both in the canonical format, the only changes made to the source code are semantic ones.

What did you expect to see?

the only changes made to the source code are semantic syntactic ones.

For me this sentence feels like there should be stated "syntactic" instead of "semantic" since the semantics of the code doesn't change by applying the transformation.

@gopherbot gopherbot added this to the Unreleased milestone Jul 18, 2017
@gopherbot
Copy link

CL https://golang.org/cl/49570 mentions this issue.

@robpike
Copy link
Contributor

robpike commented Jul 18, 2017

No! The original is correct. Syntax is preserved is the point.

In future, please ask the original author to review something like this before submitting.

@stemar94
Copy link
Author

I'm confused.
Then why are language features like these called syntactic sugar?
Probably we just have different view points concerning the transformation and how this should map to the sentence in the article.

@robpike
Copy link
Contributor

robpike commented Jul 19, 2017

The point is that the process guarantees correct syntax (and formatting) before and after. Any substantive change reflects deeper issues.

@golang golang locked and limited conversation to collaborators Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants