Python was designed (was Re: Multi-threading in Python vs Java)
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Thu Oct 17 21:58:31 EDT 2013
On Thu, 17 Oct 2013 19:24:58 +1100, Chris Angelico wrote:
> Anyway, what I sought to prove was that polymorphic object oriented code
> can be written in C or any other language.
The proof of this is that any Turing-complete language can simulate any
other language. Obviously the *difficulty* can vary, but any sufficiently
expressive language can be used to write an interpreter for some other
language which gives you the results you want.
I'm not just talking hypothetically here. Python is polymorphic, and
there are at least two Python implementations written in C (CPython and
Stackless). So if you took all the C code which implements object-
oriented behaviour within CPython, added it to your C project, and then
used it directly as a framework, you would have polymorphic code written
using nothing but C.
Of course, this wouldn't be idiomatic C code, and you won't have syntax
for what you want, but that's why other languages get invented in the
first place.
--
Steven
More information about the Python-list
mailing list