Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #1910
| From | "BartC" <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: repeating something n times |
| Date | 2012-07-06 21:56 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <jt7jdv$247$1@dont-email.me> (permalink) |
| References | <repeat-20120705210751@ram.dialup.fu-berlin.de> |
"Stefan Ram" <ram@zedat.fu-berlin.de> wrote in message news:repeat-20120705210751@ram.dialup.fu-berlin.de... > It is funny how many languages fail to give a means to > repeat something n times. > > In Logo, one can write: > > repeat 4 > to repeat something 4 times, but in C one needs Some languages just don't seem to like syntax! Any syntax of mine *always* has a construction for infinite loops, followed by one for N-times loops, even before there are indexed for-loops and while, repeat and so on. They are just fundamental. However, C-derived syntaxes rarely seem to add anything to the basic loop form from four decades ago. do body... end to 4 do body... end > for( int i = 0; i < 3; ++i ) > > , where the need to introduce a variable in the source code > seems redundant in this case and more troublesome and error-prone. C is a good example where they seem to like redundancy (so you have to write the loop-index 3 times even though it's never used). When this is put to the C guys, they might say, Oh the compiler will reduce it down to the minimum looping instructions needed if the 'i' index is not used. (But then, this is the contrary to the usual way a compiler works, ie. expressing exactly what is wanted then the compiler fills in whatever complicated code is needed. In C, the programmer writes things out the long way, and the compiler simplifies it!) Or, they will come up with some dodgy macro to expand such as REPEAT() to achieve the same. Or perhaps a while-loop can be used too. So there are a number of excuses why they shouldn't add such a feature to the language. Probably there are similar arguments for others. Certainly, any language *will* allow you to repeat something four times, in some way or another, so it's not seen as a pressing issue. -- Bartc
Back to comp.programming | Previous | Next — Next in thread | Find similar
Re: repeating something n times "BartC" <bc@freeuk.com> - 2012-07-06 21:56 +0100
Re: repeating something n times Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-07-06 22:16 +0100
Re: repeating something n times "BartC" <bc@freeuk.com> - 2012-07-06 23:18 +0100
Re: repeating something n times malcolm.mclean5@btinternet.com - 2012-07-14 14:11 -0700
Re: repeating something n times "BartC" <bc@freeuk.com> - 2012-07-14 23:11 +0100
Re: repeating something n times Ike Naar <ike@iceland.freeshell.org> - 2012-07-14 23:37 +0000
Re: repeating something n times "BartC" <bc@freeuk.com> - 2012-07-15 01:16 +0100
Re: repeating something n times malcolm.mclean5@btinternet.com - 2012-07-14 17:35 -0700
Re: repeating something n times Aaron W. Hsu <arcfide@sacrideo.us> - 2012-07-14 22:23 -0500
Re: repeating something n times Aaron W. Hsu <arcfide@sacrideo.us> - 2012-07-14 22:19 -0500
Re: repeating something n times "BartC" <bc@freeuk.com> - 2012-07-15 11:00 +0100
Re: repeating something n times malcolm.mclean5@btinternet.com - 2012-07-14 17:44 -0700
Re: repeating something n times Aaron W. Hsu <arcfide@sacrideo.us> - 2012-07-14 22:17 -0500
Re: repeating something n times "BartC" <bc@freeuk.com> - 2012-07-15 11:49 +0100
Re: repeating something n times Aaron W. Hsu <arcfide@sacrideo.us> - 2012-07-15 09:53 -0500
Re: repeating something n times Rui Maciel <rui.maciel@gmail.com> - 2012-07-15 12:18 +0100
Re: repeating something n times "BartC" <bc@freeuk.com> - 2012-07-15 13:21 +0100
Re: repeating something n times Willem <willem@toad.stack.nl> - 2012-07-15 13:02 +0000
Re: repeating something n times "BartC" <bc@freeuk.com> - 2012-07-15 14:36 +0100
Re: repeating something n times Willem <willem@toad.stack.nl> - 2012-07-15 14:18 +0000
Re: repeating something n times "BartC" <bc@freeuk.com> - 2012-07-15 15:45 +0100
Re: repeating something n times Willem <willem@toad.stack.nl> - 2012-07-15 16:25 +0000
Re: repeating something n times "BartC" <bc@freeuk.com> - 2012-07-15 18:02 +0100
Re: repeating something n times Rui Maciel <rui.maciel@gmail.com> - 2012-07-15 15:10 +0100
Re: repeating something n times "BartC" <bc@freeuk.com> - 2012-07-15 16:10 +0100
Re: repeating something n times malcolm.mclean5@btinternet.com - 2012-07-15 13:00 -0700
Re: repeating something n times Aaron W. Hsu <arcfide@sacrideo.us> - 2012-07-14 21:55 -0500
Re: repeating something n times "io_x" <a@b.c.invalid> - 2012-07-17 20:47 +0200
Re: repeating something n times "io_x" <a@b.c.invalid> - 2012-07-18 14:19 +0200
Re: repeating something n times Aaron W. Hsu <arcfide@sacrideo.us> - 2012-07-18 12:55 -0500
Re: repeating something n times malcolm.mclean5@btinternet.com - 2012-07-18 11:57 -0700
csiph-web