Hi,
quick request. Please post to the list so people can see who responded and there be only one response :) I'd like to see the output of: | col | col := OrderedCollection new.
1 to: 11 do: [ :each | | i | i := each. col add: [ i ]. i := i + 1 ]. Array with: (col collect: [ :each | each value ]) asArray
with: thisContext method symbolic TIA Eliot _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
#(2 3 4 5 6 7 8 9 10 11 12) -Boris -- +1.604.689.0322 DeepCove Labs Ltd. 4th floor 595 Howe Street Vancouver, Canada V6C 2T5 From:
[hidden email] [mailto:[hidden email]] On Behalf Of Eliot
Miranda Hi, quick request. Please post to the
list so people can see who responded and there be only one response :) I'd like to see the output of: | col | col
:= OrderedCollection new. 1
to: 11 do: [ :each | | i | i := each. col add: [ i ]. i := i + 1 ]. Array
with: (col collect: [ :each | each value ]) asArray with:
thisContext method symbolic TIA Eliot _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Eliot Miranda-2
D’oh. 1: #(2 3 4 5 6 7 8 9 10 11 12) 2: 'normal AnnotatedMethod numArgs=0 numTemps=1 frameSize=12 literals: ({OrderedCollection} CompiledBlock [] in
UndefinedObject>>unboundMethod #to:do: {Array} BlockClosure [] in
UndefinedObject>>unboundMethod #method #symbolic ) 1 <34> push OrderedCollection 2 <BC> send new 3 <4C> store local 0; pop 4 <4A> push 1 5 <D8 0B> push 11 7 <10> push local 0 8 <FA 01 01> make copying block (1) 11 <CC 42> no-check send to:do: 13 <66> pop 14 <37> push Array 15 <10> push local 0 16 <20> push BlockClosure [] in
UndefinedObject>>unboundMethod 17 <F0 4C> send collect: 19 <F0 9B> send asArray 21 <54> push context 22 <75> send method 23 <76> send symbolic 24 <F0 4A> send with:with: 26 <65> return ' -Boris -- +1.604.689.0322 DeepCove Labs Ltd. 4th floor 595 Howe Street Vancouver, Canada V6C 2T5 From: Boris Popov #(2 3 4 5 6 7 8 9 10 11 12) -Boris -- +1.604.689.0322 DeepCove Labs Ltd. 4th floor 595 Howe Street Vancouver, Canada V6C 2T5 From:
[hidden email] [mailto:[hidden email]] On Behalf Of Eliot
Miranda Hi, quick request. Please post to the
list so people can see who responded and there be only one response :) I'd like to see the output of:
|
col |
col := OrderedCollection new.
1 to: 11 do: [ :each | | i | i := each. col add: [ i ]. i := i + 1 ].
Array with: (col collect: [ :each | each value ]) asArray
with: thisContext method symbolic TIA Eliot _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Eliot Miranda-2
#(#(2 3 4 5 6 7 8 9 10 11 12) 'normal AnnotatedMethod numArgs=0
numTemps=1 frameSize=12 literals: ({OrderedCollection} CompiledBlock [] in UndefinedObject>>unboundMethod #to:do: {Array} BlockClosure [] in UndefinedObject>>unboundMethod #method #symbolic ) 1 <34> push OrderedCollection 2 <BC> send new 3 <4C> store local 0; pop 4 <4A> push 1 5 <D8 0B> push 11 7 <10> push local 0 8 <FA 01 01> make copying block (1) 11 <CC 42> no-check send to:do: 13 <66> pop 14 <37> push Array 15 <10> push local 0 16 <20> push BlockClosure [] in UndefinedObject>>unboundMethod 17 <F0 4C> send collect: 19 <F0 9B> send asArray 21 <54> push context 22 <75> send method 23 <76> send symbolic 24 <F0 4A> send with:with: 26 <65> return ') >From a 7.5NC vanilla image. On Wed, Jul 22, 2009 at 2:18 PM, Eliot Miranda<[hidden email]> wrote: > Hi, > quick request. Please post to the list so people can see who responded > and there be only one response :) > I'd like to see the output of: > > | col | > col := OrderedCollection new. > 1 to: 11 do: [ :each | | i | i := each. col add: [ i ]. i := i + 1 ]. > Array with: (col collect: [ :each | each value ]) asArray > with: thisContext method symbolic > TIA > Eliot > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > > -- Jason Rogers "I am crucified with Christ: nevertheless I live; yet not I, but Christ liveth in me: and the life which I now live in the flesh I live by the faith of the Son of God, who loved me, and gave himself for me." Galatians 2:20 _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Boris Popov, DeepCove Labs (SNN)
Interesting.
Well, my non-Smalltalk background is showing. I would have expected the value of the block “[ i ]” to hold the value of ‘i’ at the point of reference, not the point of evaluation. I recognized that each activation context gives ‘i’ a unique state (which is retained because of the copying block involved). This seems to have something similar to “pass by name” semantics, which uses the current value at the time of invocation.
I wonder what would happen if you had multiple blocks involved, some of which set ‘i’, and multiple invocations that retrieve ‘i’. This seems to be a very confusing way to set anonymous semi-persistent state…
Cheers!
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Boris Popov
D’oh.
1: #(2 3 4 5 6 7 8 9 10 11 12) 2: 'normal AnnotatedMethod numArgs=0 numTemps=1 frameSize=12
literals: ({OrderedCollection} CompiledBlock [] in UndefinedObject>>unboundMethod #to:do: {Array} BlockClosure [] in UndefinedObject>>unboundMethod #method #symbolic )
1 <34> push OrderedCollection 2 <BC> send new 3 <4C> store local 0; pop 4 <4A> push 1 5 <D8 0B> push 11 7 <10> push local 0 8 <FA 01 01> make copying block (1) 11 <CC 42> no-check send to:do: 13 <66> pop 14 <37> push Array 15 <10> push local 0 16 <20> push BlockClosure [] in UndefinedObject>>unboundMethod 17 <F0 4C> send collect: 19 <F0 9B> send asArray 21 <54> push context 22 <75> send method 23 <76> send symbolic 24 <F0 4A> send with:with: 26 <65> return '
-Boris
-- +1.604.689.0322 DeepCove Labs Ltd. 4th floor 595 Howe Street Vancouver, Canada V6C 2T5
From: Boris Popov
#(2 3 4 5 6 7 8 9 10 11 12)
-Boris
-- +1.604.689.0322 DeepCove Labs Ltd. 4th floor 595 Howe Street Vancouver, Canada V6C 2T5
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Eliot Miranda
Hi,
quick request. Please post to the list so people can see who responded and there be only one response :)
I'd like to see the output of:
| col | col := OrderedCollection new. 1 to: 11 do: [ :each | | i | i := each. col add: [ i ]. i := i + 1 ]. Array with: (col collect: [ :each | each value ]) asArray with: thisContext method symbolic
TIA Eliot
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Hi Thomas,
(forgive the repost; I always get gmail reply/reply all wrong)
On Wed, Jul 22, 2009 at 11:54 AM, <[hidden email]> wrote:
And you expect an instance variable to have the value it had at instance creation time also? ;) There is, as Vassili has pointed out many time, a deep correspondence between objects and closures. You'd be miffed if an object shared between clients didn't reflect the changes in state made by those different clients right? It wouldn't be an object if it didn't. The fact that i is a variable means its value should be that of its most recent assignment. i := i + 1 is the most recent assignment. You've seen the following many times, right?
incrementBlock | counter | counter := -1. ^[counter := counter + 1] and there's no surprise that (1 to: 10) collect: self counterBlock
answers 0 through 9 right?
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by thomas.hawker
Eliot,
(Don’t worry about the repost.)
And as for Vassili, the fact that a variable’s value should be that of its most recent assignment is only partially true here. There is a question of state semantics, which has been sidestepped. The critical concept is whether the block “[ i ]” references state at the context of definition or the context of evaluation. Although it’s been a long time, I think Ada forced this issue out in the open with the distinction between definition, declaration, elaboration, and evaluation. We can all agree here that BlockClosures and BlockContexts implement this as context of evaluation.
I don’t have a particular issue with the results – they’re just not what I would have assumed. As I said, it’s my non-Smalltalk background showing. I hadn’t ever really thought through the implications. I’m certain I’ve programmed something like this sometime in the past, but offhand can’t recall when or where.
It’s something to remember, anyway… J
Cheers!
From: Eliot Miranda [mailto:[hidden email]]
On Wed, Jul 22, 2009 at 11:54 AM, <[hidden email]> wrote: Interesting. Well, my non-Smalltalk background is showing. I would have expected the value of the block “[ i ]” to hold the value of ‘i’ at the point of reference, not the point of evaluation. I recognized that each activation context gives ‘i’ a unique state (which is retained because of the copying block involved). This seems to have something similar to “pass by name” semantics, which uses the current value at the time of invocation. I wonder what would happen if you had multiple blocks involved, some of which set ‘i’, and multiple invocations that retrieve ‘i’. This seems to be a very confusing way to set anonymous semi-persistent state… And you expect an instance variable to have the value it had at instance creation time also? ;) There is, as Vassili has pointed out many time, a deep correspondence between objects and closures. The fact that i is a variable means its value should be that of its most recent assignment. i := i + 1 is the most recent assignment. You've seen the following many times, right?
incrementBlock | counter | counter := -1. ^[counter := counter + 1]
and there's no surprise that
(1 to: 10) collect: self counterBlock
answers 0 through 9 right?
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |