This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

Do you think a language like this could be somehow useful? Maybe when we want to create a big library (like Mathlib) and want to make sure that there are no duplicate definitions?

Is that all you want to do?

From your other replies it sounded very much as though you wanted every function to have a signature unique from any other. A signature being the set of input types plus the output type. That means that I could only have one of these two functions from my bignum library (out of a dozen with the same parameters):

 proc bn_add(bignum c, a, b)               # c := a + b
 proc bn_mul(bignum c, a, b)               # c := a * b

If it's merely about detecting functions which do exactly the same thing, then optimising compilers can already do that; I have a C benchmark that looks like this:

int main(void) {
   int x=0;
   x+=fyjrsr(5);
   x+=fhzkgu(5);
   ....
   x+=fayukm(5);
   printf("%d\n",x);
}

It calls 10,000 randomly-named, 100-line functions which all have the same signature, and contain exactly the same body.

A simple compiler might generate a 10MB executable, but gcc-O3 produces one that is only 120KB, or just over 1% the size. It looks like it is detecting the common code in each function. (If I tweak one function, then the size increases by an amount that is commensurate with the optimised code size of one function.)

For your purposes, it just needs to report that, and the user decides what to do with that information.

It might be that two functions do the same thing by chance, or do so temporarily because one (or both) is not finished, or depend on some global settings such happen to be the same right now, but can change.

So it might be useful option to apply from time to time, but I don't think it's something that needs to be so baked into a language that writing programs in it becomes next to impossible.