GithubHelp home page GithubHelp logo

Comments (3)

npasserini avatar npasserini commented on June 3, 2024

Also, it would prevent the REPL to print non-interesting return values from "order methods" (i.e. where intention is to produce an effect rather than returning a alue).

I mean, if the method has no "return" then it has no return value, it will help both the repl and the type checker to be more helpful

from wollok.

javierfernandes avatar javierfernandes commented on June 3, 2024

Two questions about "mandatory"

mandatory states for "to return you must write the return keyword" or "all methods must have a return value" ?

I don't remember if our "type system" has a notion of "void"

from wollok.

npasserini avatar npasserini commented on June 3, 2024

mandatory states for "to return you must write the return keyword" or "all
methods must have a return value" ?

The first one: "to return you must write the return keyword"

The objective is to be able to differenciate:
a) "procedures" or "orders", which are interesting because of its (side)
effects and not by their return value (or do not have one).
b) "functions" or "questions", which are interesting because of its return
value and should (or must) not have side effect.

Another possibility is to introduce a new keyword, instead of using
"method" for both cases. That was my first idea.

But now I think that using the return keyword would do the trick and has
other advantages:

  1. Explicit returns are more clear for beginners.
    As much as I like implicit return values for my own programmres, I have to
    admit that it confuses some people.

  2. Explicit returns allow for more flow-control possibilities.
    You can see that almost every language with implicit return values has also
    the possibility of an explicit return instruction that allows to finish
    current method.

The question is: Had we mandatory explicit returns for methods, should
blocks also have mandatory returns?
I do not know.

I don't remember if our "type system" has a notion of "void"

Maybe not... we could add it.
Anyway I was thinking not to use the type system this semester.

from wollok.

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.