<div dir="ltr">I could see a purpose for identifiers which started numbers but weren't entirely numerical.<div>e.g.<br></div><div>enum Dimensions { case `2D`, `3D` }</div><div>enum DiceRoll { case d6, `2d6` }</div><div>func roll(dice: DiceRoll) -> Int { ... }</div><div>roll(.`2d6`)</div><div><br></div><div>I'm not sure I see one for identifiers which are entirely numerical.</div><div><br></div><div>Ross</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 9, 2017 at 8:05 AM, Adrian Zubarev via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><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 class="m_71511993325937757bloop_markdown"><p>My point would be to have a exact set of possible numerical cases. The issue with numerical cases is that they don’t have to be ordered and they could also be overlapping with other subsystems (by subsystem I mean a subsystem of your particular project). </p>
<p>Even if we had the ability to limit the range of numerical types like <code>Int</code>, we still might not be able to exclude inner values for that range, which makes <code>RawRepresentable</code> not quite efficient to work with. Numerical enum cases on the other hand could solve that issue elegantly.</p>
<p>I see the reason for types other because of FP and integer literals, but I don’t see why we couldn’t have numerical enum cases.</p>
<p></p></div><div class="m_71511993325937757bloop_original_html"><span class=""><div id="m_71511993325937757bloop_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="m_71511993325937757bloop_sign_1489046058426732032" class="m_71511993325937757bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div> <br></span><div><div class="h5"><p class="m_71511993325937757airmail_on">Am 9. März 2017 um 08:52:34, Slava Pestov (<a href="mailto:spestov@apple.com" target="_blank">spestov@apple.com</a>) schrieb:</p> <blockquote type="cite" class="m_71511993325937757clean_bq"><span><div style="word-wrap:break-word"><div></div><div>
<br>
<div>
<blockquote type="cite">
<div>On Mar 8, 2017, at 11:46 PM, Adrian Zubarev
<<a href="mailto:adrian.zubarev@devandartist.com" target="_blank">adrian.zubarev@devandartist.<wbr>com</a>> wrote:</div>
<br class="m_71511993325937757Apple-interchange-newline">
<div>
<div class="m_71511993325937757bloop_markdown" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)">
<p style="margin:15px 0px">I
don’t have more precise examples except something like TCP socket
error codes as an enum.</p>
</div>
</div>
</blockquote>
<div>I would expect that the error code is available as a computed
property of the enum value, perhaps as its raw value or something
else. I would not expect it to be part of the enum case *name*.
What significance does the numeric code have to the reader of the
code, and when do you ever want to permanently freeze error codes
in an API like this?</div>
<div><br></div>
<div>Note that even Unix errno error codes are not standardized
across unices or even different architectures running Linux; only
their names are.</div>
<div><br></div>
<div>Slava</div>
<br>
<blockquote type="cite">
<div>
<div class="m_71511993325937757bloop_markdown" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)">
<p style="margin:15px 0px">
The example with the number literal is actually really good,
because it also shows the bad sides of the pitch. However we could
allow numerical enum cases without any issues right?</p>
<div style="margin:15px 0px"><br class="m_71511993325937757webkit-block-placeholder"></div>
</div>
<div class="m_71511993325937757bloop_original_html" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)">
<div id="m_71511993325937757bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;margin:0px"><br></div>
<br>
<div id="m_71511993325937757bloop_sign_1489045421004600064" class="m_71511993325937757bloop_sign">
<div style="font-family:helvetica,arial;font-size:13px">-- <br>
Adrian Zubarev<br>
Sent with Airmail</div>
</div>
<br>
<p class="m_71511993325937757airmail_on" style="margin:15px 0px">Am 9. März 2017 um
08:41:13, Slava Pestov (<a href="mailto:spestov@apple.com" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">spestov@apple.com</a>) schrieb:</p>
<blockquote type="cite" class="m_71511993325937757clean_bq" style="margin:15px 0px">
<div style="word-wrap:break-word">
<div></div>
<div><span style="margin-top:0px;margin-bottom:0px"><br></span>
<div>
<blockquote type="cite" style="margin:15px 0px">
<div style="margin-top:0px"><span style="margin-top:0px;margin-bottom:0px">On Mar 8, 2017, at
11:33 PM, Adrian Zubarev via swift-evolution <<a href="mailto:swift-evolution@swift.org" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">swift-evolution@swift.org</a>>
wrote:</span></div>
<span style="margin-top:0px;margin-bottom:0px"><br class="m_71511993325937757Apple-interchange-newline"></span>
<div style="margin-bottom:0px">
<div class="m_71511993325937757bloop_markdown" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)">
<p style="margin:15px 0px">
<span style="margin-top:0px;margin-bottom:0px">I
forget to mention, this should be also valid:</span></p>
<pre style="margin:15px 0px;font-family:Menlo,Consolas,'Liberation Mono',Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:1px solid rgb(204,204,204);overflow:auto;padding:4px 8px;word-break:normal;word-wrap:normal"><span style="margin-top:0px;margin-bottom:0px"><code class="m_71511993325937757swift" style="font-family:Menlo,Consolas,'Liberation Mono',Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:0px;margin:0px;padding:0px;word-break:normal;word-wrap:normal">let `42` = 42
print(`42`)
struct A {
let `0` = 0
}
let number = A().0
</code></span></pre>
<div style="margin:15px 0px"><span style="margin-top:0px;margin-bottom:0px"><br class="m_71511993325937757webkit-block-placeholder"></span></div>
</div>
</div>
</blockquote>
<div><span style="margin-top:0px;margin-bottom:0px">-1</span></div>
<div><span style="margin-top:0px;margin-bottom:0px"><br></span></div>
<div><span style="margin-top:0px;margin-bottom:0px">This seems really confusing.</span></div>
<div><span style="margin-top:0px;margin-bottom:0px"><br></span></div>
<div><span style="margin-top:0px;margin-bottom:0px">extension Int { var `0`: Int { return 0 } }</span></div>
<div><span style="margin-top:0px;margin-bottom:0px"><br></span></div>
<div><span style="margin-top:0px;margin-bottom:0px">3.0 // is this a float literal?</span></div>
<div><span style="margin-top:0px;margin-bottom:0px">3 .0 // member access?</span></div>
<div><span style="margin-top:0px;margin-bottom:0px">.0 // this is actually a contextual member access, and not
a literal ‘0.0’?</span></div>
<div><span style="margin-top:0px;margin-bottom:0px"><br></span></div>
<div><span style="margin-top:0px;margin-bottom:0px"> I’d prefer if .0, .1, … were reserved for tuple
fields; .0 is already not very descriptive, but at the very least
if you see it in source code you know you have a tuple type and not
something else.</span></div>
<div><span style="margin-top:0px;margin-bottom:0px"><br></span></div>
<div><span style="margin-top:0px;margin-bottom:0px">Also the compiler’s name mangling relies on the fact that
identifiers never begin with a numeric character or
symbol.</span></div>
<div><span style="margin-top:0px;margin-bottom:0px"><br></span></div>
<div><span style="margin-top:0px;margin-bottom:0px">Can you give a motivating example where allowing an
identifier to start with a number actually helps
readability?</span></div>
<div><span style="margin-top:0px;margin-bottom:0px"><br></span></div>
<div><span style="margin-top:0px;margin-bottom:0px">Slava</span></div>
<div><span style="margin-top:0px;margin-bottom:0px"><br></span></div>
<span style="margin-top:0px;margin-bottom:0px"><br></span>
<blockquote type="cite" style="margin:15px 0px">
<div style="margin-top:0px;margin-bottom:0px">
<div class="m_71511993325937757bloop_original_html" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)">
<div id="m_71511993325937757bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;margin:0px">
<span style="margin-top:0px;margin-bottom:0px"><br></span></div>
<span style="margin-top:0px;margin-bottom:0px"><br></span>
<div id="m_71511993325937757bloop_sign_1489044670460260864" class="m_71511993325937757bloop_sign">
<div style="font-family:helvetica,arial;font-size:13px"><span style="margin-top:0px;margin-bottom:0px">-- <br>
Adrian Zubarev<br>
Sent with Airmail</span></div>
</div>
<span style="margin-top:0px;margin-bottom:0px"><br></span>
<p class="m_71511993325937757airmail_on" style="margin:15px 0px"><span style="margin-top:0px;margin-bottom:0px">Am 9. März 2017 um
08:24:54, Adrian Zubarev (<a href="mailto:adrian.zubarev@devandartist.com" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">adrian.zubarev@devandartist.<wbr>com</a>)
schrieb:</span></p>
<blockquote type="cite" class="m_71511993325937757clean_bq" style="margin:15px 0px">
<div style="margin-top:0px;margin-bottom:0px;word-wrap:break-word">
<div></div>
<div>
<div class="m_71511993325937757bloop_markdown">
<p style="margin:15px 0px">
<span style="margin-top:0px;margin-bottom:0px"><span style="margin-top:0px;margin-bottom:0px">Hi
Swift community, I’d like to pitch this idea
again.</span></span></p>
<p style="margin:15px 0px"><span style="margin-top:0px;margin-bottom:0px">Swift
already has the pitched feature, but it is exclusive for tuples
only.<span class="m_71511993325937757Apple-converted-space"> </span><strong>SE–0071</strong><span class="m_71511993325937757Apple-converted-space"> </span>allowed the use of keywords
after the<span class="m_71511993325937757Apple-converted-space"> </span><code style="font-family:Menlo,Consolas,'Liberation Mono',Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:1px solid rgb(234,234,234);margin:0px 2px;padding:0px 5px;word-break:normal;word-wrap:normal">.</code><span class="m_71511993325937757Apple-converted-space"> </span>in
a member access, except for those keywords that have special
meaning by using back-ticks. However, members starting with numbers
are not special keywords and as already mentioned, numerical
members are already allowed in tuples.</span></p>
<p style="margin:15px 0px">I propose to extend that
capability to the whole language and make that behavior consistent.
To disambiguate members starting with a number one would need to
use back-ticks.</p>
<pre style="margin:15px 0px;font-family:Menlo,Consolas,'Liberation Mono',Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:1px solid rgb(204,204,204);overflow:auto;padding:4px 8px;word-break:normal;word-wrap:normal"><code class="m_71511993325937757swift" style="font-family:Menlo,Consolas,'Liberation Mono',Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:0px;margin:0px;padding:0px;word-break:normal;word-wrap:normal">// Enum
enum ErrorCode : String {
case `2345` = "my description for 2345"
case `123a` = "my description for 123a"
case `123b` = "my description for 123b"
}
let code = ErrorCode.2345
// Function
func `42foo`(label: Type, `12345`: Type, `0987something`: Type) { … }
// Tuple
(`1`: Int, `2`: Int)
</code></pre>
<p style="margin:15px 0px">My question is: would that be
in scope for Swift 4?</p>
</div>
<div class="m_71511993325937757bloop_original_html">
<div id="m_71511993325937757bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;margin:0px">
<br></div>
<br>
<div id="m_71511993325937757bloop_sign_1489043043819660032" class="m_71511993325937757bloop_sign">
<div style="font-family:helvetica,arial;font-size:13px">
-- <br>
Adrian Zubarev<br>
Sent with Airmail</div>
</div>
</div>
<div class="m_71511993325937757bloop_markdown"></div>
</div>
</div>
</blockquote>
</div>
<div class="m_71511993325937757bloop_markdown" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)">
<div style="margin:15px 0px"><br class="m_71511993325937757webkit-block-placeholder"></div>
</div>
<span style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254);float:none;display:inline!important">______________________________<wbr>_________________</span><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)">
<span style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254);float:none;display:inline!important">
swift-evolution mailing list</span><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)">
<span style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254);float:none;display:inline!important">
<a href="mailto:swift-evolution@swift.org" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">
swift-evolution@swift.org</a></span><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)">
<span style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254);float:none;display:inline!important">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">
https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a></span><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)">
</div>
</blockquote>
</div>
<br></div>
</div>
</blockquote>
</div>
<div class="m_71511993325937757bloop_markdown" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)">
<br class="m_71511993325937757Apple-interchange-newline"></div>
</div>
</blockquote>
</div>
<br>
</div></div></span></blockquote></div></div></div><div class="m_71511993325937757bloop_markdown"><p></p></div></div><br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div>