Scriptcase multiple global variables3/10/2024 And if the Tiobe index is to be trusted it doesn't appear that C# is having too many issues attracting developers. If adoption and outreach are the goals I'd suggest that there are significantly better opportunities that don't result in creating dialects of the language. If they're trying to write this program from the command line they've already had to vault significantly higher hurdles. Perhaps a simple program should only be top level it really solve that problem, though? Sure, you might get "Hello World" off the ground faster, but for anything even slightly less trivial you're going to have to jump that same hurdle.Īnd does that hurdle really exist, even for beginners? Odds are that a beginner is starting from a tool like Visual Studio or dotnet new which writes all of that boilerplate for you. But I actually don't think this goes far enough. I strongly like the idea of simple-programs. For example, if i were to be able to have top-level statements that can be in scope for the rest of my program, then I absolutely would want to be able to make those top level variables readonly so they couldn't just be overwritten by the rest of my code. Second, it actually opens up large cans of worms for me. First, this isn't really 'simple' to me anymore. The moment we get to namespaces/classes/etc, we're no longer "simple" and i personally would prefer stating that they shouldn't mix.Īnother issue for me is that while this is pitched as 'simple programs' it seems to still allow the statements to coexist with namespaces/classes. A simple program is just statements and little funcs. Given that your goal is Proposal: Simple programs, i would say that there's actually no need for scoping to extend from teh statements elsewhere. However, it may just be an initial aversion that i coudl get over. both around 'args' as well as the scopes of variables introduced in teh statements that precede a namespace. The primary thing that bothers me here is scoping. In this way we protect our future ability to better address scenario 2, and are able to give useful diagnostics to users who mistakenly believe them to be supported. If one is picked by name look-up, it should lead to an error instead of being silently bypassed. This could lead to name collisions, ambiguous lookups and shadowing of imported names. Static class Program Scope of top-level parameters, local variables and local functionsĮven though the args parameter and top-level local variables and functions are "wrapped" into the generated Main method, they should still be in scope throughout the program, as if they were declared with internal accessibility in the global namespace.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |