Git Product home page Git Product logo

Comments (2)

bradcray avatar bradcray commented on May 18, 2024

Historically, we shied away from supporting these operators in Chapel's original design because we were generally trying to avoid supporting operators that modified things at the expression level (primarily to reduce the number of cases in which we'd need to understand read vs. write semantics on expressions in the compiler). I.e., the only way to modify things was through assignment operators and function calls. (We also avoided expression-level assignment for this reason, though the rationale for that decision is arguably stronger, since it helps avoid common = vs. == mistakes and could result in confusion in contexts like named argument passing). I also was never particularly fond of (or good at) distinguishing between ++a and a++.

All that said, my personal negativity toward them isn't as strong today as it was then. In the past I've argued "you can always define methods that do this so there's no need for language support" and while that's true, it also suggests that supporting them wouldn't be all that bad / different from doing so via methods, while being succinct and familiar to C-family programmers. All that said, I'm also am not eager to add them without a good/clean story for how they'd be defined by a user on their own type

In the perf meeting today, we (@ronawho, @ian-bertolacci, @benharsh) discussed a few use cases that might motivate supporting them:

  • If we move toward supporting operator overloads for common atomic operations, then += would correspond to a .add(), but if we had ++, that could support the common case of a .fetchAdd(1) nicely.

  • @benharsh points out that these could be useful in bucketing patterns like ISx as well.

from chapel.

bradcray avatar bradcray commented on May 18, 2024

This SO Q&A which seems to summarize Swift's choice not to support these operators was interesting to me.

from chapel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.