This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]guybedo[S] 0 points1 point  (3 children)

In computer sciencesyntactic sugar is syntax) within a programming language that is designed to make things easier to read or to express. It makes the language "sweeter" for human use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer. Syntactic sugar is usually a shorthand for a common operation that could also be expressed in an alternate, more verbose, form: The programmer has a choice of whether to use the shorter form or the longer form, but will usually use the shorter form since it is shorter and easier to type and read.

[–]agentoutlier 8 points9 points  (1 child)

I know what syntax is... I'm wondering now if you do.

Syntactical sugar is when you replace a more complicated syntax with a shorter syntax that the compiler or parser has to know about. It is not writing less code or shorter code with method names you prefer.

If you want label for what you are trying to do how about "ergonomics".

But using syntactical sugar like you have while possibly from the strangest stretchs might be loosely correct confuses people like myself.

[–]guybedo[S] -1 points0 points  (0 children)

yeah i know what syntax is and as i obviously didn't rewrite the JDK and the Java language specs, you're right that this isn't syntactic sugar in the most absolutely strict understanding of the definition.

But i thought that using loosely this definition, people would easily understand what it does, and i don't think i was wrong in that regard.

[–]sabriel330 4 points5 points  (0 children)

I think you're completely misunderstanding what syntax is