<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>You are right! </div><div>That means can keep the upper case name :-)</div><div><br></div><div>-Thorsten </div><div><br>Am 11.12.2015 um 23:43 schrieb Marc Knaup <<a href="mailto:marc@knaup.koeln">marc@knaup.koeln</a>>:<br><br></div><blockquote type="cite"><div><div dir="ltr">The type is still necessary in various locations:<div><br></div><div>Generics:</div><div><font face="monospace, monospace">let x = SomeGenericClass<SingletonObject></font></div><div><br></div><div>Type checking:</div><div><div><font face="monospace, monospace">let x: Any = SingletonObject</font></div></div><div><font face="monospace, monospace">let x: SingletonObject? = x as? SingletonObject</font></div><div><br></div><div>Passing the type dynamically:</div><div><font face="monospace, monospace">func foo(type: Any.Type) { … }</font></div><div><font face="monospace, monospace">foo(SingletonObject)</font></div><div><br></div><div>Since there can only be one instance the "object class" (if it isn't a struct) would be <font face="monospace, monospace">final</font>.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 11, 2015 at 11:34 PM, Thorsten Seitz <span dir="ltr"><<a href="mailto:tseitz42@icloud.com" target="_blank">tseitz42@icloud.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><span class=""><div></div><div><br></div><div>Am 11.12.2015 um 23:28 schrieb Marc Knaup <<a href="mailto:marc@knaup.koeln" target="_blank">marc@knaup.koeln</a>>:<br><br></div><blockquote type="cite"><div><div dir="ltr">Actually it's both - an object and a type. It's an object which describes itself.</div></div></blockquote><div><br></div></span>If it was a type then I would expect to be able to <div>- derive a subclass from it</div><div>- use it as type in variable or parameter declarations</div><div><br></div><div>I don't think either makes sense, or does it?</div><div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div>Btw. I have the same problem with enum cases. They're values so why are they uppercase?</div></div></div></blockquote><div><br></div></span>Hmm, good point. Guess I'm just used to it :-)</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Thorsten</div></font></span><div><div class="h5"><div><br></div><div><blockquote type="cite"><div><div class="gmail_extra"><div class="gmail_quote">On Fri, Dec 11, 2015 at 11:25 PM, Thorsten Seitz <span dir="ltr"><<a href="mailto:tseitz42@icloud.com" target="_blank">tseitz42@icloud.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div>I like it. Just a minor suggestion: as an object is a value and not a type it should have a name starting with lower case, i.e.</div><div><br></div><div>object globalResource { ... }</div><div><br></div><div>-Thorsten </div><div><div><div><br>Am 11.12.2015 um 23:07 schrieb Marc Knaup via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>>:<br><br></div></div></div><blockquote type="cite"><div><div><div><div dir="ltr">Hey guys,<div><br></div><div>I am working on a proposal which touches (and could even partially depend on) another interesting concept which I think would be a great addition for Swift.</div><div><br></div><div>Object declarations could be a way to declare a class or struct with exactly one instance. They are perfect for singletons, anonymous subclasses and to anonymously implement a protocol.</div><div><br></div><div>Here some examples how it could look like:</div><div><br></div><div><font face="monospace, monospace">// singleton</font></div><div><font face="monospace, monospace">object GlobalResource {</font></div><div><font face="monospace, monospace"> func doSomething() { … }</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">let resource = GlobalResource</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">// could all be the same</font></div><div><font face="monospace, monospace">resource.doSomething()</font></div><div><font face="monospace, monospace">GlobalResource.doSomething()</font></div><div><font face="monospace, monospace">GlobalResource.Type.doSomething()</font></div><div><br></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">// anonymous subclass</font></div><div><font face="monospace, monospace">class ViewController: UIViewController {</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> override func loadView() {</font></div><div><font face="monospace, monospace"> view = object: UIView {</font></div><div><font face="monospace, monospace"> // configure view</font></div><div><font face="monospace, monospace"> }</font></div><div><font face="monospace, monospace"> }</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">// anonymous protocol implementation</font></div><div><font face="monospace, monospace">protocol TapHandler {</font></div><div><font face="monospace, monospace"> func handleTap()</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">view.tapHandler = object: TapHandler {</font></div><div><font face="monospace, monospace"> func handleTap() {</font></div><div><font face="monospace, monospace"> // …</font></div><div><font face="monospace, monospace"> }</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace"><br></font></div><div><br></div><div>Kotlin is an example for a a modern language which uses this concept:</div><div><a href="https://kotlinlang.org/docs/reference/object-declarations.html" target="_blank">https://kotlinlang.org/docs/reference/object-declarations.html</a><br></div><div><br></div><div><br></div><div>What do you think about such an addition?</div></div>
</div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=1MXK54sosN3xru3iYcLt0oBZ2w20i49gyogXctgrspclYknWzz65r2qhsqfUzXb55e8dPbQJaRSSYVaFlHffez6g4VLtOrCkXCtmlLicv9OVE5R7sllNX1f7eZV1Uui5u0PCH0nK0pctWVFSkXpljT374GGF4gmc7sEVh9vBh74j4GkuPCyOD1cfUqYi9V-2Fw4inGvpUEd26VdLd6M1oQDZMdqkUjav-2FoIoGUqDI8OaY-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></blockquote></div><br></div>
</div></blockquote></div></div></div></div></blockquote></div><br></div>
</div></blockquote></body></html>