Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Syntactic sugar
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Syntactic salt === The metaphor has been extended by coining the term ''syntactic salt'', which indicates a feature designed to make it harder to write bad code.<ref>{{cite web |url=http://www.catb.org/jargon/html/S/syntactic-salt.html |title=The Jargon File - syntactic salt |date=2003-06-12 |access-date=2018-03-19 |archive-url=https://web.archive.org/web/20030612232319/http://www.catb.org/jargon/html/S/syntactic-salt.html |archive-date=2003-06-12}}</ref> Specifically, syntactic salt is a hoop that programmers must jump through just to prove that they know what is going on, rather than to express a program action. In [[C Sharp (programming language)|C#]], when hiding an inherited class member, a compiler warning is issued unless the <code>new</code> keyword is used to specify that the hiding is intentional.<ref>{{cite web|url=http://msdn.microsoft.com/en-us/library/435f1dw2.aspx|title=new Modifier (C# Reference)|publisher=Microsoft|work=microsoft.com|access-date=3 August 2015}}</ref> To avoid potential bugs owing to the similarity of the [[switch statement]] syntax with that of C or C++, C# requires a <code>break</code> for each non-empty <code>case</code> label of a <code>switch</code> (unless <code>[[goto]]</code>, <code>return</code>, or <code>throw</code> is used) even though it does not allow implicit ''fall-through''.<ref>{{cite web |url=http://msdn.microsoft.com/en-us/library/vstudio/06tc147t.aspx |title=switch (C# Reference) |publisher=Microsoft |work=microsoft.com |access-date=3 August 2015}}</ref> (Using <code>goto</code> and specifying the subsequent label produces a C/C++-like ''fall-through''.) Syntactic salt may defeat its purpose by making the code unreadable and thus worsen its quality β in extreme cases, the essential part of the code may be shorter than the overhead introduced to satisfy language requirements. An alternative to syntactic salt is generating compiler warnings when there is high probability that the code is a result of a mistake β a practice common in modern C/C++ compilers.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)