By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,432 Members | 795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,432 IT Pros & Developers. It's quick & easy.

An idea.

P: n/a
Hi!
I use Python, and writing some extension modules I think which could
be written an
C compiler, useful only to compile extension modules (I not think an
GCC!!!!), so that the user not have to use GCC, Microsoft Visual C++,
or other.
It must have an common API to all platforms, even if obviously the
implementation is various.
Could be write in 100% Python pure.

It is a bad idea?
Jul 18 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Am Wed, 21 Jul 2004 03:59:37 -0700 schrieb winlinch:
Hi!
I use Python, and writing some extension modules I think which could
be written an
C compiler, useful only to compile extension modules (I not think an
GCC!!!!), so that the user not have to use GCC, Microsoft Visual C++,
or other.
It must have an common API to all platforms, even if obviously the
implementation is various.
Could be write in 100% Python pure.

It is a bad idea?


Hi,

I like the idea very much. A C compiler
written in python. Someone already started
this. There was a post in this newsgroup,
maybe one month ago.

Regards,
Thomas

--
Thomas GŁttler, http://www.thomas-guettler.de/
Jul 18 '05 #2

P: n/a
"Thomas Guettler" <gu*****@thomas-guettler.de> wrote in message news:<pa****************************@thomas-guettler.de>...
Am Wed, 21 Jul 2004 03:59:37 -0700 schrieb winlinch:
Hi!
I use Python, and writing some extension modules I think which could
be written an
C compiler, useful only to compile extension modules (I not think an
GCC!!!!), so that the user not have to use GCC, Microsoft Visual C++,
or other.
It must have an common API to all platforms, even if obviously the
implementation is various.
Could be write in 100% Python pure.

It is a bad idea?


Hi,

I like the idea very much. A C compiler
written in python. Someone already started
this. There was a post in this newsgroup,
maybe one month ago.


The link to this compiler is here:

http://people.cs.uchicago.edu/~varmaa/mini_c/

Another good idea would be to write an improved C preprocessor that

* is more consistent with the C language. For example,
macro SQUARE(x) = x * x;
would be equivalent to
#define SQUARE(x) ((x) * (x))
* in addition to MACRO and MACRO(args), allows forms as complex as:
macro NEW T[arraysize] = calloc(arraysize, sizeof(T));
macro NEW T(...) = T ## _new(...);
macro ALLOCATOR typename(...) {init} =
T* T##_new(...) {
T* self = malloc(sizeof(T));
init;
return self;
}
;
which would allow you to write code like
ALLOCATOR String(char *s) {
self->length = strlen(self);
self->data = NEW char[self->length + 1];
strcpy(self->data, s);
}
int foo() {
s = NEW String("Hello, world!");
// ...
}
* Has "typeof" as part of the preprocessor, so that code like
macro DESTRUCTOR T {cleanup} =
void T##_delete(T* self) {
cleanup;
free(self);
}
;
macro DELETE p = typeof(p)##_delete(p);
will work.
Jul 18 '05 #3

P: n/a
da*****@yahoo.com (Dan Bishop) wrote in message news:<ad**************************@posting.google. com>...
"Thomas Guettler" <gu*****@thomas-guettler.de> wrote in message news:<pa****************************@thomas-guettler.de>...
Am Wed, 21 Jul 2004 03:59:37 -0700 schrieb winlinch:
Hi!
I use Python, and writing some extension modules I think which could
be written an
C compiler, useful only to compile extension modules (I not think an
GCC!!!!), so that the user not have to use GCC, Microsoft Visual C++,
or other.
It must have an common API to all platforms, even if obviously the
implementation is various.
Could be write in 100% Python pure.

It is a bad idea?


Hi,

I like the idea very much. A C compiler
written in python. Someone already started
this. There was a post in this newsgroup,
maybe one month ago.


The link to this compiler is here:

http://people.cs.uchicago.edu/~varmaa/mini_c/

Another good idea would be to write an improved C preprocessor that

* is more consistent with the C language. For example,
macro SQUARE(x) = x * x;
would be equivalent to
#define SQUARE(x) ((x) * (x))
* in addition to MACRO and MACRO(args), allows forms as complex as:
macro NEW T[arraysize] = calloc(arraysize, sizeof(T));
macro NEW T(...) = T ## _new(...);
macro ALLOCATOR typename(...) {init} =
T* T##_new(...) {
T* self = malloc(sizeof(T));
init;
return self;
}
;
which would allow you to write code like
ALLOCATOR String(char *s) {
self->length = strlen(self);
self->data = NEW char[self->length + 1];
strcpy(self->data, s);
}
int foo() {
s = NEW String("Hello, world!");
// ...
}
* Has "typeof" as part of the preprocessor, so that code like
macro DESTRUCTOR T {cleanup} =
void T##_delete(T* self) {
cleanup;
free(self);
}
;
macro DELETE p = typeof(p)##_delete(p);
will work.


I have seen http://people.cs.uchicago.edu/~varmaa/mini_c/ and I must
say that is good, even if I thought to a compiler written without
other modules instead of standard library's, already useful.
For me, the idea of an improvements of C preprocessor has the
disadvantage of having to learn additional syntax, when instead can be
a compiler in the standard library.

I attend answers, critics and ideas!!!!
Jul 18 '05 #4

P: n/a
wi*******@yahoo.it wrote:
Hi!
I use Python, and writing some extension modules I think which could
be written an
C compiler, useful only to compile extension modules (I not think an
GCC!!!!), so that the user not have to use GCC, Microsoft Visual C++,
or other.
It must have an common API to all platforms, even if obviously the
implementation is various.
Could be write in 100% Python pure.

It is a bad idea?


What's the point? What's wrong with GCC? It's fast, comprehensive, and
supported on all major platforms. Unless it solves a specific task, like
Pysco or SWIG, it's purpose will be merely academic.
Jul 18 '05 #5

P: n/a
"Chris S." <ch*****@NOSPAMudel.edu> wrote in message news:<cd**********@scrotar.nss.udel.edu>...
wi*******@yahoo.it wrote:
Hi!
I use Python, and writing some extension modules I think which could
be written an
C compiler, useful only to compile extension modules (I not think an
GCC!!!!), so that the user not have to use GCC, Microsoft Visual C++,
or other.
It must have an common API to all platforms, even if obviously the
implementation is various.
Could be write in 100% Python pure.

It is a bad idea?


What's the point? What's wrong with GCC? It's fast, comprehensive, and
supported on all major platforms. Unless it solves a specific task, like
Pysco or SWIG, it's purpose will be merely academic.


The idea was that one to create a Python platform, without to use
large compilers (I refer above all to MSVC++!!!!!!!), but a compiler
part of the standard library to quickly compile a module.
Jul 18 '05 #6

P: n/a
wi*******@yahoo.it wrote:
The idea was that one to create a Python platform, without to use
large compilers (I refer above all to MSVC++!!!!!!!), but a compiler
part of the standard library to quickly compile a module.


But if it was capable of compiling any C extension module, it would have
to be a full-fledged (large!) C compiler.
Jul 18 '05 #7

P: n/a
On Tue, 27 Jul 2004, Leif K-Brooks wrote:
But if it was capable of compiling any C extension module, it would have
to be a full-fledged (large!) C compiler.


Not if it eschews most/all optimizations, obscure GCC/MSVC extensions,
full-blown assembler/linker, etc. It's quite possible to make a small C
compiler (tinycc (http://www.tinycc.org/) comes to mind...).

Jul 18 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.