Get the latest tech news
The Inevitability of the Borrow Checker
When defining a type in Inko, it's allocated on the heap by default. For example (using the syntax for the upcoming 0.18.0 release): type User { let @id: Int let @username: String let @email: String } User(id: 42, username: 'Alice', email: 'alice@example.com') Here User is a heap allocated type, and the expression User(...) allocates an instance of this type using the system allocator (i.e.
This can then result in memory safety issues, such as by assigning the inline field a new value before returning from the update method as shown above. While this might work, I'm not a fan of using runtime checks for cases like this due to the potential overhead, and that debugging such issues will likely be a frustrating experience. For example, Inko's standard library provides such a BufferedWriter type and it defines a destructor, meaning we can't apply the above pattern.
Or read this on Hacker News