-
Notifications
You must be signed in to change notification settings - Fork 306
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
Struct Literals #201
Comments
@cjllanwarne I am for 1 or 2. |
Having chewed on it some more, I think braces
We might want to allow all (or some) of these syntaxes. One way or the other, I suggest sticking to a known constructor syntax. |
Good suggestions @cjllanwarne. I like proposal 3 and proposal 1. leading with the property you are setting is clearer to me in this case and allows some flexibility in terms of order when creating a struct. Additionally, I think these work better for complex type, since it becomes clearer what property is being set. Whereas leaving out the property it looks a bit muddled imo. struct A {
Array[Pair[String,File]] complex
Int i
}
workflow foo {
#Proposal 1
A a = A { complex: [{left:"string",right: "gs://abc"}, {left:"string", right:"gs://cba"}], i: 1231 }
#Proposal 3
A a = A ( complex: [{left:"string",right: "gs://abc"}, {left:"string", right:"gs://cba"}], i: 1231 )
#Proposal 2 (Dont like this as much)
A a = A { [{left:"string",right: "gs://abc"}, {left:"string", right:"gs://cba"}], 1231 }
#Proposal 4 (Dont like this either)
A a = A ([{left:"string",right: "gs://abc"}, {left:"string", right:"gs://cba"}], 1231 )
} |
@cjllanwarne not sure if you have had time to look at this, but WDYT? |
implemented by #297 |
Especially when working with structs, needing to type in
object
at struct-construction time is slightly counter-intuitive.As I was writing some of these out in test cases, I was thinking about more intuitive struct literals. Here are a few options:
A
as the constructor indicator instead ofobject
.{}
, 3 and 4()
i: ..., f:...
), 2 and 4 do not.Any other thoughts?
Side note: why do we need anything at all before the
{
at all? Because otherwise the expression evaluates as a map literal and the key is actually an expression eg:NB: I think this side-note could lead to unexpected errors for authors. In the winstanley IDE I intend to flag the above pattern (ie a Struct value being assigned from a map literal) as a warning with the suggestion being "use an object/struct literal instead".
The text was updated successfully, but these errors were encountered: