Deutsch English Français Italiano |
<20240317095014.365@kylheku.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <433-929-6894@kylheku.com> Newsgroups: comp.lang.c Subject: Re: filling area by color atack safety Date: Sun, 17 Mar 2024 17:11:44 -0000 (UTC) Organization: A noiseless patient Spider Lines: 42 Message-ID: <20240317095014.365@kylheku.com> References: <ut3669$21eur$1@i2pn2.org> <ut4020$2s8ov$1@dont-email.me> <87wmq2jn7s.fsf@bsb.me.uk> <ut4ba7$2uits$1@dont-email.me> <87frwpje2b.fsf@bsb.me.uk> <ut6o5l$3h3cb$3@dont-email.me> Injection-Date: Sun, 17 Mar 2024 17:11:44 -0000 (UTC) Injection-Info: dont-email.me; posting-host="864941e21c918841c5381afe3a2ae04e"; logging-data="3823714"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UU6WAm/926QXyYZ0sc5ncLTOqxQ2Z9s8=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:opRRttq8ML5imt17Ea8INHtBA3E= Bytes: 3092 On 2024-03-17, Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote: > The convetional wisdom is the opposite, But here, conventional wisdom > fails. Because heaps are unlimited whilst stacks are not. The strawman, absolutist conventional wisdom that "recursion is always easier to analyze than iteration" is wrong in the first place. Any program graph based on nothing but IF and GOTO primitives can be mechanically transliterated into a (tail) recursive structure that has the same shape, and is no easier to understand. Your point is not very well made, though. Even though recursion may run into a resource limit, its structure can still help analyze the logic of the algorithm apart from that resource issue. The resource issue can be separately analyzed and provisions made for the algorithm to handle the required inputs, and reject others. Most algorithms (especially ones working with all inputs in memory) are constrained by resources. The iterative version of that image processing algorithm might handle larger images than the recursive one, but there are yet image sizes it won't handle. The idea of calling algorithm implementations "incorrect" if they have any limitations on their input sizes and such isn't particularly informative or useful. Obviously it is incorrect if something has limitations, and is used in such a way that they are exceeded. E.g. the C <int> + <int> operation when a result is implied that is beyond INT_MIN or INT_MAX. Oops, + is not "correct"; don't use it! Now, there is a bit of value in algorithms that will successfully operate on any object that was successfully fit into memory. Do these really exist though? Pretty much any algorithm implementation requires some space to do its work, even if that space is small and fixed. It's possible that the input fit into memory, yet that small and fixed amount of space is not available. -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca