Open MarkMcCulloh opened 7 months ago
I like the idea of simplifying the syntax to use { key: value }
for both
When implementing this lets make sure punning works too, same as in json:
let a = 2;
let b = 3;
let y = MutMap<num> { a, b, c: 9 };
Let's go forward with this. This change will mean that to create a Map literal you will either need the Map<T>
type annotation now (or the object needs to be in a place where that type can be inferred) -- but I think it's worth it to unifying these syntaxes. Later we can add some syntax sugar like:
let x = map { foo: "bar" }; // Map<str>
let y = mutmap { bar: 123 }; // MutMap<num>
Use Case
Map<t>
literals in wing are confusing and not really needed. When you fist consider making something like a map, your first inclination is to:Without a type, this is of course a Json object. This typically isn't much of an issue because of Json's ability to be safely/easily coerced. Like struct literals, these can actually be coerced into Maps.
This works when passing a
{ ... }
object into a function expecting a Map as well. On its own I think this is sufficient reason to remove the verbose{ "key" => value }
syntax. We could go a step further and align this WithJson {}
andStruct {}
and allow this:Proposed Solution
No response
Implementation Notes
No response
Component
No response
Community Notes