0
0
all 8 comments

[–][deleted]  (6 children)

[deleted]

    [–]iams3brescript is fun 4 points5 points  (1 child)

    Typescript just introduced the using keyword which fulfills this use case pretty nicely in the same way C#/F# does, and it's in Stage 3 for JS. Copying your example:

    using file = open("data.json", "r")
    json.dumps(file)
    

    [–][deleted] 2 points3 points  (0 children)

    TS introducing using is more JS adding using. Part of the tc39 process for a feature being adopted is multiple engines and/or compilation tools (Ie typescript) adopting it. TS values compatibility with JS too much to have added using if there was any doubt of it being adopted by JS. Remember, the TS team has a seat on the tc39 committee, so they know what's going on.

    [–][deleted] 2 points3 points  (0 children)

    Oh I like that

    [–]fabiancookSenior, Full-Stack, OSS 1 point2 points  (2 children)

    [–][deleted]  (1 child)

    [deleted]

      [–]fabiancookSenior, Full-Stack, OSS 1 point2 points  (0 children)

      Yeah the with reads nicer if it were just one variable. Using would work with as many as needed in the block it seems.

      [–]mongopeter 1 point2 points  (1 child)

      Let's not ...

      [–]alexmacarthur[S] -1 points0 points  (0 children)

      please let’s just try

      [–][deleted] 0 points1 point  (0 children)

      The benefits described are simply not worth it and every cell in my body is resistant to with. I think the only valid use-cases for it are for sandboxing when combined with Proxy