Variables and block closure

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

Variables and block closure

Gemstone/S mailing list
Hi everyone,

I wonder why is that two expressions are not evaluated similarly by Gemstone, but they are by Pharo ?

The second one is the one I would like to be working like the first one is, in Gemstone.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ | traversal array|
traversal := [ :a | a do: [ :e | (e isArray) ifTrue: [ traversal value: e ] ifFalse: [ e asString ] ] ].
array := Array with: (Array with: 1 with: 4) with: #ok with: (Array with: #henry).
traversal value: array.
] on: Error do: [:evt | evt asString]
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| traversal array|
[ traversal := [ :a | a do: [ :e | (e isArray) ifTrue: [ traversal value: e ] ifFalse: [ e asString ] ] ].
array := Array with: (Array with: 1 with: 4) with: #ok with: (Array with: #henry).
traversal value: array.
] on: Error do: [:evt | evt asString]
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Thank you,

Pierre


_______________________________________________
GemStone-Smalltalk mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Variables and block closure

Gemstone/S mailing list
There are some bugs in the way blocks handle variables in GemStone/S 64-bit 3.2.x (and possibly earlier; you don’t mention your version) that will be fixed in 3.3 (but probably not before; this is described internally with bug #45059).

James

> On Mar 17, 2015, at 11:17 AM, Pierre CHANSON via GemStone-Smalltalk <[hidden email]> wrote:
>
> Hi everyone,
>
> I wonder why is that two expressions are not evaluated similarly by Gemstone, but they are by Pharo ?
>
> The second one is the one I would like to be working like the first one is, in Gemstone.
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> [ | traversal array|
> traversal := [ :a | a do: [ :e | (e isArray) ifTrue: [ traversal value: e ] ifFalse: [ e asString ] ] ].
> array := Array with: (Array with: 1 with: 4) with: #ok with: (Array with: #henry).
> traversal value: array.
> ] on: Error do: [:evt | evt asString]
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> | traversal array|
> [ traversal := [ :a | a do: [ :e | (e isArray) ifTrue: [ traversal value: e ] ifFalse: [ e asString ] ] ].
> array := Array with: (Array with: 1 with: 4) with: #ok with: (Array with: #henry).
> traversal value: array.
> ] on: Error do: [:evt | evt asString]
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> Thank you,
>
> Pierre
>
> _______________________________________________
> GemStone-Smalltalk mailing list
> [hidden email]
> http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk

_______________________________________________
GemStone-Smalltalk mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Variables and block closure

Gemstone/S mailing list
Thanks James,

ok I am working on an older version, not even the last one. So here is a very good reason I should upgrade to the last version as soon as it is released. That will be some work.

by the way my previous code example did not had any sense. This is the good one (if someone read it) and it is the same problem:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[| traversal array result|
traversal := nil.
result := OrderedCollection new.
traversal := [ :a :r |
    |rtemp|
    a do: [ :e | (e isArray) ifTrue: [ rtemp := OrderedCollection new. r add: rtemp. traversal value: e value: rtemp] ifFalse: [ r add: e asString ] ] ].
array :=  Array with: (Array with: 1 with: 4) with: #ok with: (Array with: #henry).
traversal value: array value: result.
result.
] on: Error do: [:evt | evt asString]
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Cheers,

Pierre

2015-03-17 15:52 GMT-03:00 James Foster <[hidden email]>:
There are some bugs in the way blocks handle variables in GemStone/S 64-bit 3.2.x (and possibly earlier; you don’t mention your version) that will be fixed in 3.3 (but probably not before; this is described internally with bug #45059).

James

> On Mar 17, 2015, at 11:17 AM, Pierre CHANSON via GemStone-Smalltalk <[hidden email]> wrote:
>
> Hi everyone,
>
> I wonder why is that two expressions are not evaluated similarly by Gemstone, but they are by Pharo ?
>
> The second one is the one I would like to be working like the first one is, in Gemstone.
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> [ | traversal array|
> traversal := [ :a | a do: [ :e | (e isArray) ifTrue: [ traversal value: e ] ifFalse: [ e asString ] ] ].
> array := Array with: (Array with: 1 with: 4) with: #ok with: (Array with: #henry).
> traversal value: array.
> ] on: Error do: [:evt | evt asString]
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> | traversal array|
> [ traversal := [ :a | a do: [ :e | (e isArray) ifTrue: [ traversal value: e ] ifFalse: [ e asString ] ] ].
> array := Array with: (Array with: 1 with: 4) with: #ok with: (Array with: #henry).
> traversal value: array.
> ] on: Error do: [:evt | evt asString]
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> Thank you,
>
> Pierre
>
> _______________________________________________
> GemStone-Smalltalk mailing list
> [hidden email]
> http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk



_______________________________________________
GemStone-Smalltalk mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Variables and block closure

Gemstone/S mailing list
The simple reproducible case is as follows:

| a |
[ | b |
a := [a].
b := [b].
a value -> b value.
] value. "anExecBlock0->nil"

By the way, 3.3 is expected to be released this year, but nothing much more specific is available.


On Mar 17, 2015, at 12:02 PM, Pierre CHANSON <[hidden email]> wrote:

Thanks James,

ok I am working on an older version, not even the last one. So here is a very good reason I should upgrade to the last version as soon as it is released. That will be some work.

by the way my previous code example did not had any sense. This is the good one (if someone read it) and it is the same problem:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[| traversal array result|
traversal := nil.
result := OrderedCollection new.
traversal := [ :a :r |
    |rtemp|
    a do: [ :e | (e isArray) ifTrue: [ rtemp := OrderedCollection new. r add: rtemp. traversal value: e value: rtemp] ifFalse: [ r add: e asString ] ] ].
array :=  Array with: (Array with: 1 with: 4) with: #ok with: (Array with: #henry).
traversal value: array value: result.
result.
] on: Error do: [:evt | evt asString]
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Cheers,

Pierre

2015-03-17 15:52 GMT-03:00 James Foster <[hidden email]>:
There are some bugs in the way blocks handle variables in GemStone/S 64-bit 3.2.x (and possibly earlier; you don’t mention your version) that will be fixed in 3.3 (but probably not before; this is described internally with bug #45059).

James

> On Mar 17, 2015, at 11:17 AM, Pierre CHANSON via GemStone-Smalltalk <[hidden email]> wrote:
>
> Hi everyone,
>
> I wonder why is that two expressions are not evaluated similarly by Gemstone, but they are by Pharo ?
>
> The second one is the one I would like to be working like the first one is, in Gemstone.
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> [ | traversal array|
> traversal := [ :a | a do: [ :e | (e isArray) ifTrue: [ traversal value: e ] ifFalse: [ e asString ] ] ].
> array := Array with: (Array with: 1 with: 4) with: #ok with: (Array with: #henry).
> traversal value: array.
> ] on: Error do: [:evt | evt asString]
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> | traversal array|
> [ traversal := [ :a | a do: [ :e | (e isArray) ifTrue: [ traversal value: e ] ifFalse: [ e asString ] ] ].
> array := Array with: (Array with: 1 with: 4) with: #ok with: (Array with: #henry).
> traversal value: array.
> ] on: Error do: [:evt | evt asString]
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> Thank you,
>
> Pierre
>
> _______________________________________________
> GemStone-Smalltalk mailing list
> [hidden email]
> http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk




_______________________________________________
GemStone-Smalltalk mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/gemstone-smalltalk