Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The treatment of Future #25

Closed
sophiaIC opened this issue Aug 6, 2014 · 8 comments
Closed

The treatment of Future #25

sophiaIC opened this issue Aug 6, 2014 · 8 comments

Comments

@sophiaIC
Copy link
Contributor

sophiaIC commented Aug 6, 2014

You obviously have recently changed the treatment of futures. Namely, several programs do not compile currently, unless you add a Fut to their return type - as I did to the example in program StringSend. I am not clear what the correct behaviour is.

@TobiasWrigstad
Copy link
Contributor

Good question. @EliasC is the right person to answer this, but
basically, any method call x.foo() has return type Fut T, unless
x is this.

So calling

def foo() : int
  42

like so

x.foo()

has return type Fut int. The expressions

get x.foo() 

has type int.

Thus, if you write a method

def bar(x:FooType) : int
  x.foo()

this will not compile, because
the return type should be Fut int, i.e.,

def bar(x:FooType) : Fut int
  x.foo()

However

def bar(x:FooType) : int
  get x.foo()

will compile.

I hope this helps a little waiting for @EliasC.

@sophiaIC
Copy link
Contributor Author

sophiaIC commented Aug 6, 2014

Thank you Tobias for the clear explanation. I remember vaguely that the presentation said something along the lines of what you just wrote.

The treatment of futures fits the Encore philosophy, which requires that things are asynchronous by default.

I also remember that at the meeting it was said that there could be implicit insertions of get whenever necessary. Alternatively, you could decide to implicitly drop the requirement to “get”, whenever the method call is not assigned to a variable, i.e. there is no way to get hold of that future in the future ;-).

My point is, that the current examples on the github do not agree with the current compiler.

@EliasC
Copy link
Contributor

EliasC commented Aug 6, 2014

@sophiaIC We changed the test cases to match the use of futures, but no one remembered to change the files in programs/. I just pushed a fix to this!

At some point we should come up with a way to collapse nested futures. Right now the type of main in the following program is a bit silly:

class Foo
  def foo() : void
    print "Foo!"
  def bar(x : Foo) : Fut void
    x.foo()

class Main
  def main() : Fut (Fut void)
    let x = new Foo in
      x.bar(x)

@sophiaIC
Copy link
Contributor Author

sophiaIC commented Aug 6, 2014

Not sure if it's really necessary. It works either way on my box.
I used the binaries email to men by Tobias. Perhaps the binaries are not the most recent, then..

@supercooldave
Copy link

Monadic join is the appropriate function to collapse futures (after such a thing comes into existence).

On 06 Aug 2014, at 16:00, EliasC [email protected] wrote:

@sophiaIC We changed the test cases to match the use of futures, but no one remembered to change the files in programs/. I just pushed a fix to this!

At some point we should come up with a way to collapse nested futures. Right now the type of main in the following program is a bit silly:

class Foo
def foo() : void
print "Foo!"
def bar(x : Foo) : Fut void
x.foo()

class Main
def main() : Fut (Fut void)
let x = new Foo in
x.bar(x)

Reply to this email directly or view it on GitHub.

[email protected]
Dept. of Computer Science
Celestijnenlaan 200A
B-3001 Heverlee
BELGIUM
Tel: +32 16 327866

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

@EliasC
Copy link
Contributor

EliasC commented Aug 7, 2014

I'm all for monadic joins but maybe the use of nested futures will be so rare that we can make some collapsing implicit (and force the programmer to be explicit about wanting a value of type Fut (Fut (Fut void))

@TobiasWrigstad TobiasWrigstad changed the title the treatment of Future The treatment of Future Aug 8, 2014
@TobiasWrigstad
Copy link
Contributor

Can we close this?

@supercooldave
Copy link

I think we can close this. Fut (Fut (Fut ...))) chains should not automatically be compressed without further thought.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants