Liste des Groupes | Revenir à cl c |
On 12/28/2024 11:24 AM, Tim Rentsch wrote:
>BGB <cr88192@gmail.com> writes:>
>On 12/23/2024 3:18 PM, Tim Rentsch wrote:>
>Michael S <already5chosen@yahoo.com> writes:>
>On Mon, 23 Dec 2024 09:46:46 +0100>
David Brown <david.brown@hesbynett.no> wrote:
>And Tim did not rule out using the standard library,>
Are you sure?
I explicitly called out setjmp and longjmp as being excluded.
Based on that, it's reasonable to infer the rest of the
standard library is allowed.
>
Furthermore I don't think it matters. Except for a very small
set of functions -- eg, fopen, fgetc, fputc, malloc, free --
everything else in the standard library either isn't important
for Turing Completeness or can be synthesized from the base
set. The functionality of fprintf(), for example, can be
implemented on top of fputc and non-library language features.
If I were to choose a set of primitive functions, probably:
malloc/free and/or realloc
could define, say:
malloc(sz) => realloc(NULL, sz)
free(ptr) => realloc(ptr, 0)
Maybe _msize and _mtag/..., but this is non-standard.
With _msize, can implement realloc on top of malloc/free.
>
For basic IO:
fopen, fclose, fseek, fread, fwrite
>
printf could be implemented on top of vsnprintf and fputs
fputs can be implemented on top of fwrite (via strlen).
With a temporary buffer buffer being used for the printed string.
Most of these aren't needed. I think everything can be
done using only fopen, fclose, fgetc, fputc, and feof.
If you only have fgetc and fputc, IO speeds are going to be
unacceptably slow for non-trivial file sizes.
Les messages affichés proviennent d'usenet.