[pypy-dev] Builtin types

logistix logistix at zworg.com
Tue Jan 28 15:10:12 CET 2003


> 
> Whereas "meta_eval('gcc', c_source)" also has the abstract idea of
> applying some function to interpret some input. What's the difference
> from just having a bunch of functions to do these things? Well, it seeks
> to unify the principle and identify an abstraction that can reasonably
> be implemented at each level in some form, whether it is a META_EVAL
> CPython byte code or in-lined machine code calling other machine code.
> I confess to a bit of handwaving, but if I hold back, there's no chance
> of making any contribution to early discussions. You can always ignore
> it if it doesn't fit into your views ;-)
> 

In general I agree but why not an ABC instead of a dispatch function? 
Something like:

class evaluator:
   """Interface for all evaluators"""
   def loadData(self): pass
   def compile(self): pass
   def evaluate(self): pass

And then have subclasses add more specific load_ methods:

i386 = I386evaluator()
i386.loadInstruction('push ebp')
i386.loadInstruction('mov  ebp, esp')
   ...
i386.compile()
i386.evaluate()

Where exec and eval would perform "if not compiled then compile; eval;"
on any evaluator.


More information about the Pypy-dev mailing list