An idea.

Discussion in 'Python' started by winlinchu@yahoo.it, Jul 21, 2004.

  1. Guest

    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 21, 2004
    #1
    1. Advertising

  2. C compiler written in Python Was: An idea.

    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/
     
    Thomas Guettler, Jul 21, 2004
    #2
    1. Advertising

  3. Dan Bishop Guest

    Re: C compiler written in Python Was: An idea.

    "Thomas Guettler" <> wrote in message news:<>...
    > 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.
     
    Dan Bishop, Jul 22, 2004
    #3
  4. Guest

    Re: C compiler written in Python Was: An idea.

    (Dan Bishop) wrote in message news:<>...
    > "Thomas Guettler" <> wrote in message news:<>...
    > > 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 23, 2004
    #4
  5. Chris S. Guest

    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.
     
    Chris S., Jul 24, 2004
    #5
  6. Guest

    "Chris S." <> wrote in message news:<cdt4pf$osr$>...
    > 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 26, 2004
    #6
  7. 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.
     
    Leif K-Brooks, Jul 27, 2004
    #7
  8. 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...).
     
    Christopher T King, Jul 27, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. senthil
    Replies:
    0
    Views:
    631
    senthil
    Nov 21, 2003
  2. senthil

    ifft coding in vhdl give idea

    senthil, Dec 9, 2003, in forum: VHDL
    Replies:
    1
    Views:
    1,862
  3. Replies:
    10
    Views:
    1,262
    Big K
    Feb 2, 2005
  4. Dr Mephesto

    App idea, Any idea on implementation?

    Dr Mephesto, Feb 4, 2008, in forum: Python
    Replies:
    3
    Views:
    736
    Dennis Lee Bieber
    Feb 5, 2008
  5. Replies:
    0
    Views:
    649
Loading...

Share This Page