| Deutsch English Français Italiano |
|
<vjp2f3$13k4m$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Thiago Adams <thiago.adams@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: transpiling to low level C
Date: Mon, 16 Dec 2024 08:21:07 -0300
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <vjp2f3$13k4m$2@dont-email.me>
References: <vjlh19$8j4k$1@dont-email.me>
<vjn9g5$n0vl$1@raubtier-asyl.eternal-september.org>
<vjnhsq$oh1f$1@dont-email.me> <vjnq5s$pubt$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 16 Dec 2024 12:21:07 +0100 (CET)
Injection-Info: dont-email.me; posting-host="9df6c4f7516d4e1a3aa2c9bdac164fe4";
logging-data="1167510"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18acI7/ku1HoMtj4zKeAG282YvW058Ku3w="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:aRFEhT9sqSTEfmj8DDAvG3Xs42M=
Content-Language: en-US
In-Reply-To: <vjnq5s$pubt$1@dont-email.me>
Bytes: 2723
On 15/12/2024 20:53, BGB wrote:
> On 12/15/2024 3:32 PM, bart wrote:
>> On 15/12/2024 19:08, Bonita Montero wrote:
>>> C++ is more readable because is is magnitudes more expressive than C.
>>> You can easily write a C++-statement that would hunddres of lines in
>>> C (imagines specializing a unordered_map by hand). Making a language
>>> less expressive makes it even less readable, and that's also true for
>>> your reduced C.
>>>
>>
>> That's not really the point of it. This reduced C is used as an
>> intermediate language for a compiler target. It will not usually be
>> read, or maintained.
>>
>> An intermediate language needs to at a lower level than the source
>> language.
>>
>> And for this project, it needs to be compilable by any C89 compiler.
>>
>> Generating C++ would be quite useless.
>>
>
> As an IL, even C is a little overkill, unless turned into a restricted
> subset (say, along similar lines to GCC's GIMPLE).
>
> Say:
> Only function-scope variables allowed;
> No high-level control structures;
> ...
>
> Say:
> int foo(int x)
> {
> int i, v;
> for(i=x, v=0; i>0; i--)
> v=v*i;
> return(v);
> }
>
> Becoming, say:
> int foo(int x)
> {
> int i;
> int v;
> i=x;
> v=0;
> if(i<=0)goto L1;
> L0:
> v=v*i;
> i=i-1;
> if(i>0)goto L0;
> L1:
> return v;
> }
>
> ...
>
I have considered to remove loops and keep only goto.
But I think this is not bring too much simplification.