[Compiler-sig] Number classes

Finn Bock bckfnn@worldonline.dk
Fri, 19 Apr 2002 18:05:37 GMT


[Jeremy]

>If we have 
>
>expr = Num(object value, num_type type)
>num_type = Int | Long | Float | Complex
>
>Then I can parse the string and create a num passing the PyObject *
>and setting the appropriate type flag.  I could also handle separate
>IntNum, LongNum, etc. ctors, but that seems like more nodes that we
>really need.
>
>If the Num node(s) need to have the type specified, that I'd like it
>to take an object not a string.

I think this is a little overkill. I only needed the 'type' arg when the
value was a string. If we decide to use a 'object value' I have no need
for the type argument.

So this is sufficient for me:

   expr = Num(object value)

and I'm guessing it is for you too.

I just implemented the 'object' type and the only drawback is that the
parser package now depends on the classes in the core package. It is a
little ugly but it is in no way a technical problem.

regards,
finn