Git Product home page Git Product logo

Comments (6)

vasslitvinov avatar vasslitvinov commented on June 3, 2024 1

In my view, the expectation that code after a halt() will do anything is legacy. For today's Chapel, I see it "normal" to declare the return type explicitly rather than relying on return-after-halt.

Given the importance of abstract classes and pure virtual methods it makes sense to introduce language support for them. A library routine, an attribute, or some syntax (cf. init tnis) are possibilities.

That said, if others find return-after-halt valuable, I can live with it.

from chapel.

bradcray avatar bradcray commented on June 3, 2024 1

Of course we can consider other ways to indicate something is pure virtual, such as an attribute or keyword. See also #8566 and #15271.

Given the importance of abstract classes and pure virtual methods it makes sense to introduce language support for them.

Good points and I would also prefer language support for pure virtual methods than continuing to use this pattern to fake it.

from chapel.

bradcray avatar bradcray commented on June 3, 2024

Tagging @vasslitvinov and @DanilaFe on this due to their involvement with #23309. Note that I consider this low priority (but worth capturing).

from chapel.

vasslitvinov avatar vasslitvinov commented on June 3, 2024

#20673 raises other related questions.

We should at the very least add a clarification to the spec here.

from chapel.

mppf avatar mppf commented on June 3, 2024

IMO for the specific pattern here, we could introduce a library routine to call to indicate a method is "pure virtual" / "abstract" and call that instead of halt. Then, the compiler can be adjusted to not consider this to make the return dead code. Of course we can consider other ways to indicate something is pure virtual, such as an attribute or keyword. See also #8566 and #15271.

I would also be open to an approach that uses such top-level returns for type inference of routine return types even if there is halt before it, possible as an exception to the general dead code / param folding rules.

from chapel.

dlongnecke-cray avatar dlongnecke-cray commented on June 3, 2024

I agree with Vass and think it would be reasonable for the language to detect and warn against this pattern, perhaps suggesting you annotate a return type instead. I also think it would be reasonable to try and warn for all unreachable code that is not being deliberately param folded away.

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.