<div dir="ltr">It should already be possible to handle special cases like that since you can reässign self in an initializer. Here&#39;s a contrived example; would it allay your performance concerns?<div><br></div><div>```</div><div><div>struct Foo: ExpressibleByIntegerLiteral { </div><div>    private let value: String</div><div>    private static let zero = Foo(&quot;a really big thing&quot;) </div><div><br></div><div>    init(integerLiteral value: Int) { </div><div>        if value == 0 { </div><div>            self = .zero </div><div>        } else { </div><div>            self = Foo(String(value))</div><div>        } </div><div>    } </div><div><br></div><div>    private init(_ value: String) { </div><div>        self.value = value </div><div>    } </div><div>}</div></div><div><br></div><div>let x: Foo = 5   // value = &quot;5&quot;</div><div>let y: Foo = 0   // value = &quot;a really big thing&quot;</div><div>```</div><div><br></div><div>Given that, I definitely prefer the more natural literal expressibility to the words &quot;zero&quot; and &quot;one&quot;.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jan 25, 2017 at 10:45 AM David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">On Jan 25, 2017, at 10:03, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="gmail_msg"><br class="gmail_msg"></div><blockquote type="cite" class="gmail_msg">Stephen Canon wrote that Arithmetic should refine ExpressibleByIntegerLiteral because of certain mathematical properties of rings. In that case, 0 and 1 would just be spelled in that way. Otherwise, +1.<br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Wed, Jan 25, 2017 at 11:38 Anton Mironov via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">Hi everyone,</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I want to suggest a tiny extension to an Arithmetic protocol. It would be nice to have an additive identity and a multiplicative identity constants. Basically zero and one.</div><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">```</div><div class="gmail_msg">protocol Arithmetic {</div><div class="gmail_msg">  /* ... */</div><div class="gmail_msg">  static var zero: Self { get }  // additive identity: (value + .zero) == value</div><div class="gmail_msg">  static var one: Self { get }   // multiplicative identity: (value * .one) == value</div><div class="gmail_msg">}</div></div><div class="gmail_msg">```</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">These constants will ease implementation of math structures: vectors, matrices and etc.</div><div class="gmail_msg">I’m sorry if I’m duplicating someone’s suggestion. It is really hard to search for something in a long thread.</div></div></blockquote></div></blockquote><br class="gmail_msg"></div></div><div dir="auto" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">There is some merit in having them be declared as static properties... If it&#39;s a non-trivial process to initialize a type, it might be worth it to have a static property that either provides the storage directly or just returns a fileprivate value declared outside the type.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">- Dave Sweeris</div></div></div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>