<html><head><style>
body {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        padding:1em;
        margin:auto;
        background:#fefefe;
}
h1, h2, h3, h4, h5, h6 {
        font-weight: bold;
}
h1 {
        color: #000000;
        font-size: 28pt;
}
h2 {
        border-bottom: 1px solid #CCCCCC;
        color: #000000;
        font-size: 24px;
}
h3 {
        font-size: 18px;
}
h4 {
        font-size: 16px;
}
h5 {
        font-size: 14px;
}
h6 {
        color: #777777;
        background-color: inherit;
        font-size: 14px;
}
hr {
        height: 0.2em;
        border: 0;
        color: #CCCCCC;
        background-color: #CCCCCC;
display: inherit;
}
p, blockquote, ul, ol, dl, li, table, pre {
        margin: 15px 0;
}
a, a:visited {
        color: #4183C4;
        background-color: inherit;
        text-decoration: none;
}
#message {
        border-radius: 6px;
        border: 1px solid #ccc;
        display:block;
        width:100%;
        height:60px;
        margin:6px 0px;
}
button, #ws {
        font-size: 12 pt;
        padding: 4px 6px;
        border-radius: 5px;
        border: 1px solid #bbb;
        background-color: #eee;
}
code, pre, #ws, #message {
        font-family: Monaco;
        font-size: 10pt;
        border-radius: 3px;
        background-color: #F8F8F8;
        color: inherit;
}
code {
        border: 1px solid #EAEAEA;
        margin: 0 2px;
        padding: 0 5px;
}
pre {
        border: 1px solid #CCCCCC;
        overflow: auto;
        padding: 4px 8px;
}
pre > code {
        border: 0;
        margin: 0;
        padding: 0;
}
#ws { background-color: #f8f8f8; }
.bloop_markdown table {
border-collapse: collapse;
font-family: Helvetica, arial, freesans, clean, sans-serif;
color: rgb(51, 51, 51);
font-size: 15px; line-height: 25px;
padding: 0; }
.bloop_markdown table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
.bloop_markdown table tr:nth-child(2n) {
background-color: #f8f8f8; }
.bloop_markdown table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
.bloop_markdown table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
.bloop_markdown table tr th :first-child, table tr td :first-child {
margin-top: 0; }
.bloop_markdown table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }
.bloop_markdown blockquote{
border-left: 4px solid #dddddd;
padding: 0 15px;
color: #777777; }
blockquote > :first-child {
margin-top: 0; }
blockquote > :last-child {
margin-bottom: 0; }
code, pre, #ws, #message {
word-break: normal;
word-wrap: normal;
}
hr {
display: inherit;
}
.bloop_markdown :first-child {
-webkit-margin-before: 0;
}
code, pre, #ws, #message {
font-family: Menlo, Consolas, Liberation Mono, Courier, monospace;
}
.send { color:#77bb77; }
.server { color:#7799bb; }
.error { color:#AA0000; }</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="bloop_markdown"><p>I know that, but I couldn’t describe it better. I mean implicit casts are already there and do look the same:</p>
<pre><code class="swift">class A {}
class B: A {}
let someA: A = B() // this works fine
protocol C {}
class D: C {}
let someC: C = D() // this works fine too
</code></pre>
<p>Sure it depends on the context, but the implicit cast functionality could be extended on my opinion. </p>
<p>I build a little prototype to be able to automatically cast math expression.
It looks something like this:</p>
<pre><code class="swift">let someDouble = Double(UInt(0) + Int(1)) // + is overloaded
// sometimes the compiler complains so I need to write this
let someDouble = Double(UInt(0) + Int(1) as Expression)
// it would look better if we had implicit conversion enabled trough constructors
let someDouble: Double = UInt(0) + Int(1)
// or
let someDouble: Double = UInt(0) + Int(1) as Expression
</code></pre>
<p></p></div><div class="bloop_original_html"><style>
body {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        padding:1em;
        margin:auto;
        background:#fefefe;
}
h1, h2, h3, h4, h5, h6 {
        font-weight: bold;
}
h1 {
        color: #000000;
        font-size: 28pt;
}
h2 {
        border-bottom: 1px solid #CCCCCC;
        color: #000000;
        font-size: 24px;
}
h3 {
        font-size: 18px;
}
h4 {
        font-size: 16px;
}
h5 {
        font-size: 14px;
}
h6 {
        color: #777777;
        background-color: inherit;
        font-size: 14px;
}
hr {
        height: 0.2em;
        border: 0;
        color: #CCCCCC;
        background-color: #CCCCCC;
display: inherit;
}
p, blockquote, ul, ol, dl, li, table, pre {
        margin: 15px 0;
}
a, a:visited {
        color: #4183C4;
        background-color: inherit;
        text-decoration: none;
}
#message {
        border-radius: 6px;
        border: 1px solid #ccc;
        display:block;
        width:100%;
        height:60px;
        margin:6px 0px;
}
button, #ws {
        font-size: 12 pt;
        padding: 4px 6px;
        border-radius: 5px;
        border: 1px solid #bbb;
        background-color: #eee;
}
code, pre, #ws, #message {
        font-family: Monaco;
        font-size: 10pt;
        border-radius: 3px;
        background-color: #F8F8F8;
        color: inherit;
}
code {
        border: 1px solid #EAEAEA;
        margin: 0 2px;
        padding: 0 5px;
}
pre {
        border: 1px solid #CCCCCC;
        overflow: auto;
        padding: 4px 8px;
}
pre > code {
        border: 0;
        margin: 0;
        padding: 0;
}
#ws { background-color: #f8f8f8; }
.bloop_markdown table {
border-collapse: collapse;
font-family: Helvetica, arial, freesans, clean, sans-serif;
color: rgb(51, 51, 51);
font-size: 15px; line-height: 25px;
padding: 0; }
.bloop_markdown table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
.bloop_markdown table tr:nth-child(2n) {
background-color: #f8f8f8; }
.bloop_markdown table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
.bloop_markdown table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
.bloop_markdown table tr th :first-child, table tr td :first-child {
margin-top: 0; }
.bloop_markdown table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }
.bloop_markdown blockquote{
border-left: 4px solid #dddddd;
padding: 0 15px;
color: #777777; }
blockquote > :first-child {
margin-top: 0; }
blockquote > :last-child {
margin-bottom: 0; }
code, pre, #ws, #message {
word-break: normal;
word-wrap: normal;
}
hr {
display: inherit;
}
.bloop_markdown :first-child {
-webkit-margin-before: 0;
}
code, pre, #ws, #message {
font-family: Menlo, Consolas, Liberation Mono, Courier, monospace;
}
.send { color:#77bb77; }
.server { color:#7799bb; }
.error { color:#AA0000; }</style><div class="bloop_markdown"><p><br></p></div><div class="bloop_original_html"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <br> <div id="bloop_sign_1449238712540585984" class="bloop_sign"><div><font face="helvetica, arial">— </font></div><div>Regards Adrian<br></div></div> <br><p class="airmail_on">Am 4. Dezember 2015 bei 15:15:59, Stepan Hruda (<a href="mailto:stepan.hruda@gmail.com">stepan.hruda@gmail.com</a>) schrieb:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>
<title></title>
<span id="mailbox-conversation"></span>
<div><span id="mailbox-conversation">This is not how
*LiteralConvertible protocols work, though. You can only initialize
variables with specific literal values recognized by the parser, it
never magically casts a type to a different type for you. Similar
implicit casts in my opinion confuse whoever reads the code
afterwards.</span></div>
<div><span id="mailbox-conversation"><br></span></div>
<div><span id="mailbox-conversation">```</span></div>
<div><span id="mailbox-conversation"></span>
<div id="mb-reply"><span id="mailbox-conversation">class
SomeConvertible: BooleanLiteralConvertible {</span></div>
<div id="mb-reply"><span id="mailbox-conversation">
typealias BooleanLiteralType = Bool</span></div>
<div id="mb-reply"><span id="mailbox-conversation">
let boolean: Bool</span></div>
<div id="mb-reply"><span id="mailbox-conversation"><br></span></div>
<div id="mb-reply"><span id="mailbox-conversation">
internal required init(booleanLiteral value:
SomeConvertible.BooleanLiteralType) {</span></div>
<div id="mb-reply"><span id="mailbox-conversation">
self.boolean = value</span></div>
<div id="mb-reply"><span id="mailbox-conversation">
}</span></div>
<div id="mb-reply"><span id="mailbox-conversation">}</span></div>
<div id="mb-reply"><span id="mailbox-conversation"><br></span></div>
<div id="mb-reply"><span id="mailbox-conversation">func
getBoolean() -> Bool {</span></div>
<div id="mb-reply"><span id="mailbox-conversation">
return false</span></div>
<div id="mb-reply"><span id="mailbox-conversation">}</span></div>
<div id="mb-reply"><span id="mailbox-conversation"><br></span></div>
<div id="mb-reply"><span id="mailbox-conversation">let
validConvertible: SomeConvertible = false</span></div>
<div id="mb-reply"><span id="mailbox-conversation">// Line below
doesn’t compile</span></div>
<div id="mb-reply"><span id="mailbox-conversation">let
invalidConvertible: SomeConvertible = getBoolean()</span></div>
</div>
<div><span id="mailbox-conversation">```</span></div>
<div class="mailbox_signature"><br>
<br></div>
<br>
<br>
<div class="gmail_quote">
<p>On Fri, Dec 4, 2015 at 8:51 AM, Adrian Zubarev <span dir="ltr"><<a href="mailto:adrian.zubarev@devandartist.com" target="_blank">adrian.zubarev@devandartist.com</a>></span>
wrote:<br></p>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div class="bloop_markdown">
<p>We have finally a corner where people can share their ideas on
how Swift can be improved, and I’m glad my ideas might be part of
this fun.</p>
<p>Swift introduced a few <code>Convertible</code> protocols, but
it still needs some more If you ask me.</p>
<p>Something like this:</p>
<pre><code class="swift">public protocol CustomConvertible {
typealias CustomType
public init(value: Self.CustomType) // or in a better way I can't come up with
}
</code>
</pre>
<p>But it should work in a way that we could create more different
types like <code>enums</code> and <code>ErrorType</code>.</p>
<pre><code class="swift">protocol AConvertible: CustomConvertible { /* some stuff here*/ }
protocol BConvertible: CustomConvertible { /* some stuff here*/ }
struct A {
var foo: Int = 0
}
struct B {
var boo: String = "Hello World"
}
struct C: AConvertible, BConvertible {
typealias CustomAType = A
typealias CustomBType = B
var magical: SomeType
init(value: CustomAType) {
// implement it
}
init(value: CustomBType) {
// implement it
}
}
//===========================
let firstC: C = A() // this is what I'm missing in Swift
let secondC: C = B() // this would be a great syntax sugar
</code>
</pre>
<p>What do you think?</p>
</div>
<div class="bloop_original_html">
<div class="bloop_markdown">
<p><br></p>
</div>
<div class="bloop_original_html">
<div id="bloop_sign_1449235780140307968" class="bloop_sign">
<div><font face="helvetica, arial">— </font></div>
<div>Regards Adrian<br></div>
</div>
</div>
<div class="bloop_markdown"></div>
</div>
<div class="bloop_markdown"></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=0STgJFrDM1NW2hlUscsEzEbKCUfVMDHdFZGprHdNmYc67HqSKuVeKdrTviRbwLJY8iTQNth-2BB-2FLJvdmLa5fh8Cbng8nXDsS0ClyPbHMsubN8jGvy24bYEcimn2-2Bz8g79LL5R9a-2Fl-2FNSTbd6cKLGOOOpyqDlAgnRPzNZCHybwpuhG1d-2FKrah-2Bj19J-2FWDTCJOLcX9y1oJbLTOMs1Nehr3Rs-2FDajyKj-2Bh0LS9ms1eA-2FSNc-3D" alt="" width="1" height="1" border="0" style="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>
</div>
<br>
</div></div></span></blockquote></div><div class="bloop_markdown"><p></p></div><style>body{font-family:Helvetica,Arial;font-size:13px}</style></div><div class="bloop_markdown"><p></p></div></body></html>