The using
keyword has three disparate meanings:
The documentation calls the first two definitions directives (which I'm guessing means they are preprocessing in nature), while the last is a statement.
Regardless of the fact that they are distinguished by their syntaxes, why would the language developers complicate the semantics of the keyword by attaching three different meanings to it? For example, (disclaimer: off the top of my head, there may certainly be better examples) why not add keywords like alias
and import
? Technical, theoretical, or historical reasons? Keyword quota? ;-)
Contrived sample:
import System.Timers;
alias LiteTimer=System.Threading.Timer;
alias WinForms=System.Windows.Forms;
public class Sample {
public void Action() {
var elapsed = false;
using(var t = new LiteTimer.Timer(_ => elapsed = true) {
while (!elapsed) CallSomeFinickyApi();
}
}
}
"Using" is such a vague word.
After language 'B', Dennis Ritchie came up with another language which was based upon 'B'. As in alphabets B is followed by C and hence he called this language as 'C'.
C was designed as a minimalist language to be used in writing operating systems for minicomputers, such as the DEC PDP 7, which had very limited memories compared with the mainframe computers of the period. The language was devised during 1969–73, alongside the early development of the UNIX operating system.
In 1978, Brian Kernighan and Dennis Ritchie published the first edition of The C Programming Language.
In 1978, Brian Kernighan and Dennis Ritchie published The C Programming Language, which would serve as the language reference until a formal standard was adopted.
Your question assumes 3 contextual meanings to 1 keyword is more complex than 3 different keywords with different meanings. Some may contest this.
In my years of C# coding, I can't say I've ever been confused as to the meaning of a 'using'; it's always clear from the context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With