News for hackers. Stuff that matters.
Re:Git's list of banned C functions by ggregoire on Thursday March 04, 2021 @05:00PM (#26349025)
> in JavaScript you have footguns like the with statement

I've been coding in JS on a daily basis for more than 10 years and today I learned there is a `with` statement in JS.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Edit: well, seems like it's been deprecated/forbidden since ES5 (2009), so it makes sense I've never seen it.

Re:Git's list of banned C functions by UncleMeat on Thursday March 04, 2021 @06:34PM (#26350060)
An old grad school connection of mine wrote a formal semantics for ES5 and couldn't explain what "with" did in words.
Re:Git's list of banned C functions by 1f60c on Thursday March 04, 2021 @07:11PM (#26350452)
This is JavaScript, so there are probably tons of weird edge cases, but basically, within a with (expr) { … } block, everything defined on expr is put in scope:

  with (Math) with (console) log(PI)
It reminds me a bit of Clojure's doto.
Re:Git's list of banned C functions by kaba0 on Friday March 05, 2021 @11:02AM (#26358313)
Or java’s static import
Re:Git's list of banned C functions by GordonS on Thursday March 04, 2021 @05:54PM (#26349657)
And me around 20 years - also never even heard of the `with` statement! I think to qualify as a footgun, people actually need to be using it in the real world.
Re:Git's list of banned C functions by IgorPartola on Thursday March 04, 2021 @07:05PM (#26350369)
I have seen it in the wild. I first learned of it from Douglas Crockford’s JavaScript the good parts. He also had some things to say about the new keyword and prototype inheritance and how we should stop using them. Ironically while he was dismissed on that suggestion then, VueJS has pretty much implemented exactly what he has in mind in their V3.
Re:Git's list of banned C functions by javbit on Thursday March 04, 2021 @06:45PM (#26350166)
It should be called something like appendixgun then because you don't use it but it still has a chance of causing needless suffering and pain.
Re:Git's list of banned C functions by astrange on Thursday March 04, 2021 @08:20PM (#26351151)
The appendix is a reservoir of gut bacteria in case you lose yours in an infection or by taking too many antibiotics.
Re:Git's list of banned C functions by azernik on Thursday March 04, 2021 @09:17PM (#26351671)
There are lots of more conventional footguns in JS, though - everything about the Date object/class, for example.
Re:Git's list of banned C functions by bsimpson on Thursday March 04, 2021 @06:16PM (#26349873)
Was also popular in ActionScript, the JS cousin that powered dynamic Flash content:

    with (myShape.graphics) {
      beginPath();
      setFill(0xFF0000);
      moveTo(6, 9);
      // ...
    }