From that page:
User-defined literals are basically normal function calls with a fancy syntax. [...] While user defined literals look very neat, they are not much more than syntactic sugar. There is not much difference between defining and calling a literal operator with "foo"_bar and doing the same with an ordinary function as bar("foo"). In theory, we could write literal operators that have side effects and do anything we want, like a normal function.
Obviously the arbitrary-function-part of that will never happen in Python
(yes?)
Also, for discussion, remember to make the distinction between 'units'
(amps, meters, seconds) and 'prefixes' (micro, milli, kilo, mega). Right
away from comments, it seems 1_m could look like 1 meter to some, or 0.001
to others. Typically when I need to enter very small/large literals, I'll
use "engineering" SI notation (powers divisible by 3 that correspond to the
prefixes): 0.1e-9 = 0.1 micro____.
On Sat, Oct 29, 2016 at 12:20 AM, Ryan Birmingham
I'd certainly be interested in hearing about how this has worked with C++, but this would certainly make scientific code less easy to misuse due to unclear units.
-Ryan Birmingham
On 28 October 2016 at 16:45, Sven R. Kunze
wrote: On 28.10.2016 22:06, MRAB wrote:
On 2016-08-26 13:47, Steven D'Aprano wrote:
Ken has made what I consider a very reasonable suggestion, to introduce SI prefixes to Python syntax for numbers. For example, typing 1K will be equivalent to 1000.
Just for the record, this is what you can now do in C++:
User-Defined Literals http://arne-mertz.de/2016/10/modern-c-features-user-defined-literals/
Nice to hear. :)
They now have 5 years of experience with that. Are there any surveys, experience reports, etc.?
Cheers, Sven
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/