Menu

#20 Block arguments not allowed in expressions

open
nobody
None
5
2004-01-05
2004-01-05
Bryn Keller
No

The parser in the current CVS version isn't allowing
block arguments when the call is the rhs of an assignment:

int foo(void->int func) = func();

void main(String[] args) {
foo() { return 1; } //works
int x = foo() { return 1; } //doesn't work
}

Discussion

  • Arjan Boeijink

    Arjan Boeijink - 2004-01-05

    Logged In: YES
    user_id=688815

    Only the use of a block call as statement is possible now.
    This a parsing problem, I haven't found out yet how to allow a
    block call as expression without requiring ; at the end of both
    examples you gave.

     
  • Arjan Boeijink

    Arjan Boeijink - 2004-01-13

    Logged In: YES
    user_id=688815

    Although it looks good on the rhs of an assignment, I'm not
    sure about the usage as expression:
    bar(foo(){ return 1; }. foo(){ return 5; });

    Do you have an example where you to return something from
    a block argument call?
    Otherwise I suggest limiting it to statements only and rename
    it to user defined statement.

     
  • Bryn Keller

    Bryn Keller - 2004-01-13

    Logged In: YES
    user_id=2706

    Oh, sure:

    ThreadResult<int> result = async { callSomeServer(); return 5; }

    ThreadResult<int> result = waitForFirst(
    async { return doSomething(); },
    async { return doSomethingElse(); }
    );

     

Log in to post a comment.