Do any #DotNet folks know why we still can't create static indexers for classes in C#?
What exactly are you looking for when you say "static indexing", do you mean syntatically Foo["Bar"] but dont care if in terms of implementation it is effectively the same thing... or do you mean an immutable index defined at compile time? If so how is that useful in any way as opposed to just an immutable index that is created at run time? I assume your trying to address a performance concern with generating the index whent he program first spins up?
Ahh so its a syntax limitation. You would effectively like a shorter syntax that would otherwise be functionally the same as a longer one.
Interesting. Yea I cant think of a good reason a language would prevent that.
@freemo Yeah, but you could easily get around it by replacing "this" in that static example with either the class name or the "operator" keyword. Either would make syntactic sense in this scenario.
@LouisIngenthron Oh I agree entierly.. its a weak excuse. Just the only one I can fathom one would argue at all.
I m,ean its clearly syntatical and not functional in nature cause we are basically just treating [] like a function. We are entierly int he land of syntatic sugar, so any explanation is going to be one that is purely hand waving.
@LouisIngenthron I guess the only reason that makes sense is that the format for doing it... like "this" makes no sense in the static context.... but why the word "this" is needed at all seems syntatic itself so seems the only reasoning is "this unusual syntax we choose is confusing in that scenario and we dont want to change the pattern"