<div dir="ltr"><div><div>I guess it may cause some confusion, but it's the standard term in functional programming too, e.g. <a href="https://wiki.haskell.org/Constructor#Data_constructor">https://wiki.haskell.org/Constructor#Data_constructor</a><br><br></div>Mihael, in Swift/T types and functions are in the same namespace so it isn't possible to have a function with the same name as a type.  <br><br>This is something else we should probably standardise on - does Swift/K has separate namespaces for functions and types?  I think we could solve the ambiguity by just having struct definitions automatically define a function in the function namespace.<br><br></div><div>Regardless, CamelCase is probably reasonable for user-defined types.  Thoughts?<br></div><div><br></div>- Tim<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 4, 2015 at 1:05 PM, Ketan Maheshwari <span dir="ltr"><<a href="mailto:ketan@mcs.anl.gov" target="_blank">ketan@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I would suggest we change the naming from constructors to something else as it has some associated OO connotations.</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, Feb 3, 2015 at 4:54 PM, Tim Armstrong <span dir="ltr"><<a href="mailto:tim.g.armstrong@gmail.com" target="_blank">tim.g.armstrong@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div><div>Hi All,<br></div>  While designing a location-aware feature for Swift/T Justin and I came across a scenario where we wanted to use Swift structs, but where it was very painful to assign each element individually.  To give you an idea:<br><br>type foo {<br></div>  int x;<br></div>  int y;<br><div><div>}<br><br></div><div>foo bar;<br>bar.x = 1;<br>bar.y = 2;<br><br></div><div>I'm looking at adding a feature where we can fill in a structs fields with a single expression.<br><br></div><div>We could do them the C-style way, but that doesn't allow us to use them without defining a new variable (the issue is that {} doesn't specify the intended type, meaning it needs to come from context):<br><br></div><div>foo bar = { 1, 2 };<br><br></div><div>I was thinking  that we should just have types function as named constructor functions.  There's precedent both in object-oriented languages and with Haskell's algebraic data types.  Now you can just use this expression wherever needed:<br><br>foo(1, 2)<br><br></div><div>Thoughts?  I'm reluctant to add new incompatibilities with Swift/K, but this seems like it would be really clunky otherwise.<span><font color="#888888"><br><br></font></span></div><span><font color="#888888"><div>- Tim<br></div></font></span></div></div>
<br></div></div><span class="">_______________________________________________<br>
Swift-devel mailing list<br>
<a href="mailto:Swift-devel@ci.uchicago.edu" target="_blank">Swift-devel@ci.uchicago.edu</a><br>
<a href="https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel" target="_blank">https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel</a><br>
<br></span></blockquote></div><br></div>
</blockquote></div><br></div>