-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dictionary literal (renamed from Supply default mapping class support with keyword and shorten ctor after discussion) #6965
Comments
You are free to add |
Man you forgot NetCore where it's planed to move from core. And if we speak about .net only you just underline that it's very common class. May be
May be you can say that where are any other Dictionary in core with such properties?
did you know that C# has not shared headers as C++? I don't want copy it everywhere. If you want to criticize - the only critics should be that did you know that ALIAS will not match my goal - read text - it should be IDictionary in all cases except of Man you just became my own throll-fish and post different disagrees without filtering. If you don't have expirience with working with legacy REST from C# or with code generation of mappers from JSON specifications or deal with Angular based client from C# - why you continue spam threads that cover this thematics? |
C# 7 is gonna be awesome. |
@comdiv Having multiple behaviors depending on whether or not "Legacy REST", that's a gem, really it is. How many REST services deployed on mainframes spitting out COBOL data files have you dealt with? I've dealt with more than I'd like to admit. Mapping to/from JSON or XML is a cakewalk in C#. Mapping several gigs of multi-format discriminated fixed-width with embedded dynamically-sized arrays in EBCDIC with packed decimals being vomited from a REST service, now that's fun. Some of those wire formats are government standards, too. |
I was hoping to see |
While i suggest keyword for dictionaries - "dict" can be breaker (it can overlap existed variable names) better - add not keyword but "dictioanry literal" that will be compiler-time casted to
It's good with ':' - so we can not provide ':' as '=' alternative in all context. But it can be transformed to 'dictionary literal request' - will rename issue. |
Syntax notion:
Production
So example:
|
It was some question about simialr in other threads:
so i think that dictionary literal is about
so may be it's better to translate
But while merging and extending is not very clear and can cause ambiguity (significantly) - think that we never will se such operations in language. While i'm using such semantics usually (extend, merge,deepmerge, setdefaults and so on) it's certainly not clear. |
We are now taking language feature discussion on https://github.com/dotnet/csharplang for C# specific issues, https://github.com/dotnet/vblang for VB-specific features, and https://github.com/dotnet/csharplang for features that affect both languages. |
After discussion of this issue it was transformed to :
Syntax notion:
Production
So example:
':' is required for it - it allow compiler ditinguish DOCLITERAL from invalid anonymous declaration with forgoten
new
, no mix of:It naturally support nesting
And it's compatible with JavaScript objects and close to JSON - so it simplify interop tasks (for example ElasticSearch/MogoDb query construction)
/////////////////////////////////////////////////////////////////////////////////////////////////
INITIAL ISSUE TO TRACE THINKING WAY:
Mappings are mostly used classes in JS/JSON/REST world and in any cases where we need to interop with them.
In .NET we have
IDictionary<string,object>
interface andDictionary<string,object>
class that behaves same way as JSON maps and JS object definitions and other similar things.So by the fact - it's mostly used thing.
But where are some problems -
IDictionary<string,object> + Dictionary<string,object>
are not in mscorlib. But it was not problem whenasync
ordynamic
or C omega support was added to C# while it's implementation based on various dependency beyond mscorlib and System, while System.Collection.Generic could be in reference path in any .net implementation - it's not real problem.So my suggestion: while it's so widely used - make C# more comfortable with it:
map
ordict
1a) it could be mapped wiselly - in declarations it will be
IDictionary<string,object>
and in creation it will beDictionary<string,object>
sodict x = new dict { ["x"] = 1};
should be treated asIDictionary<string,object> x = new Dictionary<string,object>{ ["x"] = 1}
dict void x (dict d)
should be treated asIDictionary<stirng,object> void (IDictionary<string,object> d);
new dict
optional, while left part of assigment (or argument definition) is knownit could be very JS/JSON close and simple to use with REST interop
The text was updated successfully, but these errors were encountered: