|
This can be valid c#
public class var
{
async async async(async async) => await async;
}
|
|
|
|
|
yick. Fortunately, I don't have to support any of those keywords, but i need to check to see if my stuff will parse that.
Edit: The compiler chokes on the async specifiers
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.
|
|
|
|
|
because async / await etc are new(ish) keywords there might be code out there which has types named "async", "await" so the C# compiler does context tests for new keywords - in the example I gave some are keywords, some are types (which I omitted)
|
|
|
|
|
Yeah but in this case, the compiler I'm using (c#7? VS2017) bombs on that statement you gave me.
I know about contextual keywords as I've parsed C# quite a bit, and LINQ and other language additions have forced it. I've watched the keyword list in C# grow over time, and some old keywords like __stackalloc finally given life in the latest incarnations of the language
But async will break in the context you used it. I'm not sure about C# compilers before it was a keyword
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.
|
|
|
|
|
You need to create types with those keywords and not use var anywhere
|
|
|
|
|
Like in Fortran IV where you can have an integer named REAL and a REAL named COMPLEX. No reserved words.
Or you could name your function SOLVE REAL PROBLEM. Spaces are ignored.
I don't know if these are still valid in modern variants of Fortran; I haven't written a single line of Fortran for 30 years.
(C.A.R Hoare, in the Fortran-77 discussions, stated "I don't know what programming languages will look like in year 2000, but they will be named 'Fortran'" - when I saw a few Fortran 2003, my immediate reaction was: He hit the nail on the head!)
|
|
|
|
|
PL/1 didn't (and probably still doesn't) have any reserved words either
|
|
|
|
|
|
Won't matter to me as it will never be supported by the CodeDOM =)
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.
|
|
|
|
|
They don't buzz, but they are definitely insects! (7)
HUMBUGS[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Urgh.... so obvious once you know the answer.
I gathered it would be some sort of confectionery, but the sweet shop was just too large!
|
|
|
|
|
I'm really glad it was "obvious with the answer" - means it wasn't impossible!
So ... I'm up tomorrow ... :EvilLaugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Simple and Difficult at the same time.
Knew it was something sweet but was focusing on Honey for some reason
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
super wrote: was focusing on Honey for some reason
He's busy playing with nested classes.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
That's the problem with honey, once you are in it's difficult to get out.
|
|
|
|
|
In C#, this is valid:
class A<T> {
class B<TT> {
}
}
therefore, this is valid:
typeof(A<int>.B<int>)
The trouble is, there's absolutely nothing out there online I can find about representing such a nested generic typereference as a CodeTypeReference properly.
Which leads me to an arcane comment in Microsoft's reference sourcecode - the last hope of the desperate.
while (current >= 0)
{
if (typeName[current] == '[')
{
if (--unmatchedRightBrackets == 0) break;
}
else if (typeName[current] == ']')
{
++unmatchedRightBrackets;
}
else if (typeName[current] == ',' && unmatchedRightBrackets == 1)
{
if (current + 1 < subTypeNameEndIndex)
{
subTypeNames.Push(typeName.Substring(current + 1, subTypeNameEndIndex - current - 1));
}
subTypeNameEndIndex = current;
}
--current;
}
So now I get to figure out what this is doing, just so I can figure out how to properly use what it is implementing.
Microsoft Docs: Technically correct, but practically useless.
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.
|
|
|
|
|
I don't think that's quite the same thing is it?
The MS one is a Dictionary<string, List<int>> which isn't really "nested" in the same way as yours is.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Yeah you know, i figured that out about a minute ago. *headdesk*
which led me to this
var c = new CodeTypeReference();
c.BaseType = "A`1+B`1";
c.TypeArguments.Add(new CodeTypeReference("System.String"));
c.TypeArguments.Add(new CodeTypeReference("System.Int64"));
Console.WriteLine(CD.ToString(c));
which led me to figuring out kind of how it works, but it isn't pretty.
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.
|
|
|
|
|
honey the codewitch wrote: you know, i figured that out about a minute ago
"Great minds" and all that.
Or "fools seldom differ" - your choice!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I think that's a perspective thing. I feel like the C# language spec is laughing at me right now.
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.
|
|
|
|
|
Quote: Microsoft Docs: Technically correct, but practically useless. Still far better than most of the 'competitors' ones.
|
|
|
|
|
While you're not wrong, that's more of a blanket condemnation of the industry than anything.
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.
|
|
|
|
|
Yes, I know that.
|
|
|
|
|
Did you not mistake [ for ] ?
|
|
|
|
|
nope. that's microsoft's code
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.
|
|
|
|