CatchTheTornado / askql

AskQL is a query language that can express any data request
https://askql.org/
MIT License
387 stars 27 forks source link

[askscript] Should we implement (pre) incrementation? #386

Open czerwinskilukasz1 opened 4 years ago

czerwinskilukasz1 commented 4 years ago

Javascript has both pre- and post-incrementation, useful in loops, e.g.:

  let result = [];
  for (let i = 1; i <= m; ++i) {
    result.push(n*i);
  }

How about we implement preincrementation (++i)?

czerwinskilukasz1 commented 4 years ago

@mhagmajer

mhagmajer commented 4 years ago

I think i = i +1 is fine for now. I know that a lot of C programmers (me included) are used to ++, however it is more difficult to read than i = i + 1 while not offering little advantage (given the current performance limitations). If I remember correctly, the popular AirBnB preset for eslint actually forbids i++ and prefers i=i+1. Therefore I would hold on with this until we have better performance where it actually matters how this operation is done (i++ vs ++i)

czerwinskilukasz1 commented 4 years ago

I guess in scripting languages like Javascript ++ is no longer about program performance, it's about programmer's convenience.