Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Linear types are shit

Name: Anonymous 2014-12-02 10:58

While all the Rust-faggots and ATS-faggots are running around with their linear types dildo, the Imperative Lords have already solved the same problem much more simply. Their solution consists of just two simple ingredients: static single assignment (SSA) and const pointers. Check it out:

int foo(int* arr);
...

int[] arr = {1, 2};
foo(arr);
print(arr[0]); // Compile-time error! But it would be OK if foo took a (const int* arr).


How do you mutate that array then? With SSA:

int foo(int* arr);
...

int[] arr = {1, 2};
foo(arr ~> arrMutated);
print(arrMutated[0]);


That's right, the binding to the mutated array just goes out of scope immediately after mutation, so there's no way to access it anymore. And in the call, you just provide a new binding for that same array (the compiler would issue a warning if you didn't) which goes into scope immediately after that same call. No new types needed! None of that type-theoretic bullshit and code duplication!

I wonder why no one ever thought of that.

Name: Anonymous 2014-12-02 12:19

How do you use global vars then, genius?

Name: Anonymous 2014-12-03 4:41

~>

You better straighten that arrow, faggot.

Name: Anonymous 2014-12-03 13:00

foo(arr ~> arrMutated);
~>
Hehe, a sperm operator.

Don't change these.
Name: Email:
Entire Thread Thread List