| Deutsch English Français Italiano |
|
<vmaig9$3ehn7$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Terje Mathisen <terje.mathisen@tmsw.no> Newsgroups: comp.arch Subject: Re: Segments Date: Thu, 16 Jan 2025 10:11:36 +0100 Organization: A noiseless patient Spider Lines: 36 Message-ID: <vmaig9$3ehn7$1@dont-email.me> References: <vdlgl9$3kq50$2@dont-email.me> <vdtmv9$16lu8$1@dont-email.me> <2024Oct6.150415@mips.complang.tuwien.ac.at> <vl7m2b$6iat$1@paganini.bofh.team> <2025Jan3.093849@mips.complang.tuwien.ac.at> <vlcddh$j2gr$1@paganini.bofh.team> <2025Jan5.121028@mips.complang.tuwien.ac.at> <vleuou$rv85$1@paganini.bofh.team> <ndamnjpnt8pkllatkdgq9qn2turaao1f0a@4ax.com> <2025Jan6.092443@mips.complang.tuwien.ac.at> <vlgreu$1lsr9$1@dont-email.me> <vlhjtm$1qrs5$1@dont-email.me> <bdZeP.23664$Hfb1.16566@fx46.iad> <vlj1pg$25p0e$1@dont-email.me> <87cygo97dl.fsf@nosuchdomain.example.com> <vm7mvi$2rr87$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 16 Jan 2025 10:11:37 +0100 (CET) Injection-Info: dont-email.me; posting-host="7b1eff93cc1ab65d539917eea199ebda"; logging-data="3622631"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18/knJz3nNxQQAb+Sk++3fDiYdID5kGChx+6INqseQsmA==" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19 Cancel-Lock: sha1:/JIOhFR2IBPnNM+b67torPpBHQU= In-Reply-To: <vm7mvi$2rr87$1@dont-email.me> Bytes: 2937 Thomas Koenig wrote: > Keith Thompson <Keith.S.Thompson+u@gmail.com> schrieb: >> Thomas Koenig <tkoenig@netcologne.de> writes: >> [...] >>> CHERY targets C, which on the one hand, I understand (there's a >>> ton of C code out there), but trying to retrofit a safe memory >>> model onto C seems a bit awkward - it might have been better to >>> target a language which has arrays in the first place, unlike C. >> [...] >> >> C does have arrays. > > Sort of - they decay into pointers at first sight. > > But what I should have written was "multi-dimensional arrays", > with a reasonable way of handling them. > Rust provides an interesting data point here: It has Vec<> which is always implemented as a dope vector, i.e. a header which contains the starting point and current length, along with allocated size. For multidimendional work, the natural mapping is Vec<Vec<>>, i.e. similar to classic C arrays of arrays, but with boundary checking. However, in my own testing I have found that it is often faster to flatten those multi-dim vectors, and instead use explicit multiplication to get the actual position: array[y][x] -> array[y*width + x] Terje -- - <Terje.Mathisen at tmsw.no> "almost all programming can be viewed as an exercise in caching"