🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1425

Re: p = {1,0,0}

#1425
From: bartc
Date: Tue, 10 Nov 2026 14:27
116 lines
4917 bytes
On 10/11/2026 12:51, fir wrote:
> bartc pisze:
>>
>>    for i=1,100 {tab[i]=0}
>>
>>
> 
> this on i dont like better woud be imo
> 
>   for i = 1 to 100 {tab[i]=0}
> 
> but still it feels too much basic

I'd considered using 1..100 and 1 to 100 but your aim seemed to be 
conciseness. "1,100" is used in Lua.


> there are quite few subtle things here what given form gives what feelings
> 
> note in c that has no loop there is like no "natural" form of loop
> (unles maybe just raw goto etc) at least i dont see it
> 
> this one wth power may be koncidered as somewhat natural
> 
> {  } ^ t

I once used this:

   (n || s)

for repeat-N-times. I decided that was too quaint.

(If a loop were to return a value, as happens in some languages, then 
such a compact form can be desirable to use within expressions.)

>   a..b @ i {}
> 
> (i slightly prefer here a..b ^ i {} right now but the exact symbol 
> choices can be deferred)
Have you considered what the construct 'x .. y', if it was part of the 
syntax, could have lots of different uses. For example:

    if x in a..b       # test a within a range
    A[i..j]            # slicing

So it would not be obvious that a..b introduces a loop. I assume that 
'a..b @ i {}' means this in my own syntax:

   for i in a..b do end

Which one do you think is clearer? Further, it is possible to do

   for i in x do end

where 'x' might be a range defined elsewhere, or some collection. Now 
that '..' cue is missing since you'd have to write 'x @ i {}'. But in 
your next example ...


> //i also konsidered
> 
> a..b {tab[%1]=k}

the @i is also missing so you basically have:

   x {}

Wasn't this the syntax for your composite struct/function definition?

> 
> //%1 being replcement for i - but i has good tradition in c
> // but maybe it could be also present as an alternative solution
> 
> so right now from those considerations the ground im standing
> as to loops would be that
> 
> 1..29𝐭{tab[𝐭]=9}
> 
> 1..29 ^ t  {tab[t]=9}
> 
> 1..29 {tab[%1]=9}
> 
> // maybe 1..29 ^ {tab[%1]=9}
> //maybe ^ t =1..29  {tab[%1]=9}
> // alternatively {tab[%1]=9} ^ t= 1..76

In practice you don't have many fixed ranges like this; the upper limit 
is usually tied to the bounds of 'tab', so how would that look? Maybe:

    for &x in tab {x = 9}

where the '&x' means that x is a writeable reference to the element. 
(C++ might have this.)

> //well in combination with power this assigment dont look bad here
> 
> maybe this also?
> ^ t=1..29 {tab[t]=9}
> allows
> 
> ^ t = {2,7,9,7,2,4,5} {f(t)}
> 
> //allows calls like f(2);f(7);f(9);f(7);f(2); f(4); f(5);

This is still just a form of:

    for x in tab {}

For example:

    for x in (2,7,9,7,2,4,5) {f(x)}

But this is more high-level. Just look at some other languages; it's all 
been done!

Technical Details
Message-ID: <11cv9kd$27cfo$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11c7f1j$20b9h$1@dont-email.me> <11c7fj6$20gab$1@dont-email.me> <11cae5m$318tq$1@dont-email.me> <11calrt$34gq3$1@dont-email.me> <11carqs$36m0o$1@dont-email.me> <11cb4hs$3a13l$1@dont-email.me> <11ccnkq$3pjhd$1@dont-email.me> <11ccobd$3ps4l$1@dont-email.me> <11cctee$3rtjh$1@dont-email.me> <11ccu0t$3s54f$1@dont-email.me> <11ccv4n$3sjn5$1@dont-email.me> <11cd05l$3t1er$1@dont-email.me> <11cd0q3$3ta28$1@dont-email.me> <11cd1vs$3tpfp$1@dont-email.me> <11cnve1$3ofei$1@dont-email.me> <11co8d4$3rpvm$1@dont-email.me> <14be9ea5-918f-5871-1bba-11e29e6e25d5@gmail.com> <11coqot$1236$1@dont-email.me> <11cplsf$8nc4$1@dont-email.me> <11cpnbb$97kp$1@dont-email.me> <11cpo21$9fji$1@dont-email.me> <11cpov5$9q2h$1@dont-email.me> <11cq3hb$dnf9$1@dont-email.me> <11ctijh$1mb1u$1@dont-email.me> <11ctr0o$1or07$1@dont-email.me> <11cv41a$2582a$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: bartc <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: p = {1,0,0}
Date: Tue, 10 Nov 2026 14:27:24 +0000
Organization: A noiseless patient Spider
Lines: 116
Message-ID: <11cv9kd$27cfo$1@dont-email.me>
References: <11c7f1j$20b9h$1@dont-email.me> <11c7fj6$20gab$1@dont-email.me>
 <11cae5m$318tq$1@dont-email.me> <11calrt$34gq3$1@dont-email.me>
 <11carqs$36m0o$1@dont-email.me> <11cb4hs$3a13l$1@dont-email.me>
 <11ccnkq$3pjhd$1@dont-email.me> <11ccobd$3ps4l$1@dont-email.me>
 <11cctee$3rtjh$1@dont-email.me> <11ccu0t$3s54f$1@dont-email.me>
 <11ccv4n$3sjn5$1@dont-email.me> <11cd05l$3t1er$1@dont-email.me>
 <11cd0q3$3ta28$1@dont-email.me> <11cd1vs$3tpfp$1@dont-email.me>
 <11cnve1$3ofei$1@dont-email.me> <11co8d4$3rpvm$1@dont-email.me>
 <14be9ea5-918f-5871-1bba-11e29e6e25d5@gmail.com>
 <11coqot$1236$1@dont-email.me> <11cplsf$8nc4$1@dont-email.me>
 <11cpnbb$97kp$1@dont-email.me> <11cpo21$9fji$1@dont-email.me>
 <11cpov5$9q2h$1@dont-email.me> <11cq3hb$dnf9$1@dont-email.me>
 <11ctijh$1mb1u$1@dont-email.me> <11ctr0o$1or07$1@dont-email.me>
 <11cv41a$2582a$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 10 Nov 2026 14:27:25 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2339320"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19IpIjZA3zkJ+IKDAuW4Mjg"; posting-host="4695183c8b99665fc19e8d6c8d0d67a8"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:SGADAL/1wYI6puYcJJdlErD2uAg= sha256:qIvMxywNAghVtlW22kJJTVkqsKJVRCWH0Qgpw8FgQus=
	sha1:UO25kNs1UDOdr91E+pffiUKUi9g= sha256:hJ23nZsv1/CG3Qd1p1iv8Ex9E1aKqfJwUWaOKyfoT0I=
In-Reply-To: <11cv41a$2582a$1@dont-email.me>
Content-Language: en-GB