The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
i have this one piece of code, and it is Bad Code(TM)
it certainly would not survive code review.
It deals with over a half dozen corner cases for disambiguating a parse of a field vs a type reference in C#
it keeps failing and I keep going back and adding another corner case.
such an anti-pattern
my hand rolled parser didn't try to handle this at all. it didn't like open typerefs with generic or array params so like
Console.WriteLine(int.Maxvalue); // ok but thinks it's a field ref of a variable
Console.WriteLine(System.Int32.MaxValue); // okay but same as above
Console.WriteLine(MyGenericType<int>.MaxValue); // won't parse
This parser is supposed to handle it but it's causing it to fail on field references. sometimes.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
No wonder the parser can't disambiguate it. They look the same. I can't see how to do it without first resolving names. Within C#, it looks like a type attribute (Maxvalue) masquerades as a field. So for C#, you could probably just treat it that way and get on with life. But if you want to generate the equivalent code in another language, I can see how it would be a PITA.
Last Visit: 26-Feb-20 10:48 Last Update: 26-Feb-20 10:48