Hacker News new | ask | show | jobs
by sparkie 459 days ago
You would need first-class functions (closures). This might work for the example you've given where we pass in a string - a non-linear value.

However, consider the case where we might partially apply a linear value - the value will be consumed and stored as part of the closure object - but linear values can only be contained in linear types - which would mean that the function itself must also become linear - and then you would only be able to use it once. These would be "one-shot" functions - because calling them would consume them. You would only be able to use them once - and if you wanted to reuse them, you would have to return a new function to replace the old one each time you call it.