Infer Generics, Implicit new and Significant whitespace


Good afternoon!

I made some suggestions on the Visual Studio section of the Uservoice site. Let's go through them in the order of controversy ;-)

Implicit new

My first suggestion is for a quality of life feature that I originally ran across in the Boo programming language: When referring to a class identifier, presume instantiation:

throw ArgumentException(); // read as `throw new ArgumentException()` since there's no `ArgumentException` method in scope, but there is a class

var banana = Fruit("Banana"); // read as `new Fruit("Banana")` since there's no `Fruit(string)` method in scope, but there is a class


https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/18043915-implicit-new

Infer Generics

My section suggestion identifies a common pattern in my daily life - I've been working with a lot of sequences (lists and dictionaries) in my Web, WebJob, hybrid web app and Bot projects. To make the C# language more attractive (for pythonistas and lovers of javascript) and competitive, allow for our compiler to infer common generic types:

var numbers = [1, 2, 3, 4, 5]; // numbers is an IEnumerable< int >
var letters = ['a', 'b', 'c']; // letters is an IEnumerable< char >
var strings = ["Hello", "World"]; // strings is an IEnumerable< string >
var objects = [3, letters, "please"]; // disparate types, so presume object; IEnumerable< object >
var iceCreamFlavours = list ["Cotton candy", "Chocolate", "Vanilla"]; // List < string >

// Optionally, defining list type with 'using' statement:
using list = System.Collections.Generic.List;

// Dictionaries!
var phrases = {{"Formal greeting", "Top of the morning to you!"}, {"Relaxed greeting", "Mornin'!"}}; // Dictionary< string, string >
var areaCodes = {{8, "Stockholm"}, {63, "Östersund"}}; // Dictionary< int, string >
var hashTable = {{0, 10}, {1, "A string"}, {2, phrases}}; // Dictionary< int, object >

https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/18043825-infer-generics


The Zen of C# - Significant whitespaces


Ready for my most controversial suggestion? It's the introduction of a compilation mode where the compiler infers a whole lot more - similar to the F# compiler. The mode could be activated on a per-file basis using one of these notations:

using zen
using significant whitespace
using option ...

... or somesuch. Then:



https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/18044161-zen-code-significant-whitespace

Thanks for taking the time to read through my post! Do you have any comments or ideas on my suggestions?
-
Thanks, BoltBait for teaching me how to expand selection in paint.net!

Comments

Popular posts from this blog

Auto Mapper and Record Types - will they blend?

Unit testing your Azure functions - part 2: Queues and Blobs

Testing WCF services with user credentials and binary endpoints