Deutsch   English   Français   Italiano  
<vrc4eb$2p28t$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: Bart's Language
Date: Tue, 18 Mar 2025 15:45:16 +0000
Organization: A noiseless patient Spider
Lines: 71
Message-ID: <vrc4eb$2p28t$1@dont-email.me>
References: <vracit$178ka$1@dont-email.me> <vrbo88$1j3e0$1@paganini.bofh.team>
 <vrbtve$2irc9$1@dont-email.me> <vrc2d5$1jjrf$1@paganini.bofh.team>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Mar 2025 16:45:16 +0100 (CET)
Injection-Info: dont-email.me; posting-host="35833daf7a617b7c2106f27a6fe8438d";
	logging-data="2918685"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19nJcbVbpg6QUb+r8dqCKKW"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:MGpumaDJ/AsaJeOXf+IwxlHgGa4=
Content-Language: en-GB
In-Reply-To: <vrc2d5$1jjrf$1@paganini.bofh.team>

On 18/03/2025 15:10, Waldek Hebisch wrote:
> bart <bc@freeuk.com> wrote:
>> On 18/03/2025 12:17, Waldek Hebisch wrote:

>> There were some tweaks needed; it indicates some basic info missing from
>> my write-up! (For example, that the function call needs to be bar() not
>> bar; 'const' is only for compile-time expressions; and that C's 'const'
>> doesn't exist - it only briefly mentions an attempt at 'let'.)
>>
>> The revised code is shown below, with what I assumed were your
>> intentions.
> 
> Well, my intentions beter correspond to the C version below:
> 
> int foo() {
>      const int c = c1(10);
>      const int b = c + c2(2);
>      const int a = b+c3(c);
>      bar();
>      baz();
>      return c;
> }
> 
> Part of the question was if "execution" of declarations is
> interleaved with execution of code or if declarations go
> before the code.

A declaration like:

    int a := x

can be considered to be:

    int a; a := x

where the declaration can go anywhere in the scope=, but the assignment 
must be done here. There are languages where you have:

     print x
     where x is ...

But the typical usage pattern in my own programs is that local variable 
are declared before first use.

(Maybe a compiler option can enforce that, but I don't see it as critical.)

>>       print a
>>       int a:=100
>>
>> the assignment is done at that place in the code (after print), but the
>> scope of 'a' is function-wide. My compiler doesn't detect accesses to
>> unitialised variables, but I could add a debug option to clear
>> stack-frame variables on function entry.)
> 
> I see.  So your feature conflicts with C feature "variable which is
> initialized at declaration time is always used initialized".

That doesn't happen here:

   int a = a;

gcc (with no extra options) tcc and bcc both put some undefined value in a.

gcc won't warn until you say '-Wextra', and then only for:

   int a = a + 1;