5 ms·
Yeah. it's not new. basically every programming language that respects itself has it in the form of: - with blah do x - using blah do x - try(blah) {
by mirceal 11y ago
Yeah. it's not new.
basically every programming language that respects itself has it in the form of:
- with blah do x
- using blah do x
- try(blah) { do x }
- File.open(blah, 'w') {|f| f.write(x) }
- there are even GCC C complier extension to hook in behavior like this
It's all over the place. Everything is new and old at the same time
- coldtea 11y agoWhich is just a small subset of what he talks about. Even the specific example he gives is NOT about recourse management (which is what the things you mention do).
- lnanek2 11y agoOne of the things he suggests is resource management, though, the file example. It would also be trivial to implement his vector sum example with syntactic sugar designed for resource management. E.g. in Java's try with you would just square in the constructor of something that implements closeable, sum in the try-with block, then square root in the close method. Ruby is even easier since you would just pass a block into a method and the method could do pre and post operations before running the block. In both cases these things are usually used for resource management, but they can easily be used for this.
- coldtea 11y agoYou missed the part where the reverse operation is inferred automatically -- not just written explicitly to run in the end.