Block return

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Block return

Vicnet-2
Hello,

I try to compile Matrix from Pharo on Amber.

In Matrix, there is this message:
identityIndexOf: anElement ifAbsent: anExceptionBlock
    ^self rowAndColumnForIndex:
         (contents identityIndexOf: anElement ifAbsent: [^anExceptionBlock value])

Amber does not compile this because of the return ^ symbol in block.

Even test >> ^ [ ^ nil ] is not accepted.

There no error message nor success (message is not added in browser).

Is it normal or a bug ?

a+
Vicnet

Reply | Threaded
Open this post in threaded view
|

Re: Block return

Amber Milan Eskridge
That is a bug in compiler I think, because it produces a syntax error in the console.



On Tue, Apr 24, 2012 at 1:48 PM, Vicnet <[hidden email]> wrote:
Hello,

I try to compile Matrix from Pharo on Amber.

In Matrix, there is this message:
identityIndexOf: anElement ifAbsent: anExceptionBlock
    ^self rowAndColumnForIndex:
         (contents identityIndexOf: anElement ifAbsent: [^anExceptionBlock value])

Amber does not compile this because of the return ^ symbol in block.

Even test >> ^ [ ^ nil ] is not accepted.

There no error message nor success (message is not added in browser).

Is it normal or a bug ?

a+
Vicnet


Reply | Threaded
Open this post in threaded view
|

Re: Block return

Herby Vojčík
Amber can compile things methods that use blocks with return, there
should not be any problem with it, but from what I looked into compiler,
it compiles it a little brittle way, if you combine the right set of
selector in call chain, you don't get what you expect (at least it seems
from the implementation).

Herby

P.S.: Error in console during compilation? Hmm... then maybe there is
really some problem.

Amber Milan Eskridge wrote:

> That is a bug in compiler I think, because it produces a syntax error in
> the console.
>
>
>
> On Tue, Apr 24, 2012 at 1:48 PM, Vicnet <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hello,
>
>     I try to compile Matrix from Pharo on Amber.
>
>     In Matrix, there is this message:
>
>         identityIndexOf: anElement ifAbsent: anExceptionBlock
>              ^self rowAndColumnForIndex:
>                   (contents identityIndexOf: anElement ifAbsent:
>         [^anExceptionBlock value])
>
>
>     Amber does not compile this because of the return ^ symbol in block.
>
>     Even test >> ^ [ ^ nil ] is not accepted.
>
>     There no error message nor success (message is not added in browser).
>
>     Is it normal or a bug ?
>
>     a+
>     Vicnet
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Block return

Nicolas Petton
In reply to this post by Vicnet-2
That's indeed a bug.
It seems that you can omit the ^ in the block though.

Cheers,
Nico

On Apr 24, 2012, at 1:48 PM, Vicnet wrote:

Hello,

I try to compile Matrix from Pharo on Amber.

In Matrix, there is this message:
identityIndexOf: anElement ifAbsent: anExceptionBlock
    ^self rowAndColumnForIndex:
         (contents identityIndexOf: anElement ifAbsent: [^anExceptionBlock value])

Amber does not compile this because of the return ^ symbol in block.

Even test >> ^ [ ^ nil ] is not accepted.

There no error message nor success (message is not added in browser).

Is it normal or a bug ?

a+
Vicnet