<div dir="ltr"><div class="gmail_default"><font face="georgia, serif">I think it avoids the confusion. You can use print((0xabc).beef) instead.</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif">Zhaoxin</font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jun 26, 2016 at 3:50 PM, Toni Suter via swift-users <span dir="ltr">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt;</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">Hi,<div><br></div><div>I have a question regarding hexadecimal floating-point literals. According to the Lexical Structure (<a href="https://developer.apple.com/library/prerelease/content/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html" target="_blank">https://developer.apple.com/library/prerelease/content/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html</a>) </div><div>it is not possible to have a hex floating-point literal without the exponent. At first I thought this makes sense.</div><div>How else would the lexer / parser know if 0x123.beef is a hex floating-point literal or a hex integer literal with a property &#39;beef&#39;?</div><div>However, if I define such a property on Int, it doesn’t work:</div><div><br></div><div><div><font face="Menlo">extension Int {</font></div><div><font face="Menlo">    var beef: Int {</font></div><div><font face="Menlo">        return 42</font></div><div><font face="Menlo">    }</font></div><div><font face="Menlo">}</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo">print(12.beef) <span style="white-space:pre-wrap">                </span>// works</font></div><div><font face="Menlo">print(0b1001.beef) <span style="white-space:pre-wrap">        </span>// works</font></div><div><font face="Menlo">print(0o77.beef) <span style="white-space:pre-wrap">        </span>// works</font></div><div><font face="Menlo">print(0xabc.beef) <span style="white-space:pre-wrap">        </span>// error: hexadecimal floating point literal must end with an exponent</font></div></div><div><br></div><div>Is this just to avoid confusion for the programmer? Or is there some other reason?</div><div><br></div><div>Thanks and best regards,</div><div>Toni</div></div><br>_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>