Follow @nxtchg

Author Topic: this.  (Read 252 times)

NxtChg

  • Overlord
  • *****
  • Posts: 1114
  • Respect: +61
    • View Profile
this.
« on: July 17, 2017, 08:02:00 am »
+1


A lot of languages copied 'this' from C++ without questioning it.

Now all our objects are littered with it:

Code: [Select]
function seg(fx, fy, tx, ty)
{
    if(this.options.smooth)
        this.ctx.bezierCurveTo(fx, fy+.5, fx, ty+0.5, tx, ty+0.5);
    else
        this.ctx.lineTo(tx, ty+.5);
}

or

Code: [Select]
function signout($nick, $token)
{
    $this->begin();
    $this->query("UPDATE users SET token='' WHERE nick='$nick'");
    $this->add('activity', ['type' => 'logout', 'actor' => $nick]);
    $this->commit();
}

Why the hell are we doing this to ourselves?!

All objects should first and foremost (maybe ever) access their own members!

Yet we drag this hack, which originated because C++ was a patch on top of C, into all our modern programming languages!

We prioritize access to the global namespace that should actually be prohibited or restricted, like in PHP with the 'global' keyword.

Why?!!

Not questioning things :(



Tentacle Overlord, The Deranged Genius of The Abyss