Hacker News new | ask | show | jobs
by Spex_guy 1154 days ago
> If the type system is uncomputable, then the type system will never be able to resolve all uses of function pointers everywhere.

Can you elaborate on what you mean here, and the problems this might cause? Do you mean that some function pointers cannot be resolved to concrete functions? Or that the process of evaluating comptime may be infinite? Or some other problem where the compiler can't determine whether a function pointer is needed for a given function?

1 comments

These are great questions.

All of the above, actually.

Turing-completeness and the uncomputability thereof are widespread, easy to build, hard to keep away, and affects everything that might happen at runtime.

A list of things that can happen is infinite, but that list absolutely includes:

* Whether a particular function pointer resolves to certain functions,

* Whether evaluating the comptime portion of a Zig program will take forever,

* Whether the compiler fails to exclude a particular function from being used as a function pointer at a particular place.

Turing-completeness is a wildly powerful property, but that power is not free; the inability to figure out what might happen in a program is only just the biggest and most apparent cost.

The problems this might cause can be summarized like this: you can never know what a program will do for a given set of inputs until you run the program on those inputs, and even then, you might never know if the program never halts.

Does that make sense?

> Whether a particular function pointer resolves to certain functions

This is only a turing completeness issue if the list of functions is infinite. It is not, in zig.

You don't need an infinite list of functions to run into the problems with Turing-completeness. You only need effectively infinite behavior, which means all you need is effectively infinite possible inputs.
this is simply untrue. I'm sorry. I recommend studying math a bit more rigorously before making claims in the future.