Deutsch English Français Italiano |
<vjr6dn$1j57r$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!.POSTED!not-for-mail From: BGB <cr88192@gmail.com> Newsgroups: comp.lang.c Subject: Re: transpiling to low level C Date: Tue, 17 Dec 2024 00:40:54 -0600 Organization: A noiseless patient Spider Lines: 76 Message-ID: <vjr6dn$1j57r$1@dont-email.me> References: <vjlh19$8j4k$1@dont-email.me> <vjn9g5$n0vl$1@raubtier-asyl.eternal-september.org> <vjnhsq$oh1f$1@dont-email.me> <vjnq5s$pubt$1@dont-email.me> <vjpn29$17jub$1@dont-email.me> <vjps0l$18hon$1@dont-email.me> <vjq36r$19sis$1@dont-email.me> <vjqcut$1bld5$1@dont-email.me> <877c7z85t2.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 17 Dec 2024 07:40:55 +0100 (CET) Injection-Info: dont-email.me; posting-host="10e7c9ead457ab57c374f57f86cb174f"; logging-data="1676539"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/4k9YdvqqRcWBlKnNvA25jyIC9/OD00WQ=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:Y/6c9XiSlP0kBrUf/flqSc38rzE= Content-Language: en-US In-Reply-To: <877c7z85t2.fsf@nosuchdomain.example.com> Bytes: 3765 On 12/16/2024 7:19 PM, Keith Thompson wrote: > bart <bc@freeuk.com> writes: > [SNIP] >> In that case I've no idea what you were trying to say. >> >> When somebody says that 'goto' can emulate any control structure, then >> clearly some of them need to be conditional; that is implied. >> >> Your reply suggested they you can do away with 'goto', and use >> recursive functions, in a scenario where no other control structures >> need exist. >> >> OK, if this is not for an IL, then it's not a language I would care >> for either. Why tie one hand behind your back for no good reason? > > I read Janis's post. I saw a suggestion that certain constructs are > *theoretically* unnecessary. I saw no suggestion of any advocacy for > such an approach. > > """ > A 'goto' may be used but it isn't strictly *necessary*. What *is* > necessary, though, that is an 'if' (some conditional branch), and > either 'goto' or recursive functions. > """ > While if-call is technically possible, it is likely to result in a significantly higher performance overhead if compared with if-goto. Say: if-goto: can be a single CPU instruction on some targets. Both RISC-V and BJX2 can do single-instruction compare-and-branch. if-call: A whole lot more than 1 instruction... One may have call/return, stack frame creation, ... Or, a backend that is very clever about inlining. Also: if-goto can readily express pretty much every other intra-function control flow construct: for, while, switch, break, continue, ... And, is less awkward for a compiler than trying to map control flow to any of the other constructs. Also it is generally the fastest construct for implementing these higher level constructs. Meanwhile, if-call, good luck... You are also going to need something beyond normal C style variable scoping to make this work acceptably. At best, it is likely to be very awkward and likely to perform poorly. Though, it is possible that one could make a case for a 3-way branch operator in the IR, say: if3(x,y) A, B, C Which does the equivalent of, say: if(x<y)goto A; else if(x>y)goto B; else goto C; This would be a bit niche, but could be useful for things like implementing "switch()" via binary subdivision. Though, functionally could decay into normal if-goto in various cases. .... > [...] > >> So what was your proposal about? > > I saw no proposal. >