<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>Sent from my iPad</div><div><br>On Dec 18, 2015, at 8:11 PM, Stephen Christopher &lt;<a href="mailto:schristopher@bignerdranch.com">schristopher@bignerdranch.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><span class=""><br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div style="font-size:14px;font-family:helvetica,arial,freesans,clean,sans-serif;line-height:1.6;padding:30px;background-color:rgb(255,255,255);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;margin:15px;outline:0px;border:0px"><p style="margin:0px 0px 15px">When do properties with behaviors get included in the memberwise initializer of structs or classes, if ever? Can properties with behaviors be initialized from&nbsp;<code style="margin:0px 2px;padding:0px 5px;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;color:rgb(51,51,51)">init</code>&nbsp;rather than with inline initializers?</p></div></div></div></blockquote><div>&nbsp;There’s a separate discussion that mentioned allowing better control of which initializers are generated or synthesized for a given struct. There’s also been mention of a “derived” feature for adding conformance without needing to supply a separate implementation. This question seems related to me - it would be ideal if Swift had a coherent way to declare something that did not need definition because it can be generated by the compiler. In this case, to declare that a property is part of memberwise initialization. `behavior lazy&lt;T&gt;: memberwise {` ?</div></div></div></div></blockquote><div><br></div></span><div>You might be talking about the initialization discussion I was involved in a week or so ago.&nbsp; I'm working on a proposal that would allow for more flexible control over synthesized memberwise initialization.&nbsp; I'm hoping to have a draft ready soon.</div></div></blockquote><div><br></div><div>Great! Looking forward to reading it.</div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><br></div><div>Is your example here part of a behavior declaration for lazy which states that properties with the lazy behavior may be memberwise initialized?&nbsp; That's what it looks like to me.&nbsp; I think syntax like that would make sense.&nbsp; There are some behaviors which would need to opt out.&nbsp; Somewhat ironically, I think lazy is one of them as the whole point of it is that it is not initialized immediately, but rather on first access.</div><div><br></div></div></blockquote><div>Yes, that was the idea behind that syntax. Hah, lazy was a terrible example, you’re right. Distracted emailing never ends well.</div></div></div></div></div></blockquote><div><br></div>I've had a couple incidences of distracted emailing on the list myself! &nbsp;I hope to learn from those mistakes and not repeat it again. :)<div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>It could be either opt-in (as my example hinted). Opt-out might be a bit harder to express, and I’m not sure if opt-in is the right default.&nbsp;</div></div></div></div>
</div></blockquote><br></div><div>I think opt-in is the right default for behaviors as it conflicts with the semantics of some behaviors.</div><div><br></div><div>I don't think a property with a behavior that *allows* memberwise initialization should be required to support it just because the behavior does. &nbsp;Part of my proposal discusses properties which cannot be memberwise initialized because of access control restrictions or because they have an @nomemberwise attribute. &nbsp;This might not make a lot of sense without seeing it in the context of the proposal, but it should once I have the draft ready to share.</div><div><br></div><div>Matthew</div><div><br></div></body></html>