![]() The C# compiler currently understands a dialect of the language used for various scripting and interactive purposes. In this dialect, statements can be written at the top level (without enclosing member bodies) and non-virtual members (methods etc) can be written at the top level (without enclosing type declarations). However, usage is picking up through Try.NET and other technologies, and I am concerned with being stuck with two incompatible dialects of C#.Ĭurrently the scripting version of C# isn’t heavily used, but Torgersen predicts that will change in the future, Usage of the scripting dialect has been relatively minor, and in some ways it hasn't kept up with the "proper" C# language. Not only is there Try.NET, but data-science and machine learning scenarios are also growing, and those tend to benefit from a much more direct - interactive mode of working with live data. Why then not just keep interactive/scripting C# separate? Because I think it is going to be useful to be able to roundtrip code between "experimentation" and "software development". If scenario 1 of this proposal is adopted, executable statements would be allowed to appear before a namespace declaration. Any such statements would be compiled into a Main function in a class named Program. This function would support asynchronous operations. If multiple files have executable statements outside of a namespace, then a compiler error will occur. Specifically, you would get multiple classes named Program with Main functions. Top-level functions would also be allowed under scenario 2. The functions can be declared within a namespace or globally. They would default to internal, though public would also be allowed. (This is already how functions work in Visual Basic modules.) Consumers would see the function as belonging directly to the namespace. The implementation would be that a partial class is generated to wrap the members as static members. ![]() The class name would probably be unspeakable, and would be chosen in such a way that the same name wouldn't be used twice in the same namespace across different assemblies. ![]() If any of the top-level members are public, the class would be public, and marked in such a way that a consuming assembly would know to expose the members directly.Ĭ# already has a scripting dialect, though it does differ from C# itself. The goal in this scenario isn’t to eliminate the scripting dialect, but rather move the two languages closer together. If we want to add top level statements and functions to C#, we don't want them to conflict with how those work in scripting. Rather we want to compile them in the requisite manner when necessary, but unify on the semantics of the features. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |