<div dir="ltr"><div><div><div><div><div><div><div>I am strongly opposed to any such syntax sugar. In all the posts in this thread, I have not seen anything that would do anything other than save 4 keystrokes. The thing that expresses transformations on string literals are known as *functions* already. And while functions need a set of parentheses and perhaps an 'r' to make sure raw strings are passed in, this is exactly the same thing as the "registry of evaluated string types".<br>
<br></div>I.e. if you want:<br><br></div> mydecimal = D"123.45"<br><br></div>Just settle for the perfectly good (and far less confusing and error-prone):<br><br></div> mydecimal = D(r"123.45")<br><br>
</div>And likewise, this is fine:<br><br></div> sql = S(r"SELECT * FROM foo WHERE field='value'")<br></div> funny_string_type = f(r"Gets interpreted [in some] <odd way>")<br><br><br></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 30, 2013 at 1:15 PM, Göktuğ Kayaalp <span dir="ltr"><<a href="mailto:goktug.kayaalp@gmail.com" target="_blank">goktug.kayaalp@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">> Of course the OP wasn't even worried about that; he just wanted to<br>
> save a few keystrokes making decimals.<br>
<br>
</div>I haven't used the decimal library for anything other than the example<br>
I've given in the first post of this thread. What I wanted was a more<br>
convenient way to express transformations on string literals that are<br>
usually expressed via functions and classes and what I proposed was a<br>
method to achieve this utilizing syntactic sugar and runtime evaluation<br>
of string literals. Reducing my *worries* to an *effort of mutating the<br>
language to save some keystrokes* is rude.<br>
<br>
Göktuğ.<br>
<div class="HOEnZb"><div class="h5">Andrew Barnert <<a href="mailto:abarnert@yahoo.com">abarnert@yahoo.com</a>> writes:<br>
<br>
> On May 30, 2013, at 3:42, Haoyi Li <<a href="mailto:haoyi.sg@gmail.com">haoyi.sg@gmail.com</a>> wrote:<br>
><br>
><br>
> > But still, it's amazing how C++11-ish this discussion is getting. Which<br>
> may be a good hint that (as you suggest) this feature isn't a good fit for<br>
> Python.<br>
><br>
><br>
> I don't agree with this; while C++ is huge and terrible, C++11 actually<br>
> has some pretty good stuff (e.g. real lambdas, with real closures and real<br>
> lexical scoping! u"unicode" and r"raw" strings!). Dismissing something as<br>
> bad just because it's something C++11 has is a terrible idea and<br>
> immediately shuts out a whole range of interesting possibilities.<br>
><br>
><br>
> C++11 is a set of very clever, and often very nice, improvements, but nearly<br>
> all of the improvements are solutions to problems unique to C++90.<br>
><br>
> And if you step back, the problem most people are trying to solve here is that<br>
> they don't want to do string processing inline within a function because they're<br>
> worried about performance. (Of course the OP wasn't even worried about that;<br>
> he just wanted to save a few keystrokes making decimals. But most of the<br>
> follow ups haven't been about that.) I'd guess that 90% of the time those<br>
> performance worries are misguided, and the remaining 10% can already be solved<br>
> by moving the strings to module level, caching the results, etc. So, we're<br>
> looking for syntactic sugar for a way to accomplish one of those solutions<br>
> more nicely. That's a very different problem than making strings (and other<br>
> types) accessible to a compile-time metalanguage that's radically different<br>
> from the runtime language, which is what C++ was solving.<br>
><br>
> (PS, you misattributed most of your quotes to me instead of Eric Snow. But I'm<br>
> sure he'll still see then.)<br>
</div></div><div class="im HOEnZb">> _______________________________________________<br>
> Python-ideas mailing list<br>
> <a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
> <a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
<br>
</div><span class="HOEnZb"><font color="#888888">--<br>
Göktuğ Kayaalp <<a href="mailto:goktug.kayaalp@gmail.com">goktug.kayaalp@gmail.com</a>><br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>
advocates of freedom in prisons. Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br>
</div>