Path: ...!news.misty.com!weretis.net!feeder9.news.weretis.net!i2pn.org!i2pn2.org!.POSTED!not-for-mail From: fir Newsgroups: comp.lang.c Subject: Re: on allowing "int a" definition everywhere Date: Thu, 29 Aug 2024 09:37:11 +0200 Organization: i2pn2 (i2pn.org) Message-ID: <73522f429bacaabc5bab78bd164ba77d83f2e45b@i2pn2.org> References: <7ea05965a67fa09d4ebd0b6ec53109dcb0b12f76@i2pn2.org> <3775b5abd14443f89852e05177a44bd72585cbdd@i2pn2.org> <4c7a695b1b755393162a1ae36ea6306760ffe949@i2pn2.org> <41520456e45d778ea26805f6f711a05757365bc3@i2pn2.org> <7e4b0b0d918b2fb5c392edf927ccb1f82e28e322@i2pn2.org> <28f282d59a73bdc9a8fd808ebd2aefb89065bd5b@i2pn2.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 29 Aug 2024 07:37:14 -0000 (UTC) Injection-Info: i2pn2.org; logging-data="112200"; mail-complaints-to="usenet@i2pn2.org"; posting-account="+ydHcGjgSeBt3Wz3WTfKefUptpAWaXduqfw5xdfsuS0"; User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24 In-Reply-To: <28f282d59a73bdc9a8fd808ebd2aefb89065bd5b@i2pn2.org> X-Spam-Checker-Version: SpamAssassin 4.0.0 Bytes: 3608 Lines: 85 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>>> float dx=wx/m,dy=wy/m;for(int >>>> i=0;i<(int)m;i++)set_pixel(x+=dx,y+=dy,color); >>>> } >>>> >> > > > i thought on it yet and concluded code for that shopuld look more like > > point {ints x y} > line {points p q} > draw line(color c) > { > point a = p > int m = max abs(q-p) ' a+=(q-p)/m, Setpixel a, c > } > > > explanation: > > point {ints x y} > > this is structure "point" definition , > ints is int[] but it also has named elements so int[0[ is x and int[1] > is y (such is very handy as structure may be seen as array and array as > structure.. so more fractal touch added (if it is proper name fractal > touch as maybe not im not sure) i noticed it today that int a,b,c in old c is wrong it should be ints ints a b c moreover as obave written the acces shpould be by fielda but also array way here this a b c is like nonamed structure so you cant acces it array way but put it into name point {ints a b c} and then you can acces both ways > > line {points p q} > > same this is structure named "line" defined > > draw line(color c) > > this is function header though line here is a type so its > a bit new in that aspect possibly > > point a = p > > instantiates point structure entity named a and copies p into it > > as p is point in line and p is int2 type and int2 has defined assigning > to other int2 so this is automatic > > int m = max abs(q-p) > > same here q-p are int2 - int2 they are defined to retuirn int2 > abs is defined on int2 to return two int2 values then max is defined > on int2 to return one int > > m' is loop (loop m times) > this a+=(q-p)/m, is calculation, i know it will not work as > it shopuld work on floats but for simplicity of example as i was thinkin > on ints i will stay it with ints > > overally this is kinda closer to C2 syntax i need