destructDo:

CH
Christian Haider
Sat, Mar 28, 2020 12:42 PM

Hi,

I am using a nice little method #destructDo: for a while now and it feels
good.

In VisualWorks:

SequenceableCollection>>destructDo: aBlock

                            "Evaluate aBlock with the receiver's

elements as parameters.

                            aBlock takes its arguments from the

receiver.

                            'ok'

                            #(1 2 3) destructDo: [:a :b :c | a + b + c]

                            #(1 2 3) destructDo: [:a :b | a + b]

                            #(1 2 3) destructDo: [:a | a]

                            #(1 2 3) destructDo: [42]

                            'not ok'

                            #(1 2 3) destructDo: [:a :b :c :d | a + b +

c + d]

                            "

                            ^aBlock cullWithArguments: self asArray

In Amber:

SequenceableCollection>>destructDo: aBlock

                            ^aBlock valueWithPossibleArguments: self

In Pharo and other dialects, I don't know, but should be as easy.

For example you can do

            (('2020-03-28' tokensBasedOn: $-) collect: #asNumber)

destructDo: [:year :month :day |

                           Date newDay: day monthNumber: month year:

year]

I like that the block is not the receiver (like with #valueWithArguments or
#cullWithArguments), but the last argument.

Now the questions:

  • I am sure that others came up with this. Anybody knows?
  • What are you using for this pattern?
  • I don't really like the name, but haven't found anything better yet.
    Maybe #destructedDo: or just #destructed: or: #withPartsDo:. maybe something
    shorter? Ideas?
  • What are you thinking about this?

Happy hacking,

            Christian
Hi, I am using a nice little method #destructDo: for a while now and it feels good. In VisualWorks: SequenceableCollection>>destructDo: aBlock "Evaluate aBlock with the receiver's elements as parameters. aBlock takes its arguments from the receiver. 'ok' #(1 2 3) destructDo: [:a :b :c | a + b + c] #(1 2 3) destructDo: [:a :b | a + b] #(1 2 3) destructDo: [:a | a] #(1 2 3) destructDo: [42] 'not ok' #(1 2 3) destructDo: [:a :b :c :d | a + b + c + d] " ^aBlock cullWithArguments: self asArray In Amber: SequenceableCollection>>destructDo: aBlock ^aBlock valueWithPossibleArguments: self In Pharo and other dialects, I don't know, but should be as easy. For example you can do (('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day | Date newDay: day monthNumber: month year: year] I like that the block is not the receiver (like with #valueWithArguments or #cullWithArguments), but the last argument. Now the questions: * I am sure that others came up with this. Anybody knows? * What are you using for this pattern? * I don't really like the name, but haven't found anything better yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:. maybe something shorter? Ideas? * What are you thinking about this? Happy hacking, Christian
NH
Norbert Hartl
Sat, Mar 28, 2020 1:06 PM

[:year :month :day | Date newDay: day month: month year: year]
valueWithPossibleArguments: (($- split: '2020-03-28') collect: #asNumber)

Norbert

Am 28.03.2020 um 13:42 schrieb Christian Haider Christian.Haider@smalltalked-visuals.com:

Hi,

I am using a nice little method #destructDo: for a while now and it feels good.
In VisualWorks:
SequenceableCollection>>destructDo: aBlock
"Evaluate aBlock with the receiver's elements as parameters.
aBlock takes its arguments from the receiver.
'ok'
#(1 2 3) destructDo: [:a :b :c | a + b + c]
#(1 2 3) destructDo: [:a :b | a + b]
#(1 2 3) destructDo: [:a | a]
#(1 2 3) destructDo: [42]
'not ok'
#(1 2 3) destructDo: [:a :b :c :d | a + b + c + d]
"
^aBlock cullWithArguments: self asArray

In Amber:
SequenceableCollection>>destructDo: aBlock
^aBlock valueWithPossibleArguments: self

In Pharo and other dialects, I don’t know, but should be as easy.

For example you can do
(('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day |
Date newDay: day monthNumber: month year: year]

I like that the block is not the receiver (like with #valueWithArguments or #cullWithArguments), but the last argument.

Now the questions:
I am sure that others came up with this. Anybody knows?
What are you using for this pattern?
I don’t really like the name, but haven’t found anything better yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:… maybe something shorter? Ideas?
What are you thinking about this?

Happy hacking,
Christian


Esug-list mailing list
Esug-list@lists.esug.org mailto:Esug-list@lists.esug.org
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org

[:year :month :day | Date newDay: day month: month year: year] valueWithPossibleArguments: (($- split: '2020-03-28') collect: #asNumber) Norbert > Am 28.03.2020 um 13:42 schrieb Christian Haider <Christian.Haider@smalltalked-visuals.com>: > > Hi, > > I am using a nice little method #destructDo: for a while now and it feels good. > In VisualWorks: > SequenceableCollection>>destructDo: aBlock > "Evaluate aBlock with the receiver's elements as parameters. > aBlock takes its arguments from the receiver. > 'ok' > #(1 2 3) destructDo: [:a :b :c | a + b + c] > #(1 2 3) destructDo: [:a :b | a + b] > #(1 2 3) destructDo: [:a | a] > #(1 2 3) destructDo: [42] > 'not ok' > #(1 2 3) destructDo: [:a :b :c :d | a + b + c + d] > " > ^aBlock cullWithArguments: self asArray > > In Amber: > SequenceableCollection>>destructDo: aBlock > ^aBlock valueWithPossibleArguments: self > > In Pharo and other dialects, I don’t know, but should be as easy. > > For example you can do > (('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day | > Date newDay: day monthNumber: month year: year] > > I like that the block is not the receiver (like with #valueWithArguments or #cullWithArguments), but the last argument. > > Now the questions: > I am sure that others came up with this. Anybody knows? > What are you using for this pattern? > I don’t really like the name, but haven’t found anything better yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:… maybe something shorter? Ideas? > What are you thinking about this? > > Happy hacking, > Christian > > _______________________________________________ > Esug-list mailing list > Esug-list@lists.esug.org <mailto:Esug-list@lists.esug.org> > http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org <http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org>
NH
Norbert Hartl
Sat, Mar 28, 2020 1:08 PM

Pressed send to fast. Just wanted to add that this is how it works in pharo but no collection selector.

Norbert

Am 28.03.2020 um 14:06 schrieb Norbert Hartl norbert@hartl.name:

[:year :month :day | Date newDay: day month: month year: year]
valueWithPossibleArguments: (($- split: '2020-03-28') collect: #asNumber)

Norbert

Am 28.03.2020 um 13:42 schrieb Christian Haider <Christian.Haider@smalltalked-visuals.com mailto:Christian.Haider@smalltalked-visuals.com>:

Hi,

I am using a nice little method #destructDo: for a while now and it feels good.
In VisualWorks:
SequenceableCollection>>destructDo: aBlock
"Evaluate aBlock with the receiver's elements as parameters.
aBlock takes its arguments from the receiver.
'ok'
#(1 2 3) destructDo: [:a :b :c | a + b + c]
#(1 2 3) destructDo: [:a :b | a + b]
#(1 2 3) destructDo: [:a | a]
#(1 2 3) destructDo: [42]
'not ok'
#(1 2 3) destructDo: [:a :b :c :d | a + b + c + d]
"
^aBlock cullWithArguments: self asArray

In Amber:
SequenceableCollection>>destructDo: aBlock
^aBlock valueWithPossibleArguments: self

In Pharo and other dialects, I don’t know, but should be as easy.

For example you can do
(('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day |
Date newDay: day monthNumber: month year: year]

I like that the block is not the receiver (like with #valueWithArguments or #cullWithArguments), but the last argument.

Now the questions:
I am sure that others came up with this. Anybody knows?
What are you using for this pattern?
I don’t really like the name, but haven’t found anything better yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:… maybe something shorter? Ideas?
What are you thinking about this?

Happy hacking,
Christian


Esug-list mailing list
Esug-list@lists.esug.org mailto:Esug-list@lists.esug.org
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org

Pressed send to fast. Just wanted to add that this is how it works in pharo but no collection selector. Norbert > Am 28.03.2020 um 14:06 schrieb Norbert Hartl <norbert@hartl.name>: > > [:year :month :day | Date newDay: day month: month year: year] > valueWithPossibleArguments: (($- split: '2020-03-28') collect: #asNumber) > > Norbert > >> Am 28.03.2020 um 13:42 schrieb Christian Haider <Christian.Haider@smalltalked-visuals.com <mailto:Christian.Haider@smalltalked-visuals.com>>: >> >> Hi, >> >> I am using a nice little method #destructDo: for a while now and it feels good. >> In VisualWorks: >> SequenceableCollection>>destructDo: aBlock >> "Evaluate aBlock with the receiver's elements as parameters. >> aBlock takes its arguments from the receiver. >> 'ok' >> #(1 2 3) destructDo: [:a :b :c | a + b + c] >> #(1 2 3) destructDo: [:a :b | a + b] >> #(1 2 3) destructDo: [:a | a] >> #(1 2 3) destructDo: [42] >> 'not ok' >> #(1 2 3) destructDo: [:a :b :c :d | a + b + c + d] >> " >> ^aBlock cullWithArguments: self asArray >> >> In Amber: >> SequenceableCollection>>destructDo: aBlock >> ^aBlock valueWithPossibleArguments: self >> >> In Pharo and other dialects, I don’t know, but should be as easy. >> >> For example you can do >> (('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day | >> Date newDay: day monthNumber: month year: year] >> >> I like that the block is not the receiver (like with #valueWithArguments or #cullWithArguments), but the last argument. >> >> Now the questions: >> I am sure that others came up with this. Anybody knows? >> What are you using for this pattern? >> I don’t really like the name, but haven’t found anything better yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:… maybe something shorter? Ideas? >> What are you thinking about this? >> >> Happy hacking, >> Christian >> >> _______________________________________________ >> Esug-list mailing list >> Esug-list@lists.esug.org <mailto:Esug-list@lists.esug.org> >> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org <http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org> > _______________________________________________ > Esug-list mailing list > Esug-list@lists.esug.org > http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
MP
Mark Plas
Sat, Mar 28, 2020 1:15 PM

Hello Christian,

" I don't really like the name,"

Maybe you could call it #tupleDo:?

            #(1 2 3) tupleDo: [:a :b :c | ...]

Mark

Mark Plas

Software Engineer
T +32 2 467 34 30

mark.plas@mediagenix.tv

[cid:logomgxnew_3d44337b-2535-4d6a-9f5f-3fdd565513ca.png]

http://www.mediagenix.tv/en/cabsat2018/

Nieuwe Gentsesteenweg 21/1https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429

1702 Groot-Bijgaarden - Belgiumhttps://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429

https://nl.linkedin.com/company/mediagenix-nghttps://nl.linkedin.com/company/mediagenix-ng [cid:linkedin_75b9c4f1-6a2b-497c-aab8-df56fe16b8e3.png] https://nl.linkedin.com/company/mediagenix-ng  [cid:twitter_de4c3300-c6ab-4898-a962-b33ff662a322.png] https://twitter.com/mediagenix_tv https://twitter.com/mediagenix_tv https://twitter.com/mediagenix_tv https://www.facebook.com/MEDIAGENIX/ [cid:Facebook-icon_6bef7545-f54e-4548-bfc4-1f07407f2642.png] https://www.facebook.com/MEDIAGENIX/ www.mediagenix.tvhttp://www.mediagenix.tv

Directions to MEDIAGENIXhttp://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf

This e-mail and any files attached to it are confidential and intended only for the use of the individuals or entity to whom they are addressed. If you have received this e-mail in error, please notify the sender immediately.

From: Esug-list esug-list-bounces@lists.esug.org On Behalf Of Christian Haider
Sent: zaterdag 28 maart 2020 13:43
To: vwnc@cs.uiuc.edu; esug-list@lists.esug.org; amber-lang@googlegroups.com
Subject: [Esug-list] destructDo:

Hi,

I am using a nice little method #destructDo: for a while now and it feels good.
In VisualWorks:
SequenceableCollection>>destructDo: aBlock
"Evaluate aBlock with the receiver's elements as parameters.
aBlock takes its arguments from the receiver.
'ok'
#(1 2 3) destructDo: [:a :b :c | a + b + c]
#(1 2 3) destructDo: [:a :b | a + b]
#(1 2 3) destructDo: [:a | a]
#(1 2 3) destructDo: [42]
'not ok'
#(1 2 3) destructDo: [:a :b :c :d | a + b + c + d]
"
^aBlock cullWithArguments: self asArray

In Amber:
SequenceableCollection>>destructDo: aBlock
^aBlock valueWithPossibleArguments: self

In Pharo and other dialects, I don't know, but should be as easy.

For example you can do
(('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day |
Date newDay: day monthNumber: month year: year]

I like that the block is not the receiver (like with #valueWithArguments or #cullWithArguments), but the last argument.

Now the questions:

  • I am sure that others came up with this. Anybody knows?
  • What are you using for this pattern?
  • I don't really like the name, but haven't found anything better yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:... maybe something shorter? Ideas?
  • What are you thinking about this?

Happy hacking,
Christian

Hello Christian, " I don't really like the name," Maybe you could call it #tupleDo:? #(1 2 3) tupleDo: [:a :b :c | ...] Mark Mark Plas Software Engineer T +32 2 467 34 30 mark.plas@mediagenix.tv [cid:logomgxnew_3d44337b-2535-4d6a-9f5f-3fdd565513ca.png] <http://www.mediagenix.tv/en/cabsat2018/> Nieuwe Gentsesteenweg 21/1<https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> 1702 Groot-Bijgaarden - Belgium<https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> <https://nl.linkedin.com/company/mediagenix-ng><https://nl.linkedin.com/company/mediagenix-ng> [cid:linkedin_75b9c4f1-6a2b-497c-aab8-df56fe16b8e3.png] <https://nl.linkedin.com/company/mediagenix-ng> [cid:twitter_de4c3300-c6ab-4898-a962-b33ff662a322.png] <https://twitter.com/mediagenix_tv> <https://twitter.com/mediagenix_tv> <https://twitter.com/mediagenix_tv> <https://www.facebook.com/MEDIAGENIX/> [cid:Facebook-icon_6bef7545-f54e-4548-bfc4-1f07407f2642.png] <https://www.facebook.com/MEDIAGENIX/> www.mediagenix.tv<http://www.mediagenix.tv> Directions to MEDIAGENIX<http://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf> This e-mail and any files attached to it are confidential and intended only for the use of the individuals or entity to whom they are addressed. If you have received this e-mail in error, please notify the sender immediately. From: Esug-list <esug-list-bounces@lists.esug.org> On Behalf Of Christian Haider Sent: zaterdag 28 maart 2020 13:43 To: vwnc@cs.uiuc.edu; esug-list@lists.esug.org; amber-lang@googlegroups.com Subject: [Esug-list] destructDo: Hi, I am using a nice little method #destructDo: for a while now and it feels good. In VisualWorks: SequenceableCollection>>destructDo: aBlock "Evaluate aBlock with the receiver's elements as parameters. aBlock takes its arguments from the receiver. 'ok' #(1 2 3) destructDo: [:a :b :c | a + b + c] #(1 2 3) destructDo: [:a :b | a + b] #(1 2 3) destructDo: [:a | a] #(1 2 3) destructDo: [42] 'not ok' #(1 2 3) destructDo: [:a :b :c :d | a + b + c + d] " ^aBlock cullWithArguments: self asArray In Amber: SequenceableCollection>>destructDo: aBlock ^aBlock valueWithPossibleArguments: self In Pharo and other dialects, I don't know, but should be as easy. For example you can do (('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day | Date newDay: day monthNumber: month year: year] I like that the block is not the receiver (like with #valueWithArguments or #cullWithArguments), but the last argument. Now the questions: * I am sure that others came up with this. Anybody knows? * What are you using for this pattern? * I don't really like the name, but haven't found anything better yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:... maybe something shorter? Ideas? * What are you thinking about this? Happy hacking, Christian
NH
Norbert Hartl
Sat, Mar 28, 2020 1:19 PM

Am 28.03.2020 um 14:15 schrieb Mark Plas mark.plas@mediagenix.tv:

Hello Christian,

" I don’t really like the name,"

Maybe you could call it #tupleDo:?

             #(1 2 3) tupleDo: [:a :b :c | …]

Mark

Mark Plas

Software Engineer
T +32 2 467 34 30
mark.plas@mediagenix.tv mailto:mark.plas@mediagenix.tv

<logomgxnew_3d44337b-2535-4d6a-9f5f-3fdd565513ca.png>
http://www.mediagenix.tv/en/cabsat2018/

Nieuwe Gentsesteenweg 21/1 https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429
1702 Groot-Bijgaarden - Belgium https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429
https://nl.linkedin.com/company/mediagenix-ng https://nl.linkedin.com/company/mediagenix-ng <linkedin_75b9c4f1-6a2b-497c-aab8-df56fe16b8e3.png> https://nl.linkedin.com/company/mediagenix-ng <twitter_de4c3300-c6ab-4898-a962-b33ff662a322.png> https://twitter.com/mediagenix_tv https://twitter.com/mediagenix_tv https://twitter.com/mediagenix_tv https://www.facebook.com/MEDIAGENIX/<Facebook-icon_6bef7545-f54e-4548-bfc4-1f07407f2642.png> https://www.facebook.com/MEDIAGENIX/www.mediagenix.tv http://www.mediagenix.tv/
Directions to MEDIAGENIX http://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf

This e-mail and any files attached to it are confidential and intended only for the use of the individuals or entity to whom they are addressed. If you have received this e-mail in error, please notify the sender immediately.

From: Esug-list <esug-list-bounces@lists.esug.org mailto:esug-list-bounces@lists.esug.org> On Behalf Of Christian Haider
Sent: zaterdag 28 maart 2020 13:43
To: vwnc@cs.uiuc.edu mailto:vwnc@cs.uiuc.edu; esug-list@lists.esug.org mailto:esug-list@lists.esug.org; amber-lang@googlegroups.com mailto:amber-lang@googlegroups.com
Subject: [Esug-list] destructDo:

Hi,

I am using a nice little method #destructDo: for a while now and it feels good.
In VisualWorks:
SequenceableCollection>>destructDo: aBlock
"Evaluate aBlock with the receiver's elements as parameters.
aBlock takes its arguments from the receiver.
'ok'
#(1 2 3) destructDo: [:a :b :c | a + b + c]
#(1 2 3) destructDo: [:a :b | a + b]
#(1 2 3) destructDo: [:a | a]
#(1 2 3) destructDo: [42]
'not ok'
#(1 2 3) destructDo: [:a :b :c :d | a + b + c + d]
"
^aBlock cullWithArguments: self asArray

In Amber:
SequenceableCollection>>destructDo: aBlock
^aBlock valueWithPossibleArguments: self

In Pharo and other dialects, I don’t know, but should be as easy.

For example you can do
(('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day |
Date newDay: day monthNumber: month year: year]

I like that the block is not the receiver (like with #valueWithArguments or #cullWithArguments), but the last argument.

Now the questions:
I am sure that others came up with this. Anybody knows?
What are you using for this pattern?
I don’t really like the name, but haven’t found anything better yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:… maybe something shorter? Ideas?
What are you thinking about this?

Happy hacking,
Christian


Esug-list mailing list
Esug-list@lists.esug.org mailto:Esug-list@lists.esug.org
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org

I think the name destructDo: comes from destructuring assignment. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment> Norbert > Am 28.03.2020 um 14:15 schrieb Mark Plas <mark.plas@mediagenix.tv>: > > Hello Christian, > > " I don’t really like the name," > > Maybe you could call it #tupleDo:? > > #(1 2 3) tupleDo: [:a :b :c | …] > > Mark > > > > Mark Plas > > Software Engineer > T +32 2 467 34 30 > mark.plas@mediagenix.tv <mailto:mark.plas@mediagenix.tv> > > > <logomgxnew_3d44337b-2535-4d6a-9f5f-3fdd565513ca.png> > <http://www.mediagenix.tv/en/cabsat2018/> > > Nieuwe Gentsesteenweg 21/1 <https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> > 1702 Groot-Bijgaarden - Belgium <https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> > <https://nl.linkedin.com/company/mediagenix-ng> <https://nl.linkedin.com/company/mediagenix-ng> <linkedin_75b9c4f1-6a2b-497c-aab8-df56fe16b8e3.png> <https://nl.linkedin.com/company/mediagenix-ng> <twitter_de4c3300-c6ab-4898-a962-b33ff662a322.png> <https://twitter.com/mediagenix_tv> <https://twitter.com/mediagenix_tv> <https://twitter.com/mediagenix_tv> <https://www.facebook.com/MEDIAGENIX/><Facebook-icon_6bef7545-f54e-4548-bfc4-1f07407f2642.png> <https://www.facebook.com/MEDIAGENIX/>www.mediagenix.tv <http://www.mediagenix.tv/> > Directions to MEDIAGENIX <http://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf> > > > This e-mail and any files attached to it are confidential and intended only for the use of the individuals or entity to whom they are addressed. If you have received this e-mail in error, please notify the sender immediately. > > > From: Esug-list <esug-list-bounces@lists.esug.org <mailto:esug-list-bounces@lists.esug.org>> On Behalf Of Christian Haider > Sent: zaterdag 28 maart 2020 13:43 > To: vwnc@cs.uiuc.edu <mailto:vwnc@cs.uiuc.edu>; esug-list@lists.esug.org <mailto:esug-list@lists.esug.org>; amber-lang@googlegroups.com <mailto:amber-lang@googlegroups.com> > Subject: [Esug-list] destructDo: > > Hi, > > I am using a nice little method #destructDo: for a while now and it feels good. > In VisualWorks: > SequenceableCollection>>destructDo: aBlock > "Evaluate aBlock with the receiver's elements as parameters. > aBlock takes its arguments from the receiver. > 'ok' > #(1 2 3) destructDo: [:a :b :c | a + b + c] > #(1 2 3) destructDo: [:a :b | a + b] > #(1 2 3) destructDo: [:a | a] > #(1 2 3) destructDo: [42] > 'not ok' > #(1 2 3) destructDo: [:a :b :c :d | a + b + c + d] > " > ^aBlock cullWithArguments: self asArray > > In Amber: > SequenceableCollection>>destructDo: aBlock > ^aBlock valueWithPossibleArguments: self > > In Pharo and other dialects, I don’t know, but should be as easy. > > For example you can do > (('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day | > Date newDay: day monthNumber: month year: year] > > I like that the block is not the receiver (like with #valueWithArguments or #cullWithArguments), but the last argument. > > Now the questions: > I am sure that others came up with this. Anybody knows? > What are you using for this pattern? > I don’t really like the name, but haven’t found anything better yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:… maybe something shorter? Ideas? > What are you thinking about this? > > Happy hacking, > Christian > > _______________________________________________ > Esug-list mailing list > Esug-list@lists.esug.org <mailto:Esug-list@lists.esug.org> > http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org <http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org>
GC
Giovanni Corriga
Sat, Mar 28, 2020 1:35 PM

How about #consume: ?

Il giorno sab 28 mar 2020 alle ore 13:20 Norbert Hartl norbert@hartl.name
ha scritto:

I think the name destructDo: comes from destructuring assignment.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

Norbert

Am 28.03.2020 um 14:15 schrieb Mark Plas mark.plas@mediagenix.tv:

Hello Christian,

" I don’t really like the name,"

Maybe you could call it #tupleDo:?

             #(1 2 3) tupleDo: [:a :b :c | …]

Mark

Mark Plas
Software Engineer
T +32 2 467 34 30

mark.plas@mediagenix.tv

<logomgxnew_3d44337b-2535-4d6a-9f5f-3fdd565513ca.png>

http://www.mediagenix.tv/en/cabsat2018/
Nieuwe Gentsesteenweg 21/1
https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429

1702 Groot-Bijgaarden - Belgium
https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429

https://nl.linkedin.com/company/mediagenix-ng
https://nl.linkedin.com/company/mediagenix-ng
<linkedin_75b9c4f1-6a2b-497c-aab8-df56fe16b8e3.png>
https://nl.linkedin.com/company/mediagenix-ng
<twitter_de4c3300-c6ab-4898-a962-b33ff662a322.png>
https://twitter.com/mediagenix_tv https://twitter.com/mediagenix_tv
https://twitter.com/mediagenix_tv https://www.facebook.com/MEDIAGENIX/
<Facebook-icon_6bef7545-f54e-4548-bfc4-1f07407f2642.png>
https://www.facebook.com/MEDIAGENIX/www.mediagenix.tv
Directions to MEDIAGENIX
http://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf

This e-mail and any files attached to it are confidential and intended
only for the use of the individuals or entity to whom they are addressed.
If you have received this e-mail in error, please notify the sender
immediately.

From: Esug-list esug-list-bounces@lists.esug.org *On Behalf Of *Christian
Haider
Sent: zaterdag 28 maart 2020 13:43
To: vwnc@cs.uiuc.edu; esug-list@lists.esug.org;
amber-lang@googlegroups.com
Subject: [Esug-list] destructDo:

Hi,

I am using a nice little method #destructDo: for a while now and it feels
good.
In VisualWorks:
SequenceableCollection>>destructDo: aBlock
"Evaluate aBlock with the receiver's
elements as parameters.
aBlock takes its arguments from the
receiver.
'ok'
#(1 2 3) destructDo: [:a :b :c | a + b + c]
#(1 2 3) destructDo: [:a :b | a + b]
#(1 2 3) destructDo: [:a | a]
#(1 2 3) destructDo: [42]
'not ok'
#(1 2 3) destructDo: [:a :b :c :d | a + b

  • c + d]
    "
    ^aBlock cullWithArguments: self asArray

In Amber:
SequenceableCollection>>destructDo: aBlock
^aBlock valueWithPossibleArguments: self

In Pharo and other dialects, I don’t know, but should be as easy.

For example you can do
(('2020-03-28' tokensBasedOn: $-) collect: #asNumber)
destructDo: [:year :month :day |
Date newDay: day monthNumber: month year:
year]

I like that the block is not the receiver (like with #valueWithArguments
or #cullWithArguments), but the last argument.

Now the questions:

- I am sure that others came up with this. Anybody knows?
- What are you using for this pattern?
- I don’t really like the name, but haven’t found anything better yet.
Maybe #destructedDo: or just #destructed: or: #withPartsDo:… maybe
something shorter? Ideas?
- What are you thinking about this?

Happy hacking,
Christian


Esug-list mailing list
Esug-list@lists.esug.org
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org


Esug-list mailing list
Esug-list@lists.esug.org
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org

How about #consume: ? Il giorno sab 28 mar 2020 alle ore 13:20 Norbert Hartl <norbert@hartl.name> ha scritto: > I think the name destructDo: comes from destructuring assignment. > > > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment > > Norbert > > Am 28.03.2020 um 14:15 schrieb Mark Plas <mark.plas@mediagenix.tv>: > > Hello Christian, > > " I don’t really like the name," > > Maybe you could call it #tupleDo:? > > #(1 2 3) tupleDo: [:a :b :c | …] > > Mark > > > > > *Mark Plas* > Software Engineer > T +32 2 467 34 30 > > mark.plas@mediagenix.tv > > > <logomgxnew_3d44337b-2535-4d6a-9f5f-3fdd565513ca.png> > > <http://www.mediagenix.tv/en/cabsat2018/> > Nieuwe Gentsesteenweg 21/1 > <https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> > > 1702 Groot-Bijgaarden - Belgium > <https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> > > <https://nl.linkedin.com/company/mediagenix-ng> > <https://nl.linkedin.com/company/mediagenix-ng> > <linkedin_75b9c4f1-6a2b-497c-aab8-df56fe16b8e3.png> > <https://nl.linkedin.com/company/mediagenix-ng> > <twitter_de4c3300-c6ab-4898-a962-b33ff662a322.png> > <https://twitter.com/mediagenix_tv> <https://twitter.com/mediagenix_tv> > <https://twitter.com/mediagenix_tv> <https://www.facebook.com/MEDIAGENIX/> > <Facebook-icon_6bef7545-f54e-4548-bfc4-1f07407f2642.png> > <https://www.facebook.com/MEDIAGENIX/>www.mediagenix.tv > Directions to MEDIAGENIX > <http://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf> > > > > *This e-mail and any files attached to it are confidential and intended > only for the use of the individuals or entity to whom they are addressed. > If you have received this e-mail in error, please notify the sender > immediately.* > > *From:* Esug-list <esug-list-bounces@lists.esug.org> *On Behalf Of *Christian > Haider > *Sent:* zaterdag 28 maart 2020 13:43 > *To:* vwnc@cs.uiuc.edu; esug-list@lists.esug.org; > amber-lang@googlegroups.com > *Subject:* [Esug-list] destructDo: > > Hi, > > I am using a nice little method #destructDo: for a while now and it feels > good. > In VisualWorks: > SequenceableCollection>>destructDo: aBlock > "Evaluate aBlock with the receiver's > elements as parameters. > aBlock takes its arguments from the > receiver. > 'ok' > #(1 2 3) destructDo: [:a :b :c | a + b + c] > #(1 2 3) destructDo: [:a :b | a + b] > #(1 2 3) destructDo: [:a | a] > #(1 2 3) destructDo: [42] > 'not ok' > #(1 2 3) destructDo: [:a :b :c :d | a + b > + c + d] > " > ^aBlock cullWithArguments: self asArray > > In Amber: > SequenceableCollection>>destructDo: aBlock > ^aBlock valueWithPossibleArguments: self > > In Pharo and other dialects, I don’t know, but should be as easy. > > For example you can do > (('2020-03-28' tokensBasedOn: $-) collect: #asNumber) > destructDo: [:year :month :day | > Date newDay: day monthNumber: month year: > year] > > I like that the block is not the receiver (like with #valueWithArguments > or #cullWithArguments), but the last argument. > > Now the questions: > > - I am sure that others came up with this. Anybody knows? > - What are you using for this pattern? > - I don’t really like the name, but haven’t found anything better yet. > Maybe #destructedDo: or just #destructed: or: #withPartsDo:… maybe > something shorter? Ideas? > - What are you thinking about this? > > > Happy hacking, > Christian > > _______________________________________________ > Esug-list mailing list > Esug-list@lists.esug.org > http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org > > > _______________________________________________ > Esug-list mailing list > Esug-list@lists.esug.org > http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org >
GM
Graham McLeod
Sat, Mar 28, 2020 1:47 PM

How about: #mapTo:

Graham

Giovanni Corriga mailto:giovanni@corriga.net
28 March 2020 at 15:35
How about #consume: ?


Esug-list mailing list
Esug-list@lists.esug.org
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
Norbert Hartl mailto:norbert@hartl.name
28 March 2020 at 15:19
I think the name destructDo: comes from destructuring assignment.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

Norbert


Esug-list mailing list
Esug-list@lists.esug.org
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
Mark Plas mailto:mark.plas@mediagenix.tv
28 March 2020 at 15:15

Hello Christian,

"I don’t really like the name,"

Maybe you could call it #tupleDo:?

                #(1 2 3) tupleDo: [:a :b :c | …]

Mark

**

Mark Plas

Software Engineer
T +32 2 467 34 30

mark.plas@mediagenix.tv

Nieuwe Gentsesteenweg 21/1
https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429

1702 Groot-Bijgaarden - Belgium
https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429

https://nl.linkedin.com/company/mediagenix-ng
https://twitter.com/mediagenix_tvhttps://www.facebook.com/MEDIAGENIX/www.mediagenix.tv
http://www.mediagenix.tv

Directions to MEDIAGENIX
http://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf

/This e-mail and any files attached to it are confidential and
intended only for the use of the individuals or entity to whom they
are addressed. If you have received this e-mail in error, please
notify the sender immediately./

*From:*Esug-list esug-list-bounces@lists.esug.org *On Behalf Of
*Christian Haider
Sent: zaterdag 28 maart 2020 13:43
To: vwnc@cs.uiuc.edu; esug-list@lists.esug.org;
amber-lang@googlegroups.com
Subject: [Esug-list] destructDo:

Hi,

I am using a nice little method #destructDo: for a while now and it
feels good.

In VisualWorks:

SequenceableCollection>>destructDo: aBlock

"Evaluate aBlock with the receiver's elements as parameters.

aBlock takes its arguments from the receiver.

'ok'

#(1 2 3) destructDo: [:a :b :c | a + b + c]

#(1 2 3) destructDo: [:a :b | a + b]

#(1 2 3) destructDo: [:a | a]

#(1 2 3) destructDo: [42]

'not ok'

#(1 2 3) destructDo: [:a :b :c :d | a + b + c + d]

"

^aBlock cullWithArguments: self asArray

In Amber:

SequenceableCollection>>destructDo: aBlock

^aBlock valueWithPossibleArguments: self

In Pharo and other dialects, I don’t know, but should be as easy.

For example you can do

                (('2020-03-28' tokensBasedOn: $-) collect: #asNumber)
destructDo: [:year :month :day |

Date newDay: day monthNumber: month year: year]

I like that the block is not the receiver (like with
#valueWithArguments or #cullWithArguments), but the last argument.

Now the questions:

  • I am sure that others came up with this. Anybody knows?
  • What are you using for this pattern?
  • I don’t really like the name, but haven’t found anything better
    yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:…
    maybe something shorter? Ideas?
  • What are you thinking about this?

Happy hacking,

                Christian


Esug-list mailing list
Esug-list@lists.esug.org
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
Christian Haider mailto:christian.haider@smalltalked-visuals.com
28 March 2020 at 14:42

Hi,

I am using a nice little method #destructDo: for a while now and it
feels good.

In VisualWorks:

SequenceableCollection>>destructDo: aBlock

                "Evaluate aBlock with the receiver's elements as
parameters.

                aBlock takes its arguments from the receiver.

'ok'

                #(1 2 3) destructDo: [:a :b :c | a + b + c]

#(1 2 3) destructDo: [:a :b | a + b]

                                #(1 2 3) destructDo: [:a | a]

                                #(1 2 3) destructDo: [42]

'not ok'

                #(1 2 3) destructDo: [:a :b :c :d | a + b + c + d]

"

                                ^aBlock cullWithArguments: self asArray

In Amber:

SequenceableCollection>>destructDo: aBlock

                ^aBlock valueWithPossibleArguments: self

In Pharo and other dialects, I don’t know, but should be as easy.

For example you can do

                (('2020-03-28' tokensBasedOn: $-) collect: #asNumber)
destructDo: [:year :month :day |

Date newDay: day monthNumber: month year: year]

I like that the block is not the receiver (like with
#valueWithArguments or #cullWithArguments), but the last argument.

Now the questions:

  • I am sure that others came up with this. Anybody knows?
  • What are you using for this pattern?
  • I don’t really like the name, but haven’t found anything better
    yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:…
    maybe something shorter? Ideas?
  • What are you thinking about this?

Happy hacking,

                Christian


Esug-list mailing list
Esug-list@lists.esug.org
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org

How about: #mapTo: Graham > Giovanni Corriga <mailto:giovanni@corriga.net> > 28 March 2020 at 15:35 > How about #consume: ? > > > > _______________________________________________ > Esug-list mailing list > Esug-list@lists.esug.org > http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org > Norbert Hartl <mailto:norbert@hartl.name> > 28 March 2020 at 15:19 > I think the name destructDo: comes from destructuring assignment. > > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment > > Norbert > > > > > _______________________________________________ > Esug-list mailing list > Esug-list@lists.esug.org > http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org > Mark Plas <mailto:mark.plas@mediagenix.tv> > 28 March 2020 at 15:15 > > Hello Christian, > > "I don’t really like the name," > > Maybe you could call it #tupleDo:? > >                 #(1 2 3) tupleDo: [:a :b :c | …] > > Mark > > ** > > *Mark Plas* > > Software Engineer > T +32 2 467 34 30 > > mark.plas@mediagenix.tv > > > > Nieuwe Gentsesteenweg 21/1 > <https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> > > 1702 Groot-Bijgaarden - Belgium > <https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> > > <https://nl.linkedin.com/company/mediagenix-ng> > <https://twitter.com/mediagenix_tv><https://www.facebook.com/MEDIAGENIX/>www.mediagenix.tv > <http://www.mediagenix.tv> > > Directions to MEDIAGENIX > <http://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf> > > /This e-mail and any files attached to it are confidential and > intended only for the use of the individuals or entity to whom they > are addressed. If you have received this e-mail in error, please > notify the sender immediately./ > > *From:*Esug-list <esug-list-bounces@lists.esug.org> *On Behalf Of > *Christian Haider > *Sent:* zaterdag 28 maart 2020 13:43 > *To:* vwnc@cs.uiuc.edu; esug-list@lists.esug.org; > amber-lang@googlegroups.com > *Subject:* [Esug-list] destructDo: > > Hi, > > I am using a nice little method #destructDo: for a while now and it > feels good. > > In VisualWorks: > > SequenceableCollection>>destructDo: aBlock > > "Evaluate aBlock with the receiver's elements as parameters. > > aBlock takes its arguments from the receiver. > > 'ok' > > #(1 2 3) destructDo: [:a :b :c | a + b + c] > > #(1 2 3) destructDo: [:a :b | a + b] > > #(1 2 3) destructDo: [:a | a] > > #(1 2 3) destructDo: [42] > > 'not ok' > > #(1 2 3) destructDo: [:a :b :c :d | a + b + c + d] > > " > > ^aBlock cullWithArguments: self asArray > > In Amber: > > SequenceableCollection>>destructDo: aBlock > > ^aBlock valueWithPossibleArguments: self > > In Pharo and other dialects, I don’t know, but should be as easy. > > For example you can do > >                 (('2020-03-28' tokensBasedOn: $-) collect: #asNumber) > destructDo: [:year :month :day | > > Date newDay: day monthNumber: month year: year] > > I like that the block is not the receiver (like with > #valueWithArguments or #cullWithArguments), but the last argument. > > Now the questions: > > * I am sure that others came up with this. Anybody knows? > * What are you using for this pattern? > * I don’t really like the name, but haven’t found anything better > yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:… > maybe something shorter? Ideas? > * What are you thinking about this? > > Happy hacking, > >                 Christian > > > > _______________________________________________ > Esug-list mailing list > Esug-list@lists.esug.org > http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org > Christian Haider <mailto:christian.haider@smalltalked-visuals.com> > 28 March 2020 at 14:42 > > Hi, > > I am using a nice little method #destructDo: for a while now and it > feels good. > > In VisualWorks: > > SequenceableCollection>>destructDo: aBlock > >                 "Evaluate aBlock with the receiver's elements as > parameters. > >                 aBlock takes its arguments from the receiver. > > 'ok' > >                 #(1 2 3) destructDo: [:a :b :c | a + b + c] > > #(1 2 3) destructDo: [:a :b | a + b] > >                                 #(1 2 3) destructDo: [:a | a] > >                                 #(1 2 3) destructDo: [42] > > 'not ok' > >                 #(1 2 3) destructDo: [:a :b :c :d | a + b + c + d] > > " > >                                 ^aBlock cullWithArguments: self asArray > > In Amber: > > SequenceableCollection>>destructDo: aBlock > >                 ^aBlock valueWithPossibleArguments: self > > In Pharo and other dialects, I don’t know, but should be as easy. > > For example you can do > >                 (('2020-03-28' tokensBasedOn: $-) collect: #asNumber) > destructDo: [:year :month :day | > > Date newDay: day monthNumber: month year: year] > > I like that the block is not the receiver (like with > #valueWithArguments or #cullWithArguments), but the last argument. > > Now the questions: > > * I am sure that others came up with this. Anybody knows? > * What are you using for this pattern? > * I don’t really like the name, but haven’t found anything better > yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:… > maybe something shorter? Ideas? > * What are you thinking about this? > > Happy hacking, > >                 Christian > > > > _______________________________________________ > Esug-list mailing list > Esug-list@lists.esug.org > http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
KK
Karsten Kusche
Sat, Mar 28, 2020 1:50 PM

It reminds me of Javascript there you have similar constructs via apply() and i tend to think that the name is not too bad either.

#(1 2 3) apply:[:a :b :c | ]

I am a bit sceptic about the idea though. Given the examples you provided i do think it’s a neat solution but when i consider:

(('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day |
Date newDay: day monthNumber: month year: year]

I’m sure that the input string is not a literal because then this whole code doesn’t make much sense at all.
But when the string is not literal, no-one can guarantee the correctness of the string.
I’ve seen you use #cull: in the implementation so at least there’s no error if the number of arguments is smaller than the collection. But what happens the other way around?
Maybe you should call #valueWithArguments: and ensure that the arguments are filled up with nil.

Other than that i hope such a construct doesn’t lure people to use tupel-like arrays. That just produces the hardest-to-understand code ever.

Kind Regards
Karsten

Georg Heeg eK

Wallstraße 22
06366 Köthen

Tel.: 03496/214328
FAX: 03496/214712
Amtsgericht Dortmund HRA 12812

Am 28. März 2020 bei 14:36:11, Giovanni Corriga (giovanni@corriga.netmailto:giovanni@corriga.net) schrieb:

How about #consume: ?

Il giorno sab 28 mar 2020 alle ore 13:20 Norbert Hartl <norbert@hartl.namemailto:norbert@hartl.name> ha scritto:
I think the name destructDo: comes from destructuring assignment.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

Norbert

Am 28.03.2020 um 14:15 schrieb Mark Plas <mark.plas@mediagenix.tvmailto:mark.plas@mediagenix.tv>:

Hello Christian,

" I don’t really like the name,"

Maybe you could call it #tupleDo:?

            #(1 2 3) tupleDo: [:a :b :c | …]

Mark

Mark Plas

Software Engineer
T +32 2 467 34 30

mark.plas@mediagenix.tvmailto:mark.plas@mediagenix.tv

<logomgxnew_3d44337b-2535-4d6a-9f5f-3fdd565513ca.png>

http://www.mediagenix.tv/en/cabsat2018/

Nieuwe Gentsesteenweg 21/1https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429

1702 Groot-Bijgaarden - Belgiumhttps://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429

https://nl.linkedin.com/company/mediagenix-nghttps://nl.linkedin.com/company/mediagenix-ng <linkedin_75b9c4f1-6a2b-497c-aab8-df56fe16b8e3.png>https://nl.linkedin.com/company/mediagenix-ng <twitter_de4c3300-c6ab-4898-a962-b33ff662a322.png>https://twitter.com/mediagenix_tvhttps://twitter.com/mediagenix_tvhttps://twitter.com/mediagenix_tvhttps://www.facebook.com/MEDIAGENIX/<Facebook-icon_6bef7545-f54e-4548-bfc4-1f07407f2642.png>https://www.facebook.com/MEDIAGENIX/www.mediagenix.tvhttp://www.mediagenix.tv/

Directions to MEDIAGENIXhttp://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf

This e-mail and any files attached to it are confidential and intended only for the use of the individuals or entity to whom they are addressed. If you have received this e-mail in error, please notify the sender immediately.

From: Esug-list <esug-list-bounces@lists.esug.orgmailto:esug-list-bounces@lists.esug.org> On Behalf Of Christian Haider
Sent: zaterdag 28 maart 2020 13:43
To: vwnc@cs.uiuc.edumailto:vwnc@cs.uiuc.edu; esug-list@lists.esug.orgmailto:esug-list@lists.esug.org; amber-lang@googlegroups.commailto:amber-lang@googlegroups.com
Subject: [Esug-list] destructDo:

Hi,

I am using a nice little method #destructDo: for a while now and it feels good.
In VisualWorks:
SequenceableCollection>>destructDo: aBlock
"Evaluate aBlock with the receiver's elements as parameters.
aBlock takes its arguments from the receiver.
'ok'
#(1 2 3) destructDo: [:a :b :c | a + b + c]
#(1 2 3) destructDo: [:a :b | a + b]
#(1 2 3) destructDo: [:a | a]
#(1 2 3) destructDo: [42]
'not ok'
#(1 2 3) destructDo: [:a :b :c :d | a + b + c + d]
"
^aBlock cullWithArguments: self asArray

In Amber:
SequenceableCollection>>destructDo: aBlock
^aBlock valueWithPossibleArguments: self

In Pharo and other dialects, I don’t know, but should be as easy.

For example you can do
(('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day |
Date newDay: day monthNumber: month year: year]

I like that the block is not the receiver (like with #valueWithArguments or #cullWithArguments), but the last argument.

Now the questions:

  • I am sure that others came up with this. Anybody knows?
  • What are you using for this pattern?
  • I don’t really like the name, but haven’t found anything better yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:… maybe something shorter? Ideas?
  • What are you thinking about this?

Happy hacking,
Christian


Esug-list mailing list
Esug-list@lists.esug.orgmailto:Esug-list@lists.esug.org
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org


Esug-list mailing list
Esug-list@lists.esug.orgmailto:Esug-list@lists.esug.org
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org

It reminds me of Javascript there you have similar constructs via apply() and i tend to think that the name is not too bad either. #(1 2 3) apply:[:a :b :c | ] I am a bit sceptic about the idea though. Given the examples you provided i do think it’s a neat solution but when i consider: (('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day | Date newDay: day monthNumber: month year: year] I’m sure that the input string is not a literal because then this whole code doesn’t make much sense at all. But when the string is not literal, no-one can guarantee the correctness of the string. I’ve seen you use #cull: in the implementation so at least there’s no error if the number of arguments is smaller than the collection. But what happens the other way around? Maybe you should call #valueWithArguments: and ensure that the arguments are filled up with nil. Other than that i hope such a construct doesn’t lure people to use tupel-like arrays. That just produces the hardest-to-understand code ever. Kind Regards Karsten — Georg Heeg eK Wallstraße 22 06366 Köthen Tel.: 03496/214328 FAX: 03496/214712 Amtsgericht Dortmund HRA 12812 Am 28. März 2020 bei 14:36:11, Giovanni Corriga (giovanni@corriga.net<mailto:giovanni@corriga.net>) schrieb: How about #consume: ? Il giorno sab 28 mar 2020 alle ore 13:20 Norbert Hartl <norbert@hartl.name<mailto:norbert@hartl.name>> ha scritto: I think the name destructDo: comes from destructuring assignment. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment Norbert Am 28.03.2020 um 14:15 schrieb Mark Plas <mark.plas@mediagenix.tv<mailto:mark.plas@mediagenix.tv>>: Hello Christian, " I don’t really like the name," Maybe you could call it #tupleDo:? #(1 2 3) tupleDo: [:a :b :c | …] Mark Mark Plas Software Engineer T +32 2 467 34 30 mark.plas@mediagenix.tv<mailto:mark.plas@mediagenix.tv> <logomgxnew_3d44337b-2535-4d6a-9f5f-3fdd565513ca.png> <http://www.mediagenix.tv/en/cabsat2018/> Nieuwe Gentsesteenweg 21/1<https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> 1702 Groot-Bijgaarden - Belgium<https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> <https://nl.linkedin.com/company/mediagenix-ng><https://nl.linkedin.com/company/mediagenix-ng> <linkedin_75b9c4f1-6a2b-497c-aab8-df56fe16b8e3.png><https://nl.linkedin.com/company/mediagenix-ng> <twitter_de4c3300-c6ab-4898-a962-b33ff662a322.png><https://twitter.com/mediagenix_tv><https://twitter.com/mediagenix_tv><https://twitter.com/mediagenix_tv><https://www.facebook.com/MEDIAGENIX/><Facebook-icon_6bef7545-f54e-4548-bfc4-1f07407f2642.png><https://www.facebook.com/MEDIAGENIX/>www.mediagenix.tv<http://www.mediagenix.tv/> Directions to MEDIAGENIX<http://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf> This e-mail and any files attached to it are confidential and intended only for the use of the individuals or entity to whom they are addressed. If you have received this e-mail in error, please notify the sender immediately. From: Esug-list <esug-list-bounces@lists.esug.org<mailto:esug-list-bounces@lists.esug.org>> On Behalf Of Christian Haider Sent: zaterdag 28 maart 2020 13:43 To: vwnc@cs.uiuc.edu<mailto:vwnc@cs.uiuc.edu>; esug-list@lists.esug.org<mailto:esug-list@lists.esug.org>; amber-lang@googlegroups.com<mailto:amber-lang@googlegroups.com> Subject: [Esug-list] destructDo: Hi, I am using a nice little method #destructDo: for a while now and it feels good. In VisualWorks: SequenceableCollection>>destructDo: aBlock "Evaluate aBlock with the receiver's elements as parameters. aBlock takes its arguments from the receiver. 'ok' #(1 2 3) destructDo: [:a :b :c | a + b + c] #(1 2 3) destructDo: [:a :b | a + b] #(1 2 3) destructDo: [:a | a] #(1 2 3) destructDo: [42] 'not ok' #(1 2 3) destructDo: [:a :b :c :d | a + b + c + d] " ^aBlock cullWithArguments: self asArray In Amber: SequenceableCollection>>destructDo: aBlock ^aBlock valueWithPossibleArguments: self In Pharo and other dialects, I don’t know, but should be as easy. For example you can do (('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day | Date newDay: day monthNumber: month year: year] I like that the block is not the receiver (like with #valueWithArguments or #cullWithArguments), but the last argument. Now the questions: * I am sure that others came up with this. Anybody knows? * What are you using for this pattern? * I don’t really like the name, but haven’t found anything better yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:… maybe something shorter? Ideas? * What are you thinking about this? Happy hacking, Christian _______________________________________________ Esug-list mailing list Esug-list@lists.esug.org<mailto:Esug-list@lists.esug.org> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org _______________________________________________ Esug-list mailing list Esug-list@lists.esug.org<mailto:Esug-list@lists.esug.org> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
CD
Christophe Dony
Sat, Mar 28, 2020 2:17 PM

Hi.
I like tupleDo:

or matchDo:

and what about installing a full pattern matching, as in many languages
e.g. Scheme : https://docs.racket-lang.org/reference/match.html

#(1 #(2 3 6 7) 4) matchDo: [:a (:b :@c) :d] | …]
here c would be #(3 6 7)

may be it already exist?
if not, would really be a +

Christophe

Le 28/03/2020 à 14:15, Mark Plas a écrit :

Hello Christian,

"I don’t really like the name,"

Maybe you could call it #tupleDo:?

             #(1 2 3) tupleDo: [:a :b :c | …]

Mark

**

Mark Plas

Software Engineer
T +32 2 467 34 30

mark.plas@mediagenix.tv

Nieuwe Gentsesteenweg 21/1
https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429

1702 Groot-Bijgaarden - Belgium
https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429

https://nl.linkedin.com/company/mediagenix-ng
https://twitter.com/mediagenix_tvhttps://www.facebook.com/MEDIAGENIX/www.mediagenix.tv
http://www.mediagenix.tv

Directions to MEDIAGENIX
http://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf

/This e-mail and any files attached to it are confidential and
intended only for the use of the individuals or entity to whom they
are addressed. If you have received this e-mail in error, please
notify the sender immediately./

*From:*Esug-list esug-list-bounces@lists.esug.org *On Behalf Of
*Christian Haider
Sent: zaterdag 28 maart 2020 13:43
To: vwnc@cs.uiuc.edu; esug-list@lists.esug.org;
amber-lang@googlegroups.com
Subject: [Esug-list] destructDo:

Hi,

I am using a nice little method #destructDo: for a while now and it
feels good.

In VisualWorks:

SequenceableCollection>>destructDo: aBlock

             "Evaluate aBlock with the receiver's elements as 

parameters.

             aBlock takes its arguments from the receiver.

             'ok'

             #(1 2 3) destructDo: [:a :b :c | a + b + c]

             #(1 2 3) destructDo: [:a :b | a + b]

             #(1 2 3) destructDo: [:a | a]

             #(1 2 3) destructDo: [42]

             'not ok'

             #(1 2 3) destructDo: [:a :b :c :d | a + b + c + d]

"

             ^aBlock cullWithArguments: self asArray

In Amber:

SequenceableCollection>>destructDo: aBlock

             ^aBlock valueWithPossibleArguments: self

In Pharo and other dialects, I don’t know, but should be as easy.

For example you can do

(('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo:
[:year :month :day |

Date newDay: day monthNumber: month year: year]

I like that the block is not the receiver (like with
#valueWithArguments or #cullWithArguments), but the last argument.

Now the questions:

  • I am sure that others came up with this. Anybody knows?
  • What are you using for this pattern?
  • I don’t really like the name, but haven’t found anything better
    yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:…
    maybe something shorter? Ideas?
  • What are you thinking about this?

Happy hacking,

Christian


Esug-list mailing list
Esug-list@lists.esug.org
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org

Hi. I like tupleDo: or matchDo: and what about installing a full pattern matching, as in many languages e.g. Scheme : https://docs.racket-lang.org/reference/match.html #(1 #(2 3 6 7) 4) matchDo: [:a (:b :@c) :d] | …] here c would be #(3 6 7) may be it already exist? if not, would really be a + Christophe Le 28/03/2020 à 14:15, Mark Plas a écrit : > > Hello Christian, > > "I don’t really like the name," > > Maybe you could call it #tupleDo:? > > #(1 2 3) tupleDo: [:a :b :c | …] > > Mark > > ** > > *Mark Plas* > > Software Engineer > T +32 2 467 34 30 > > mark.plas@mediagenix.tv > > > > Nieuwe Gentsesteenweg 21/1 > <https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> > > 1702 Groot-Bijgaarden - Belgium > <https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> > > <https://nl.linkedin.com/company/mediagenix-ng> > <https://twitter.com/mediagenix_tv><https://www.facebook.com/MEDIAGENIX/>www.mediagenix.tv > <http://www.mediagenix.tv> > > Directions to MEDIAGENIX > <http://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf> > > /This e-mail and any files attached to it are confidential and > intended only for the use of the individuals or entity to whom they > are addressed. If you have received this e-mail in error, please > notify the sender immediately./ > > *From:*Esug-list <esug-list-bounces@lists.esug.org> *On Behalf Of > *Christian Haider > *Sent:* zaterdag 28 maart 2020 13:43 > *To:* vwnc@cs.uiuc.edu; esug-list@lists.esug.org; > amber-lang@googlegroups.com > *Subject:* [Esug-list] destructDo: > > Hi, > > I am using a nice little method #destructDo: for a while now and it > feels good. > > In VisualWorks: > > SequenceableCollection>>destructDo: aBlock > > "Evaluate aBlock with the receiver's elements as > parameters. > > aBlock takes its arguments from the receiver. > > 'ok' > > #(1 2 3) destructDo: [:a :b :c | a + b + c] > > #(1 2 3) destructDo: [:a :b | a + b] > > #(1 2 3) destructDo: [:a | a] > > #(1 2 3) destructDo: [42] > > 'not ok' > > #(1 2 3) destructDo: [:a :b :c :d | a + b + c + d] > > " > > ^aBlock cullWithArguments: self asArray > > In Amber: > > SequenceableCollection>>destructDo: aBlock > > ^aBlock valueWithPossibleArguments: self > > In Pharo and other dialects, I don’t know, but should be as easy. > > For example you can do > > (('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: > [:year :month :day | > > Date newDay: day monthNumber: month year: year] > > I like that the block is not the receiver (like with > #valueWithArguments or #cullWithArguments), but the last argument. > > Now the questions: > > * I am sure that others came up with this. Anybody knows? > * What are you using for this pattern? > * I don’t really like the name, but haven’t found anything better > yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:… > maybe something shorter? Ideas? > * What are you thinking about this? > > Happy hacking, > > Christian > > > > _______________________________________________ > Esug-list mailing list > Esug-list@lists.esug.org > http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
CH
Christian Haider
Sat, Mar 28, 2020 2:23 PM

I chose the name because of the old Lisp “destructuring-bind”. But this is more powerful, because it does tree matching. This is just shallow.

I am not sure where the concept was invented first. It may have been Lisp.

Von: Norbert Hartl norbert@hartl.name
Gesendet: Samstag, 28. März 2020 14:20
An: Mark Plas mark.plas@mediagenix.tv
Cc: Christian Haider christian.haider@smalltalked-visuals.com; vwnc@cs.uiuc.edu; esug-list@lists.esug.org; amber-lang@googlegroups.com
Betreff: Re: [Esug-list] destructDo:

I think the name destructDo: comes from destructuring assignment.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

Norbert

Am 28.03.2020 um 14:15 schrieb Mark Plas <mark.plas@mediagenix.tv mailto:mark.plas@mediagenix.tv >:

Hello Christian,

" I don’t really like the name,"

Maybe you could call it #tupleDo:?

            #(1 2 3) tupleDo: [:a :b :c | …]

Mark

Mark Plas

Software Engineer

T +32 2 467 34 30

mailto:mark.plas@mediagenix.tv mark.plas@mediagenix.tv

<logomgxnew_3d44337b-2535-4d6a-9f5f-3fdd565513ca.png>

https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429 Nieuwe Gentsesteenweg 21/1

https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429 1702 Groot-Bijgaarden - Belgium

https://nl.linkedin.com/company/mediagenix-ng <linkedin_75b9c4f1-6a2b-497c-aab8-df56fe16b8e3.png>  https://twitter.com/mediagenix_tv <twitter_de4c3300-c6ab-4898-a962-b33ff662a322.png> https://www.facebook.com/MEDIAGENIX/ <Facebook-icon_6bef7545-f54e-4548-bfc4-1f07407f2642.png> http://www.mediagenix.tv/ www.mediagenix.tv

http://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf Directions to MEDIAGENIX

This e-mail and any files attached to it are confidential and intended only for the use of the individuals or entity to whom they are addressed. If you have received this e-mail in error, please notify the sender immediately.

From: Esug-list < mailto:esug-list-bounces@lists.esug.org esug-list-bounces@lists.esug.org> On Behalf Of Christian Haider
Sent: zaterdag 28 maart 2020 13:43
To:  mailto:vwnc@cs.uiuc.edu vwnc@cs.uiuc.edumailto:esug-list@lists.esug.org esug-list@lists.esug.orgmailto:amber-lang@googlegroups.com amber-lang@googlegroups.com
Subject: [Esug-list] destructDo:

Hi,

I am using a nice little method #destructDo: for a while now and it feels good.

In VisualWorks:

SequenceableCollection>>destructDo: aBlock

                            "Evaluate aBlock with the receiver's elements as parameters.

                            aBlock takes its arguments from the receiver.

                            'ok'

                            #(1 2 3) destructDo: [:a :b :c | a + b + c]

                            #(1 2 3) destructDo: [:a :b | a + b]

                            #(1 2 3) destructDo: [:a | a]

                            #(1 2 3) destructDo: [42]

                            'not ok'

                            #(1 2 3) destructDo: [:a :b :c :d | a + b + c + d]

                            "

                            ^aBlock cullWithArguments: self asArray

In Amber:

SequenceableCollection>>destructDo: aBlock

                            ^aBlock valueWithPossibleArguments: self

In Pharo and other dialects, I don’t know, but should be as easy.

For example you can do

            (('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day |

                           Date newDay: day monthNumber: month year: year]

I like that the block is not the receiver (like with #valueWithArguments or #cullWithArguments), but the last argument.

Now the questions:

  • I am sure that others came up with this. Anybody knows?
  • What are you using for this pattern?
  • I don’t really like the name, but haven’t found anything better yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:… maybe something shorter? Ideas?
  • What are you thinking about this?

Happy hacking,

            Christian

Esug-list mailing list
mailto:Esug-list@lists.esug.org Esug-list@lists.esug.org
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org

I chose the name because of the old Lisp “destructuring-bind”. But this is more powerful, because it does tree matching. This is just shallow. I am not sure where the concept was invented first. It may have been Lisp. Von: Norbert Hartl <norbert@hartl.name> Gesendet: Samstag, 28. März 2020 14:20 An: Mark Plas <mark.plas@mediagenix.tv> Cc: Christian Haider <christian.haider@smalltalked-visuals.com>; vwnc@cs.uiuc.edu; esug-list@lists.esug.org; amber-lang@googlegroups.com Betreff: Re: [Esug-list] destructDo: I think the name destructDo: comes from destructuring assignment. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment Norbert Am 28.03.2020 um 14:15 schrieb Mark Plas <mark.plas@mediagenix.tv <mailto:mark.plas@mediagenix.tv> >: Hello Christian, " I don’t really like the name," Maybe you could call it #tupleDo:? #(1 2 3) tupleDo: [:a :b :c | …] Mark Mark Plas Software Engineer T +32 2 467 34 30 <mailto:mark.plas@mediagenix.tv> mark.plas@mediagenix.tv <logomgxnew_3d44337b-2535-4d6a-9f5f-3fdd565513ca.png> <https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> Nieuwe Gentsesteenweg 21/1 <https://www.google.com/maps/dir/?api=1&destination=50.872900,4.286429> 1702 Groot-Bijgaarden - Belgium <https://nl.linkedin.com/company/mediagenix-ng> <linkedin_75b9c4f1-6a2b-497c-aab8-df56fe16b8e3.png> <https://twitter.com/mediagenix_tv> <twitter_de4c3300-c6ab-4898-a962-b33ff662a322.png> <https://www.facebook.com/MEDIAGENIX/> <Facebook-icon_6bef7545-f54e-4548-bfc4-1f07407f2642.png> <http://www.mediagenix.tv/> www.mediagenix.tv <http://www.mediagenix.tv/wp-content/uploads/2017/08/Directions.pdf> Directions to MEDIAGENIX This e-mail and any files attached to it are confidential and intended only for the use of the individuals or entity to whom they are addressed. If you have received this e-mail in error, please notify the sender immediately. From: Esug-list < <mailto:esug-list-bounces@lists.esug.org> esug-list-bounces@lists.esug.org> On Behalf Of Christian Haider Sent: zaterdag 28 maart 2020 13:43 To: <mailto:vwnc@cs.uiuc.edu> vwnc@cs.uiuc.edu; <mailto:esug-list@lists.esug.org> esug-list@lists.esug.org; <mailto:amber-lang@googlegroups.com> amber-lang@googlegroups.com Subject: [Esug-list] destructDo: Hi, I am using a nice little method #destructDo: for a while now and it feels good. In VisualWorks: SequenceableCollection>>destructDo: aBlock "Evaluate aBlock with the receiver's elements as parameters. aBlock takes its arguments from the receiver. 'ok' #(1 2 3) destructDo: [:a :b :c | a + b + c] #(1 2 3) destructDo: [:a :b | a + b] #(1 2 3) destructDo: [:a | a] #(1 2 3) destructDo: [42] 'not ok' #(1 2 3) destructDo: [:a :b :c :d | a + b + c + d] " ^aBlock cullWithArguments: self asArray In Amber: SequenceableCollection>>destructDo: aBlock ^aBlock valueWithPossibleArguments: self In Pharo and other dialects, I don’t know, but should be as easy. For example you can do (('2020-03-28' tokensBasedOn: $-) collect: #asNumber) destructDo: [:year :month :day | Date newDay: day monthNumber: month year: year] I like that the block is not the receiver (like with #valueWithArguments or #cullWithArguments), but the last argument. Now the questions: * I am sure that others came up with this. Anybody knows? * What are you using for this pattern? * I don’t really like the name, but haven’t found anything better yet. Maybe #destructedDo: or just #destructed: or: #withPartsDo:… maybe something shorter? Ideas? * What are you thinking about this? Happy hacking, Christian _______________________________________________ Esug-list mailing list <mailto:Esug-list@lists.esug.org> Esug-list@lists.esug.org <http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org