Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <val7m1$3374n$1@dont-email.me>
Deutsch   English   Français   Italiano  
<val7m1$3374n$1@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: Bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: on allowing "int a" definition everywhere
Date: Tue, 27 Aug 2024 19:59:13 +0100
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <val7m1$3374n$1@dont-email.me>
References: <afdfe7c37c6ad739fd82c7ec0587b82e0963fce2@i2pn2.org>
 <va3n09$3nnl8$1@dont-email.me>
 <f693bfded5f8fec712a445d88ebe34419e0f7072@i2pn2.org>
 <vajt3u$2so1b$2@dont-email.me>
 <7ea05965a67fa09d4ebd0b6ec53109dcb0b12f76@i2pn2.org>
 <3775b5abd14443f89852e05177a44bd72585cbdd@i2pn2.org>
 <4c7a695b1b755393162a1ae36ea6306760ffe949@i2pn2.org>
 <de38f0ff40f8eb2354905d74c107c507c67ba7a3@i2pn2.org>
 <41520456e45d778ea26805f6f711a05757365bc3@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 27 Aug 2024 20:59:13 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="0eb40e535de99d049ec5580a004404e4";
	logging-data="3251351"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/R6rQYSZp31dR3JPSALpBX"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:DmFAbdQQJgBnN7bwlsduMe5ZKDo=
In-Reply-To: <41520456e45d778ea26805f6f711a05757365bc3@i2pn2.org>
Content-Language: en-GB
Bytes: 3055

On 27/08/2024 19:44, fir wrote:
> fir wrote:

>> on fictional snippet (probebly not working)
>>
>> void draw_line( float x, float y, float x2, float y2, unsigned color)
>> {
>>      float
>>       wx=dist(x,x2),wy=dist(y,y2); int m=wx<wy?wx:wy;
>>       float dx=wx/m,dy=wy/m;for(int
>> i=0;i<(int)m;i++)set_pixel(x+=dx,y+=dy,color);
>> }
>>
>> thin skin
>>
>> draw_line`x`y`x2`y2`color
>> {
>>      `wx=dist x x2,`wy=dist y y2,`M=(wx<wy?wx!wy)
>>      `dx=wx/m,`dy=wy/m, M'set_pixel x+=dx y+=dy color;
>> }
>>
> though eventualy it canm be written shorter i guess
> 
>   draw_line`x`y`x2`y2`color:
>   `m = min 'wx=abs x2-x 'wy=abs y2-y) ' set_pixel x+=wx/m y+=wy/m color;
>   ;
> 
> not to say it lookin specially good but welll..

There are ways to have more compact syntax without it turning weird, 
leaving out types, and using backtick separators and other strange 
punctuation (or is that lone ')' a typo?).

Start with this version:

   void draw_line( float x, float y, float x2, float y2, unsigned color)
   {
       float
        wx=dist(x,x2),wy=dist(y,y2); int m=wx<wy?wx:wy;
        float 
dx=wx/m,dy=wy/m;for(inti=0;i<(int)m;i++)set_pixel(x+=dx,y+=dy,color);
  }

For example:

    void draw_line(f32 x, y, x2, y2; u32 colour) {
        f32 wx = dist(x, y2), wy = dist(y, y2)
        int m = min(wx, wy)
        repeat m {
            set_pixel(x += wx/m, y += wy/m, colour)
        }
    }

Summary:

- Allow shared types in parameter lists
- Auto semicolon insertion
- Built-in 'min/max' operators
- New repeat-n-times loop
- Shorter type names