<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Ok, thanks for the hint!<div class=""><br class=""></div><div class="">Toni</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 26 Jun 2016, at 11:49, zh ao &lt;<a href="mailto:owenzx@gmail.com" class="">owenzx@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default"><font face="georgia, serif" class="">I think it avoids the confusion. You can use&nbsp;print((0xabc).beef) instead.</font></div><div class="gmail_default"><font face="georgia, serif" class=""><br class=""></font></div><div class="gmail_default"><font face="georgia, serif" class="">Zhaoxin</font></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Jun 26, 2016 at 3:50 PM, Toni Suter via swift-users <span dir="ltr" class="">&lt;<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi,<div class=""><br class=""></div><div class="">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" class="">https://developer.apple.com/library/prerelease/content/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html</a>)&nbsp;</div><div class="">it is not possible to have a hex floating-point literal without the exponent. At first I thought this makes sense.</div><div class="">How else would the lexer / parser know if 0x123.beef is a hex floating-point literal or a hex integer literal with a property 'beef'?</div><div class="">However, if I define such a property on Int, it doesn’t work:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">extension Int {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; var beef: Int {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp; return 42</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; }</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">print(12.beef) <span style="white-space:pre-wrap" class="">                </span>// works</font></div><div class=""><font face="Menlo" class="">print(0b1001.beef) <span style="white-space:pre-wrap" class="">        </span>// works</font></div><div class=""><font face="Menlo" class="">print(0o77.beef) <span style="white-space:pre-wrap" class="">        </span>// works</font></div><div class=""><font face="Menlo" class="">print(0xabc.beef) <span style="white-space:pre-wrap" class="">        </span>// error: hexadecimal floating point literal must end with an exponent</font></div></div><div class=""><br class=""></div><div class="">Is this just to avoid confusion for the programmer? Or is there some other reason?</div><div class=""><br class=""></div><div class="">Thanks and best regards,</div><div class="">Toni</div></div><br class="">_______________________________________________<br class="">
swift-users mailing list<br class="">
<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>