Migrating a Pharo application to Amber

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

Migrating a Pharo application to Amber

abergel
Hi!

Anyone has ported a non-trvial Pharo or VW application to Amber?

Cheers,
Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.





Reply | Threaded
Open this post in threaded view
|

Re: Migrating a Pharo application to Amber

Vicnet-2
Hello,

Not exactly a non-trivial because I try to port a TicTacToe example that runs in Pharo to Amber.
Here is the link of the game: TicTacToe Game in Pharo

There is some traps. The Amber wiki summarize some of them:
https://github.com/NicolasPetton/amber/wiki/Porting-code-from-other-Smalltalk-dialects

I discovers also:
- compilation pb on block with direct return (issue #178)
- Array >> at:ifAbsent: return ifAbsent block evaluation if a element is present but nil (issue #181)
- equality = and identity == is not treated at same level in Pharo and Amber
  c := 'X'. c == 'X' return true (Pharo) or false (Amber) depends environment
For me Amber is right as c is not 'X', it just the same value not the same object...
Perhaps a deepCopy/shallowCopy consideration...

Of course some classes missing in Amber :-) but could be imported.

Morphic could be partialy use with js port: morphic.js but not tried yet.
It my next try to port TicTacToe view.

a+
Vicnet

Le vendredi 27 avril 2012 03:27:23 UTC+2, Alexandre.Bergel a écrit :
Hi!

Anyone has ported a non-trvial Pharo or VW application to Amber?

Cheers,
Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.





Reply | Threaded
Open this post in threaded view
|

Re: Migrating a Pharo application to Amber

gokr
On 04/27/2012 09:01 AM, Vicnet wrote:
> Hello,
>
> Not exactly a non-trivial because I try to port a TicTacToe example that
> runs in Pharo to Amber.
> Here is the link of the game: TicTacToe Game in Pharo
> <http://nerdysermons.blogspot.com/2012/03/tictactoe-game-in-pharo-smalltalk.html>
>
> There is some traps. The Amber wiki summarize some of them:
> https://github.com/NicolasPetton/amber/wiki/Porting-code-from-other-Smalltalk-dialects

Feel free to add stuff to that page also.

> I discovers also:
> - compilation pb on block with direct return (issue #178)
> - Array >> at:ifAbsent: return ifAbsent block evaluation if a element is
> present but nil (issue #181)

Ok, bugs we probably don't need to add to that page... or well, we could
make links to them of course.

> - equality = and identity == is not treated at same level in Pharo and Amber
> c := 'X'. c == 'X' return true (Pharo) or false (Amber) depends environment
> For me Amber is right as c is not 'X', it just the same value not the
> same object...

That is actually due to a Compiler optimization in Pharo/Squeak. The
Compiler there notes that the two literals in the method happens to be
the same and thus it will only instantiate *one* literal object
(representing 'X') so c and the last literal 'X' actually refers to the
*same* object.

If you put these two lines in two different methods it will not evaluate
to true. You can also, in a workspace in Pharo, do the following:

1. Run printit on " c := 'X'. c == 'X' ". This will create a c binding
in the workspace and do the comparison and print "true".

2. Now, select only the last part and do printit "c == 'X'". c still
refers to the 'X' literal object created in step #2 above but 'X' will
cause a new literal object to be created by the compiler. This will now
print to "false".

regards, Göran
Reply | Threaded
Open this post in threaded view
|

Re: Migrating a Pharo application to Amber

abergel
Thanks for your help.

Alexandre



On 27 Apr 2012, at 03:12, Göran Krampe wrote:

> On 04/27/2012 09:01 AM, Vicnet wrote:
>> Hello,
>>
>> Not exactly a non-trivial because I try to port a TicTacToe example that
>> runs in Pharo to Amber.
>> Here is the link of the game: TicTacToe Game in Pharo
>> <http://nerdysermons.blogspot.com/2012/03/tictactoe-game-in-pharo-smalltalk.html>
>>
>> There is some traps. The Amber wiki summarize some of them:
>> https://github.com/NicolasPetton/amber/wiki/Porting-code-from-other-Smalltalk-dialects
>
> Feel free to add stuff to that page also.
>
>> I discovers also:
>> - compilation pb on block with direct return (issue #178)
>> - Array >> at:ifAbsent: return ifAbsent block evaluation if a element is
>> present but nil (issue #181)
>
> Ok, bugs we probably don't need to add to that page... or well, we could make links to them of course.
>
>> - equality = and identity == is not treated at same level in Pharo and Amber
>> c := 'X'. c == 'X' return true (Pharo) or false (Amber) depends environment
>> For me Amber is right as c is not 'X', it just the same value not the
>> same object...
>
> That is actually due to a Compiler optimization in Pharo/Squeak. The Compiler there notes that the two literals in the method happens to be the same and thus it will only instantiate *one* literal object (representing 'X') so c and the last literal 'X' actually refers to the *same* object.
>
> If you put these two lines in two different methods it will not evaluate to true. You can also, in a workspace in Pharo, do the following:
>
> 1. Run printit on " c := 'X'. c == 'X' ". This will create a c binding in the workspace and do the comparison and print "true".
>
> 2. Now, select only the last part and do printit "c == 'X'". c still refers to the 'X' literal object created in step #2 above but 'X' will cause a new literal object to be created by the compiler. This will now print to "false".
>
> regards, Göran

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.