News for hackers. Stuff that matters.
Re:Microfeatures I'd like to see in more languages by masklinn on Thursday January 05, 2023 @05:08PM (#34267551)
> Python's `with`

It's very common already: try-with-resource (java), using (C#), bracket (haskell), unwind-protect (common-lisp), ... though it the latter two it's more of a building block.

Also building block: languages with a convenient and "unrestricted" syntax for anonymous function can just use that e.g. Smalltalk, Ruby, ... in Ruby a "with" is usually just passing a block to the corresponding object's constructor:

    # python 
    with open(...) as f:
        ...

    # ruby
    File::open(...) do |f|
      ...
    end

There are no comments on this comment yet.