[Python-ideas] User-defined literals
p.f.moore at gmail.com
Fri Jun 5 14:18:43 CEST 2015
On 5 June 2015 at 00:03, Andrew Barnert <abarnert at yahoo.com> wrote:
> If it's meant to be a "compile-time decimal value"... What kind of value is that? What ends up in your co_consts? An instance of decimal.Decimal? How does that get marshaled?
Well, Python bytecode has no way of holding any form of constant
Decimal value, so if that's what you want you need a change to the
bytecode (and hence the interperter). I'm not sure how that qualifies
We seem to be talking at cross purposes here. The questions you're
asking are ones I would direct at you (assuming it's you that's after
a compile-time value, I'm completely lost as to who is arguing for
what any more :-() My position is that "compile-time" user-defined
literals don't make sense in Python, what people actually want is
probably more along the lines of "better syntax for writing constant
values of user-defined types".
Oh, and just as a point of reference see
http://en.cppreference.com/w/cpp/language/user_literal - C++ user
defined literals translate into a *runtime* function call. So even
static languages don't work the way you suggest in the comment above.
More information about the Python-ideas