David Mitchell wrote:
> Now of course if we have the luxury of deciding that core perl 'knows'
> about complex numbers, then of  the parser can be made to recognise ...

The core doesn't need to know -- that was my point. All the core needs
is the basic constant folding rules _it_already_has_ combined with a
macro to define "i". When you "use complex" the macro would be folded
into the parser. The core doesn't need any special support (other than
decent macros... ;)

> In summary: Perl shouldn't do interpetation of numeric literals, but
> should instead delegate it to the numeric class currently in scope.

I agree with you. The complication is that there isn't *a* numeric class
in scope -- there are *many* numeric classes. We could model numeric
classes as a tower ala Scheme in which case a constant is given to the
most fundamental class first and then the classes higher up the tower.
The core might just implement this by throwing a compile-time exception
that can be caught by the classes higher up the tower. (I think the only
real problem here is handling large precision numbers -- everything else
can be handled with macros and constant folding.)

A more complete solution might be to allow numeric modules to extend
the parser's definition of numeric constants and allow back-tracking if
an attempted parse fails. This has more control and flexibility than
compile time exceptions but demands a lot more from the parser.

It'd be nice to hear the PDL folks jump in with their opinion of what
kinds of numeric constants are useful.

- Ken

Reply via email to