<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div>First a general question: Are these behaviors also allowed on normal variables in function bodies (regarding the current proposal)?</div><div><br></div><div>----------</div><div><br></div><div>The "<b>initialValue</b>" should be exposed as closure/function since it can introduce side effects:</div><div><br></div><div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; var [resettable] y = functionWithSideEffects()</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">According to your proposal: "If the behavior includes an&nbsp;<em style="box-sizing: border-box;">initial value requirement declaration</em>, then the identifier&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">initialValue</code>&nbsp;is bound as a get-only computed property that evaluates the initial value expression for the property"</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">So if I understand it right if I reset "y" "functionWithSideEffects" gets executed.</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">------------</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div>Can you explain what is the difference between "<b>Self</b>" and "<b>Value</b>" in the following example?:</div><div><br></div><div><div>protocol Fungible {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; typealias Fungus</div><div>&nbsp; &nbsp; &nbsp; &nbsp; func funge() -&gt; Fungus</div><div>}</div><div><br></div><div>var behavior runcible&lt;Value where Self: Fungible, Self.Fungus == Value&gt;: Value {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; get {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return self.funge()</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>}</div></div><div><br></div><div>Isn't "Self" the same as "Value"? So it can be rewritten to:</div><div><br></div><div><div><span style="background-color: rgba(255, 255, 255, 0);">var behavior runcible&lt;Value: Fungible, Value.Fungus == Value&gt;: Value {</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; get {</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return self.funge()</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">}</span></div></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">----------</span></div><div><br></div><div>You've wrote that <b>behaviors shouldn't be types/type-like</b> e.g. "var x: lazy&lt;Int&gt;".</div><div>Can you mention some disadvantages?</div><div><br></div><div>I can't see huge ones. However I don't see any advantages.</div><div><br></div><div>Is there any advantage regarding a type-like behavior?</div><div><br></div><div>---------</div><div><br></div><div>I just remembered recursive value types...</div><div>We can even eliminate another keyword: "<b>indirect</b>"</div><div><br></div><div>implementation:</div><div><br></div><div>var behavior indirect&lt;Value&gt;: Value {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; class Ref&lt;T&gt; {</div><div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; var value: T</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; init(_ value: T) { self.value = value }</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; var reference: Ref&lt;Value&gt; = Ref(initialValue())</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; get { return reference.value }</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; set { reference.value = newValue }</span></div><div>}</div><div><br></div><div><br></div><div>I'm glad you made it so far :)</div><div>- Maximilian</div><div></div></body></html>