[Python-Dev] Re: User extendable literal modifiers ?!

Gerhard Häring gerhard.haering@opus-gmbh.net
Fri, 27 Sep 2002 10:33:11 +0000 (UTC)

In article <3D9423FB.9070303@lemburg.com>, M.-A. Lemburg wrote:
> [mxNumber]
> I was wondering whether it would be worth adding something
> like a registry of literal modifiers to Python,

Especially for this purpose, that would be great. And have potential for
misuse, too. Just like, say, operator overloading. But in the context of
Python, I didn't see any misuse of operator overloading, yet.

> [...] so that
> extensions can register new modifiers with the compiler,
> e.g.
> sitecustomize.py:
> def create_I_literal(literal_string):
>      return 'mx.Number.Integer(%s)' % literal_string
> sys.register_numberlitmod('I', create_I_literal)

A single literal, however, doesn't (easily) allow you to give precision and
scale arguments to your decimal literal. That's of course easy if you can
declare your variable, which you can't in Python. So we're back to
constructors/factory functions here, right?

-- Gerhard