Liste des Groupes | Revenir à cl c |
fir wrote:though eventualy it canm be written shorter i guessfir wrote:>fir wrote:>Lawrence D'Oliveiro wrote:>On Sun, 25 Aug 2024 12:40:39 +0200, fir wrote:>
>Lawrence D'Oliveiro wrote:>
>Somehow along the line from BCPL to B to C, one useful feature wasif so thats probably sad, though i dont know how it looked like
lost: the ability to have a value-returning statement block
inside an
expression.
>
The construct looks like
>
VALOF $( ... «stmts»; RESULTIS «return-value» $)
>
it is good to things return value and good to be able to combine it
>
as i sait for example i consider such loops
>
10'x //ten tiem execute x
>
print (10'x+=x)/10
>
would be equivalent of
>
for(int i=0; i<10; i++) x+=x;
print(x/10)
>
(and its still c, just with shorted syntax not python et sort)
>
>
as to this loop as i said i had no ide how to make indexes like i
in this form but what comes to my mind now is maybe something lika
>
>
10'print("x")
>
10i'print(i)
>
>
480y' 640x' set_pixel(x,y, 0xffff00)
>
those i,x,y in loop 'headers' could be possibly subscripted
like 2 in typical H20 (2 is subscripted
>
eventually one can go
>
10' print((x 0)++)
>
where x 0 is initialisation of int x to zero
>
>
overally not bad, i could somewhat accept that loop
(yu wouldnt belive how hard is come to that syntax conclusions,
literally takes years, and not 5 years more like 15)
>
>
i wanted to compore how many chars my thin c skin conventions would
make (but not having funic F for wloat or runic U for unsigned) i put `
and the spare is not great becouse c is quite thin - hovever it uses a
lot of what i call 'decorators i eman not necessary ().; which could
be changed to spaces, it not spares chars but somewhat spares ink
>
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;
}
>
Les messages affichés proviennent d'usenet.