Re: C Fronts
Mon, 5 Aug 91 16:57:36 +0300

          From comp.compilers

Related articles
C Fronts (1991-08-04)
Re: C Fronts (1991-08-05)
Re: C Fronts (1991-08-07)
Re: C Fronts (Chris Dollin) (1991-08-08)
Re: C Fronts (1991-08-09)
| List of all articles for this month |

Newsgroups: comp.compilers
Keywords: C, C++, optimize
Organization: Research Computing Center, Moscow State University
References: 91-08-016
Date: Mon, 5 Aug 91 16:57:36 +0300

    In 91-08-016 (Steve Boswell) writes:

>I know of a few languages that are implemented as C fronts (C++, Eiffel,
>and Kyoto Common Lisp, to name a few.) C++ generates C code that looks like
>C code, while Kyoto Common Lisp generates C code that looks like assembly
>langage (i.e. all branches are GOTOs, one very simple operation per line,
>etc.) Which leads to better, more optimal compiled code? Have there been
>any studies on this?

Steve, I think (IMHO) that in some respects C semantically is more close
to assembly language than to high level language while syntactically
it is more like high level language.

Here are some points to support this argument:
  - C control structures (while, do ... while, for) are all *equivalently*
      expressed through 'if(...) goto L...' statement.
      That semantic equvivalence in practice means that there are no semantic
      limitations present in other languages' control structures.
      For example, you can write:
                for(i=0; i<10; i++) {
                        printf("%d", i);
      It is correct in C but such 'loops' are prohibited in many other languages
      (you can not assign the loop variable in the loop body).

  - C multidimensional arrays are semantically treated as linearized
      1-dimensional arrays. It means that compiler doesn't need to check that
      index expession values fit in array boundary.

So semantically C is *high level assembly language* in many respects but not
in all.

C expressions look like normal high level expressions. And many
compilers can optimize expressions and generate very good code for them.
So if your 'very simple operations' are small parts of expression written as
separate statements you'll probably get slower code because not all
compilers do interstatement optimizations. But if these 'operations'
are goto and if statements you won't lose anything.
  Vadim Yu. Maslov, Internet:
                                        Office phone: (095)939-2347, (095)939-3907

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.