Re: new IL: C (sort of...).



"cr88192" <cr88192@xxxxxxxxxxx> wrote in message
news:h0p4u5$k98$1@xxxxxxxxxxxxxxxxxxxx
however, to better fill the role (ok, mostly to reduce performance
overhead), I considered making a few design changes/restrictions:
I have removed the preprocessor, as for now I will assume that any used
input will be "PP clean"...
I have considered deprecating typedef (the reason is that typedef adds a
good deal of complexity to the parser, as well as likely making it a good
deal slower);
I have also dropped/deprecated some other misc language features (enum, a
lot of the C99 additions, ...);
I may deprecate support for "inline" struct/union declarations (all
structs
are declared toplevel, and may be referenced, but no struct bodies may
appear as part of a variable of function declaration);
all variable declarations will be at the top of the function;
functions may not be nested;

bitfields? floats? unions? multiple integer and char types? qualifiers?
volatile? const? void? void*?

I'd get rid of all those too... :-)

so, the questions here are:
do people think using C as the basis for an IL is a good idea?...

Many modern languages already do, don't they?

If you do, you'll be restricted to the functionality of that subset of C,
and to the Algol-like language concepts. You'll be restricted to the Unix
everything-as-a-file concept, etc.

Although I was using a FORTH-like IL (not anymore...), as were you - IIRC, I
really wouldn't want to try convert FORTH or LISP to C... I don't see them
as being similar enough to convert them optimally. I'd consider C as an IL
to be fine for FORTRAN, Pascal, or BASIC, etc. Of course, you'd need to
keep the floats for FORTRAN, at least.

C has the advantage that it can be implemented for the most part using very
basic ? concepts, such as addresses and pointers. However, C can be made
far more portable with slight extensions.

are some of my considered alterations (such as deprecating typedef)
reasonable?...

I don't know. I know that it's about the only way to extend C. If the
other language is very extendable, you might have some problems. The two
situations where I commonly use typedef is with structs to self-reference
the struct and to hide the code complexity of function pointers.

or, hypothetically, would anyone else target a C subset with these
alterations?...

Possibly. A high level C with extensions, like GCC, to a very simple
reduced C would be very useful, IMO. I know there is Necula's CIL (not to
be confused with MS CIL), but I haven't seen much else. There are a number
of ancient C compilers, like Small C, which could compile the output of the
C-to-C conversion. I think it would be good for OS development and embedded
development etc. It really depends on how many advanced features and
extensions you could convert into simple C. The idea of implementing a very
simple C language was popular back when C compilers weren't common or
widespread.


Rod Pemberton


.



Relevant Pages

  • Re: Embedding assembler in a language
    ... With Seed7 I try to avoid portability pitfalls. ... improving language or implementation they offer a backdoor. ... compilers beating hand-coded assembler, that I rewrote the core of my ... Seed7 supports Linux/unix/bsd, Mac OS X and Windows (using MinGW, ...
    (comp.lang.misc)
  • Re: ANSI C compliance
    ... One of the world's most used C compilers, gcc, has a command line ... But it has nothing to do with the C language, ... > platform might not work on another platform. ... Chars have 8 bits and plain char is signed. ...
    (comp.lang.c)
  • Re: Aztec C and Dosemu
    ... impossible) to configure the way we use compilers today and disk swapping, ... Upper case hurts my eyes:) Any comparison between an Applesoft program being considered structured and a C program that is structured would be in the eyes of the beholder IMO. ... Aztec C supports inline assembly and the linking of assembly language modules if one needs to. ...
    (comp.sys.apple2.programmer)
  • Re: new IL: C (sort of...).
    ... I have considered deprecating typedef (the reason is that typedef adds a ... and to the Algol-like language concepts. ... of ancient C compilers, like Small C, which could compile the output of ... now LLVM has them, so it is a lot more of an issue. ...
    (comp.lang.misc)
  • No Starch Press Releases "Write Great Code, Volume 2"
    ... Thinking Low-Level, Writing High-Level ... Explains how compilers work and how to get the best quality output from ... code for those high-level language statements and data structures, ... In the early days of computing, programmers used high-level language code ...
    (comp.os.linux.announce)