c# - verbosity of yield syntax -
i have interesting question. according msdn yield syntax:
yield return <expression>; // yield value yield break; // exiting iterator
why not just:
yield <expression>; // yield value return; // exiting iterator
to me second form less verbose , still have same meaning first. question - why first form chosen .net designers ? reasons may caused ? potential design problems second form has ?
here's 1 possibility: create technical ambiguity (remember yield
contextual keyword, not reserved keyword)... unlikely, but:
struct yield {}
then
yield x;
is variable declaration. "yield return x;", valid 1 way.
no idea if true. thought.
Comments
Post a Comment