Pricefield | Lemmy
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
@[email protected] to Programmer [email protected] • 11 days ago

The meaning of this

lemmy.world

message-square
13
fedilink
  • cross-posted to:
  • [email protected]
286

The meaning of this

lemmy.world

@[email protected] to Programmer [email protected] • 11 days ago
message-square
13
fedilink
  • cross-posted to:
  • [email protected]
alert-triangle
You must log in or register to comment.
  • @[email protected]
    link
    fedilink
    English
    24•11 days ago

    Go:

    MCU universe Loki saying "I've never met this man in my life."

    • Kairos
      link
      fedilink
      1•10 days ago

      deleted by creator

  • @[email protected]
    link
    fedilink
    19•11 days ago

    “We wanted it to work like Perl,” said someone who should have been killed on the spot.

    • palordrolap
      link
      fedilink
      9•11 days ago

      At the time JS was created, Perl didn’t have a this. A lot of the docs and books suggested using $self but a reference to the object would be passed as the first parameter to all class methods and you assign that to any name you wanted.

      It’s only very recently (as in the last year or so) with a new class system that Perl has hard-coded $self for that purpose.

      • @[email protected]
        link
        fedilink
        3•11 days ago

        I mean $_.

        • palordrolap
          link
          fedilink
          2•11 days ago

          Ah. The usually implicit topical “this” didn’t even occur to me because I thought, er, this, was about objects. $_ isn’t used for those in Perl.

          I suppose there might be some parallels with the implicit nature of $_ in non-OO contexts in Perl versus this in OO contexts in Javascript, but, at least to me, that feels pretty tenuous.

  • Justas🇱🇹
    link
    fedilink
    4•10 days ago

    let self = this;

  • @[email protected]
    link
    fedilink
    2•11 days ago

    I did not know that about event handlers, that is actually super convenient

  • @[email protected]
    link
    fedilink
    6•10 days ago

    Any language feature with such a long definition is a bad language feature.

    The less such features, the better the language.

    Thus, javascript is not a “good” language for expressing your programs.

  • @[email protected]
    link
    fedilink
    11•11 days ago

    Yeah, this is that.

  • @[email protected]
    link
    fedilink
    English
    1•8 days ago

    In python self is just a convention, you can call it whatever you want :)

  • @[email protected]
    link
    fedilink
    7•10 days ago

    Rust: do you mean Self or self?

    • @[email protected]
      link
      fedilink
      6•10 days ago

      this is commonly used with a similar meaning to self in cases where ` self can’t be used because it is a reserved keyword.

      Example:

          fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<St1::Item>> {
              let this = self.project();
              this.inner.poll_next(cx)
          }
      

      https://github.com/rust-lang/futures-rs/blob/master/futures-util/src/stream/select.rs#L113-L116

  • @[email protected]
    link
    fedilink
    English
    11•11 days ago
    const that = this;
    

Programmer [email protected]

[email protected]
Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
  • 24 users / day
  • 395 users / week
  • 1.63K users / month
  • 4.3K users / 6 months
  • 3 subscribers
  • 1.54K Posts
  • 54.8K Comments
  • Modlog
  • mods:
  • Feyter
  • adr1an
  • @[email protected]
  • Pierre-Yves Lapersonne
  • UI: 0.18.4
  • BE: 0.18.2
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org