Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is params keyword not contextual?

The reason I ask is, it's only valid in method parameter declaration, isn't it? I was trying to make a variable inside the function body called "params", but of course this is not a big deal, just wondering the reason MS chose to make it a global keyword and not contextual.

like image 812
Joan Venge Avatar asked Jan 05 '11 21:01

Joan Venge


1 Answers

The same could be asked about any other keyword. For example, why isn't "class" contextual since it's only used in class declarations?

To me a keyword is a keyword. I imagine it greatly simplifies the lexical analysis part of compilation to not have to be THAT context aware.

As an aside, you can use the @ symbol to allow you to declare a variable called 'params' (or any other reserved keyword):

var @params = new int[] { 1, 2 };
like image 102
Adam Lear Avatar answered Sep 20 '22 15:09

Adam Lear