Req23: Make more keywords contextual

[This post is part of a series, "wish-list for future versions of VB"]

 

IDEA: Make more keywords contextual, rather than reserved. At the moment lots of words like "Event" and "Next" and "AddHandler" are reserved keywords. If you want to have variables or methods with these names then you have to put them in brackets, "[Event]" and "[Next]" and "[AddHandler]". We should change the compiler so it allows these to be used as identifiers in contexts where it's not ambiguous.

 

Doing this would help those of us who are re-implementing the VB compiler in VB! It would also help with things like WPF which has a method named AddHandler. Since VB is so English-like, the English-speaking programmers tend to run into clashes with VB more than they do with other languages. "Next" and "End" are particularly frustrating because they're such natural words do use for your own identifiers.

 

Incidentally, you can currently use all keywords as identifiers if they come AFTER a dot, e.g. it's fine to write "Dim x = Fred.Next" or "Dim y = MyClass.Of({1,2,3})". The only exception is "New", where Fred.New isn't allowed (except bizarely in the case of Enums).

 

Provisional evaluation from VB team: This is a nice idea, but it doesn't seem very important.