Language Support: Anonymous Derivations #1960
Labels
Area-Language Design
Feature Request
Resolution-Duplicate
The described behavior is tracked in another issue
Verified
Anonymous derivation for classes and interfaces, providing the illusion of direct instantiation of interfaces, base classes, etc.
Its is impossible to use the existing
new
operator without colliding with current semantics. But introducing another keyword has its own problems, and compatibilities issues. Instead, simply use the new keyword, but as the constraint form,new()
except that it takes an argument of syntaxtypeName { InitializationExpression }
where the expression similar to the class initialization syntax, except that, all functions, are described as expressions.The Funcs aren't really funcs. They get translated into real methods by Roslyn. This is only used for the expression definition.
The above is a compile-time factor. This can also be extended to be done at run-time with a new overload, that takes a
type
as parameter, there-by providing the language with direct interface instantiation-like semantics.The text was updated successfully, but these errors were encountered: