Deutsch   English   Français   Italiano  
<vkbkf6$16qt0$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: transpiling to low level C
Date: Mon, 23 Dec 2024 13:18:46 +0100
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <vkbkf6$16qt0$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> <86ikrdg6yq.fsf@linuxsc.com>
 <vk78it$77aa$1@dont-email.me> <vk8a0e$l8sq$1@paganini.bofh.team>
 <vk9q1p$oucu$1@dont-email.me> <vkb81n$14frj$1@dont-email.me>
 <vkbhuq$1633q$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 23 Dec 2024 13:18:48 +0100 (CET)
Injection-Info: dont-email.me; posting-host="4541fb8706e33f0d382046069d49cfc8";
	logging-data="1272736"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19tohY0IY2hc1h1wIXJMpzf4885y9qm/LA="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.11.0
Cancel-Lock: sha1:BQw6UQYSq9jVADrSzRVD3KS3VYo=
In-Reply-To: <vkbhuq$1633q$1@dont-email.me>
Content-Language: en-GB
Bytes: 3089

On 23/12/2024 12:35, bart wrote:
> On 23/12/2024 08:46, David Brown wrote:
> 
>> Tim ruled out &&, ||, ?:, goto, break, continue, if, for, while, 
>> switch, do, labels, setjmp and longjmp.
>>
>> He didn't rule out recursion, or the relational operators, or any 
>> other part of C.
>>
>>
>> int fact(int n);
>>
>> int fact_zero(int n) {
>>          return 1;
>> }
>>
>> int n_fact_n1(int n) {
>>          return n * fact(n - 1);
>> }
>>
>> int fact(int n) {
>>          return (int (*[])(int)){ fact_zero, n_fact_n1 }[(bool) n](n);
>> }
>>
>>
>> There are additional fun things that can be done using different 
>> operators.  For an unsigned integer "n" that is not big enough to 
>> wrap, "(n + 2) / (n + 1) - 1"  evaluates "(n == 0)".
> 
> Isn't this just !n ? I don't think "!" was ruled out. This would also 
> work for negative n.

Sure.  It was merely another example of something you could use, if you 
had ruled out simpler things (like the conversion to bool that I used, 
or the ! operator that you suggest).


> 
>> And Tim did not rule out using the standard library, which would 
>> surely open up new possibilities.
> 
> printf (not sprintf) would be reasonable here to show results. Anything 
> else could be considered cheating.
> 

No, I would not say so - as long as the standard library is not ruled 
out, it is part of C.  But I think you could reasonably argue that 
allowing the standard library makes this whole pointless exercise even 
more pointless!

> The original context was a small subset of C that can be used to 
> represent a larger subset.