Open AnthonyDGreen opened 7 years ago
Random thought of undetermined quality: What if ? <expression>
was simply an alias for the invocation Print( <expression> )
, and Imports
was extended to be able to alias Print
to any single-parameter method or property, like Imports Print = Console.WriteLine
?
Just a note: The target of ?
isn't trivial to decide. There could be >1 possibility, with drastic consequences: 😃
'Developer types the following:
? $"LOG: Checking user input against real password {User.Password}"
'Compiler converts to:
Debug.Print($"LOG: Checking user input against real password {User.Password}") 'Okay idea
Console.WriteLine($"LOG: Checking user input against real password {User.Password}") 'Not so okay idea
Response.Write($"LOG: Checking user input against real password {User.Password}") 'BAD idea! :-)
I know there is a tendency to resist adding new keywords; however, not really a new keyword, just enhancing one that already exists...
Option Print Console (default) Option Print Debug Option Print Response Option Print Log (????)
Even without this I believe it should be Console and if that isn't "good enough", then you still have the ability to fully qualify as we do today. I say this as ? = Print = historically output to the console. I do see that this could possibly be enhanced by being able to "override" this behavior using a new Option Print feature... but overall, for me, the value would be more for writing Console applications. With that said, I could also see that there could be two different "defaults". In Console applications, ? = Console.Write/WriteLine (do we need to also support the semicolon?). In WinForms, Debug.Write/WriteLine and in ASP.NET, Response.Write… With even more thinking, could this be determined based on the Imports for the project file? If you Imports System.Console… ? uses Console. (Still needs more noodling...)
Thanks.
Making a different comment... I think ? should support both Write and WriteLine... this could be done through the use of an ending semi-colon (as it once did). Furthermore, I don't think it should require the use of parens…
? "something or somesuch"
versus
?("something or somesuch")
By not requiring the parens, the use of semi-colon on the end feels more natural and can be the queue for whether or not to new line. With semi-colon, Console.Write()… without the semi-colon (default), Console.WriteLine().
Building on the scenario of #102 there's another thing that might be simplified--basic output.
Today in the Immediate Window a user can type
? <expression>
to print the value of that expression. This doesn't work in normal VB though it did work in VB6 and earlier as well as QBasic. We already parse this but the parser only excepts it legally in .vbx files.What problem does this solve? Knowing what the correct way to printf debug in context. Depending on the app type it could be correct/preferred to:
and I'm sure there are several others. If we could somehow tie this into .NET's debug or trace listeners could we abstract away all these variations?