whileTrue works different in Amber than in Pharo?

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

whileTrue works different in Amber than in Pharo?

Bernat Romagosa
Hi list,

| a |
[ a := 3 ] valueWithTimeout: 500.
[ a isNil ] whileTrue.

This freezes the page, unlike the (I think) equivalent in Pharo:

|a|
[ (Delay forMilliseconds: 500) wait. a := 3 ] fork.
[ a isNil ] whileTrue.

Which waits for a to not be nil and ends.

Any ideas?

Cheers!

--
Bernat Romagosa.
Reply | Threaded
Open this post in threaded view
|

Re: whileTrue works different in Amber than in Pharo?

Ankh'nAton
Hi,

I don't know for sure, but it looks like a scope problem. Maybe local
variables in Amber cannot be addressed from within blocks?

Cheers...
Reply | Threaded
Open this post in threaded view
|

Re: whileTrue works different in Amber than in Pharo?

Denis Kudriashov
In reply to this post by Bernat Romagosa
Is #fork really works in Amber?

2011/12/27 Bernat Romagosa <[hidden email]>
Hi list,

| a |
[ a := 3 ] valueWithTimeout: 500.
[ a isNil ] whileTrue.

This freezes the page, unlike the (I think) equivalent in Pharo:

|a|
[ (Delay forMilliseconds: 500) wait. a := 3 ] fork.
[ a isNil ] whileTrue.

Which waits for a to not be nil and ends.

Any ideas?

Cheers!

--
Bernat Romagosa.

Reply | Threaded
Open this post in threaded view
|

Re: whileTrue works different in Amber than in Pharo?

Bernat Romagosa
No, #fork doesn't exist in Amber, that was the equivalent code in Pharo :)

It seems to be the normal behavior in Javascript, so I'm afraid there may be no solution to get this to work in Amber.

2011/12/30 Denis Kudriashov <[hidden email]>
Is #fork really works in Amber?


2011/12/27 Bernat Romagosa <[hidden email]>
Hi list,

| a |
[ a := 3 ] valueWithTimeout: 500.
[ a isNil ] whileTrue.

This freezes the page, unlike the (I think) equivalent in Pharo:

|a|
[ (Delay forMilliseconds: 500) wait. a := 3 ] fork.
[ a isNil ] whileTrue.

Which waits for a to not be nil and ends.

Any ideas?

Cheers!

--
Bernat Romagosa.




--
Bernat Romagosa.
Reply | Threaded
Open this post in threaded view
|

Re: whileTrue works different in Amber than in Pharo?

Nicolas Petton
In reply to this post by Denis Kudriashov
On Fri, 2011-12-30 at 09:17 +0400, Denis Kudriashov wrote:
> Is #fork really works in Amber?

Nope, it's not at all in Amber. And #valueWithTimeout: doesn't work the
same way. BTW, the same is true with JavaScript:

var a;
setTimeout(function() {a = 3}, 500);
while(!a) {"oops"};


Cheers,
Nico

>
> 2011/12/27 Bernat Romagosa <[hidden email]>
>         Hi list,
>        
>        
>         | a |
>         [ a := 3 ] valueWithTimeout: 500.
>         [ a isNil ] whileTrue.
>        
>        
>         This freezes the page, unlike the (I think) equivalent in
>         Pharo:
>        
>        
>         |a|
>         [ (Delay forMilliseconds: 500) wait. a := 3 ] fork.
>         [ a isNil ] whileTrue.
>        
>        
>         Which waits for a to not be nil and ends.
>        
>        
>         Any ideas?
>        
>        
>         Cheers!
>        
>        
>         --
>         Bernat Romagosa.
>        
>



Reply | Threaded
Open this post in threaded view
|

Re: whileTrue works different in Amber than in Pharo?

Amber Milan Eskridge
Maybe it would be possible to implement that with WebWorkers[1]? I believe not with considerable effort and even then only with introduced complexity to the overall system.

[1] http://en.wikipedia.org/wiki/Web_worker

On Mon, Jan 2, 2012 at 6:30 PM, Nicolas Petton <[hidden email]> wrote:
On Fri, 2011-12-30 at 09:17 +0400, Denis Kudriashov wrote:
> Is #fork really works in Amber?

Nope, it's not at all in Amber. And #valueWithTimeout: doesn't work the
same way. BTW, the same is true with JavaScript:

var a;
setTimeout(function() {a = 3}, 500);
while(!a) {"oops"};


Cheers,
Nico

>
> 2011/12/27 Bernat Romagosa <[hidden email]>
>         Hi list,
>
>
>         | a |
>         [ a := 3 ] valueWithTimeout: 500.
>         [ a isNil ] whileTrue.
>
>
>         This freezes the page, unlike the (I think) equivalent in
>         Pharo:
>
>
>         |a|
>         [ (Delay forMilliseconds: 500) wait. a := 3 ] fork.
>         [ a isNil ] whileTrue.
>
>
>         Which waits for a to not be nil and ends.
>
>
>         Any ideas?
>
>
>         Cheers!
>
>
>         --
>         Bernat Romagosa.
>
>




Reply | Threaded
Open this post in threaded view
|

Re: whileTrue works different in Amber than in Pharo?

Denis Kudriashov
Web workers are like native OS threads support for usual smalltalk system.
Is it possible to implement green threads in amber?

2012/1/4 Amber Milan Eskridge <[hidden email]>
Maybe it would be possible to implement that with WebWorkers[1]? I believe not with considerable effort and even then only with introduced complexity to the overall system.

[1] http://en.wikipedia.org/wiki/Web_worker


On Mon, Jan 2, 2012 at 6:30 PM, Nicolas Petton <[hidden email]> wrote:
On Fri, 2011-12-30 at 09:17 +0400, Denis Kudriashov wrote:
> Is #fork really works in Amber?

Nope, it's not at all in Amber. And #valueWithTimeout: doesn't work the
same way. BTW, the same is true with JavaScript:

var a;
setTimeout(function() {a = 3}, 500);
while(!a) {"oops"};


Cheers,
Nico

>
> 2011/12/27 Bernat Romagosa <[hidden email]>
>         Hi list,
>
>
>         | a |
>         [ a := 3 ] valueWithTimeout: 500.
>         [ a isNil ] whileTrue.
>
>
>         This freezes the page, unlike the (I think) equivalent in
>         Pharo:
>
>
>         |a|
>         [ (Delay forMilliseconds: 500) wait. a := 3 ] fork.
>         [ a isNil ] whileTrue.
>
>
>         Which waits for a to not be nil and ends.
>
>
>         Any ideas?
>
>
>         Cheers!
>
>
>         --
>         Bernat Romagosa.
>
>





Reply | Threaded
Open this post in threaded view
|

Re: whileTrue works different in Amber than in Pharo?

Amber Milan Eskridge
Not without significantly changing (and slowing down) Amber, since Amber is a transpiled system and not an interpreted one, IMHO.

On Wed, Jan 4, 2012 at 11:34 AM, Denis Kudriashov <[hidden email]> wrote:
Web workers are like native OS threads support for usual smalltalk system.
Is it possible to implement green threads in amber?


2012/1/4 Amber Milan Eskridge <[hidden email]>
Maybe it would be possible to implement that with WebWorkers[1]? I believe not with considerable effort and even then only with introduced complexity to the overall system.

[1] http://en.wikipedia.org/wiki/Web_worker


On Mon, Jan 2, 2012 at 6:30 PM, Nicolas Petton <[hidden email]> wrote:
On Fri, 2011-12-30 at 09:17 +0400, Denis Kudriashov wrote:
> Is #fork really works in Amber?

Nope, it's not at all in Amber. And #valueWithTimeout: doesn't work the
same way. BTW, the same is true with JavaScript:

var a;
setTimeout(function() {a = 3}, 500);
while(!a) {"oops"};


Cheers,
Nico

>
> 2011/12/27 Bernat Romagosa <[hidden email]>
>         Hi list,
>
>
>         | a |
>         [ a := 3 ] valueWithTimeout: 500.
>         [ a isNil ] whileTrue.
>
>
>         This freezes the page, unlike the (I think) equivalent in
>         Pharo:
>
>
>         |a|
>         [ (Delay forMilliseconds: 500) wait. a := 3 ] fork.
>         [ a isNil ] whileTrue.
>
>
>         Which waits for a to not be nil and ends.
>
>
>         Any ideas?
>
>
>         Cheers!
>
>
>         --
>         Bernat Romagosa.
>
>