Esug-list
By thread
esug-list@lists.esug.org
By month
Messages by month
- ----- 2026 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
March 2020
- 27 participants
- 51 messages
Re: [Esug-list] destructDo:
by Bernhard Pieber
Hi Christian,
Thank you for the example. I like it (except for the need of ignore maybe).
So #bind: from Pharo 8 would not work in that case, right?
I see three possible semantics:
1. block arguments size must match receiver collection's size: like Pharo 8's #bind or PetitParsers's #map::
2. arguments size must be equal or less than receiver collection's size: like #destructDo:
3. Like 2 but with using rest of collection (like in Nobert's JavaScript example): could be #destructDo:rest:
Bernhard
> Am 28.03.2020 um 19:20 schrieb Christian Haider <christian.haider(a)smalltalked-visuals.com>:
>
>
> Hi Bernhard,
>
> yes, it is very handy for csv tables. I deal a lot with them lately (budgets, CoViD19).
> I read a line, separate the fields and use that list for #destructDo: .
> Now I can just pick the first n columns I am interested in.
> (Mostly, identifying information is in the first columns.)
>
> Real world example:
> ^stringsOfLine destructDo: [:ignore :string2 :string3 :string4 |
> self produktbereich: string2 profitcenter: string3 bezeichnung: string4]
>
> I think that the code becomes much more readable.
> Except the name ... :-)
>
> Stay healthy,
> Christian
>
> -----Ursprüngliche Nachricht-----
> Von: Bernhard Pieber <bernhard(a)pieber.com>
> Gesendet: Samstag, 28. März 2020 18:53
> An: Martin McClure <martin.mcclure(a)gemtalksystems.com>
> Cc: Christian Haider <christian.haider(a)smalltalked-visuals.com>; Christophe Dony <dony(a)lirmm.fr>; esug-list(a)lists.esug.org
> Betreff: Re: [Esug-list] destructDo:
>
> Hi everyone,
>
> I find Martin's arguments regarding "destruct" and "do" rather convincing. Which brings me to:
>
> #(1 2 3) destructured: [:a :b :c | a + b + c]
>
> Christian, have you ever used this method in a case in which the number of block arguments was smaller than the receiver collection's size?
>
> Bernhard
>
>> Am 28.03.2020 um 16:13 schrieb Martin McClure <martin.mcclure(a)gemtalksystems.com>:
>>
>> Hi Christian and all,
>>
>> #destructDo: is probably not the best name. "Destruct" can be interpreted as either short for "destructured" (which is what you want) or more like "destroy" as in "self-destruct." I initially took "destruct" in the "destroy" sense and guessed that #destructDo: might remove each element from the collection as it iterated. You could lengthen it to #destructured: or #destructuredDo:, but if there's a good short name that would be better.
>>
>> #tupleDo: feels better.
>>
>> But both #tupleDo: and #destructDo: contain "do" which implies
>> iteration. Unless I'm missing something, your #destructDo: does not
>> iterate. I'd really expect a #tupleDo: to iterate -- I'd expect with
>>
>> #(1 2 3 4) tupleDo: [:a :b: | a + b]
>>
>> that the block would be evaluated twice, once with 1 and 2 and once with 3 and 4. This would be a nice pattern; you could also have a tupleCollect: a tupleDetect: and so on.
>>
>> #mapTo: is quite similar to #map: in PetitParser, except IIRC PetitParser's #map: expects an exact match in argument count. But maybe #map: is a good name for consistency.
>>
>> Hope this helps.
>>
>> Regards,
>> -Martin
>>
>> On 3/28/20 7:24 AM, Christian Haider wrote:
>>> Yes, that would be nice. Unfortunately a bit more involved than this
>>> 1-liner…
>>>
>>> Von: Esug-list <esug-list-bounces(a)lists.esug.org> Im Auftrag von
>>> Christophe Dony
>>> Gesendet: Samstag, 28. März 2020 15:17
>>> An: esug-list(a)lists.esug.org
>>> Betreff: Re: [Esug-list] destructDo:
>>>
>>> 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(a)mediagenix.tv
>>>
>>>
>>>
>>> <image001.png>
>>>
>>>
>>> Nieuwe Gentsesteenweg 21/1
>>>
>>> 1702 Groot-Bijgaarden - Belgium
>>>
>>>
>>> <image002.png> <image003.png><image004.png>www.mediagenix.tv
>>>
>>>
>>> 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 <esug-list-bounces(a)lists.esug.org> On Behalf Of
>>> Christian Haider
>>> Sent: zaterdag 28 maart 2020 13:43
>>> To: vwnc(a)cs.uiuc.edu; esug-list(a)lists.esug.org;
>>> amber-lang(a)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(a)lists.esug.org
>>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Esug-list mailing list
>>>
>>> Esug-list(a)lists.esug.org
>>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
>
>
March 28, 2020
Re: [Esug-list] destructDo:
by Pape, Tobias
> On 28.03.2020, at 19:20, Christian Haider <christian.haider(a)smalltalked-visuals.com> wrote:
>
> Hi Bernhard,
>
> yes, it is very handy for csv tables. I deal a lot with them lately (budgets, CoViD19).
> I read a line, separate the fields and use that list for #destructDo: .
> Now I can just pick the first n columns I am interested in.
> (Mostly, identifying information is in the first columns.)
>
> Real world example:
> ^stringsOfLine destructDo: [:ignore :string2 :string3 :string4 |
> self produktbereich: string2 profitcenter: string3 bezeichnung: string4]
>
> I think that the code becomes much more readable.
What about
^stringsOfLine asComponentsIn: [:ignore :string2 :string3 :string4 |
self produktbereich: string2 profitcenter: string3 bezeichnung: string4]
?
Best regards
-Tobias
> Except the name ... :-)
>
> Stay healthy,
> Christian
>
> -----Ursprüngliche Nachricht-----
> Von: Bernhard Pieber <bernhard(a)pieber.com>
> Gesendet: Samstag, 28. März 2020 18:53
> An: Martin McClure <martin.mcclure(a)gemtalksystems.com>
> Cc: Christian Haider <christian.haider(a)smalltalked-visuals.com>; Christophe Dony <dony(a)lirmm.fr>; esug-list(a)lists.esug.org
> Betreff: Re: [Esug-list] destructDo:
>
> Hi everyone,
>
> I find Martin's arguments regarding "destruct" and "do" rather convincing. Which brings me to:
>
> #(1 2 3) destructured: [:a :b :c | a + b + c]
>
> Christian, have you ever used this method in a case in which the number of block arguments was smaller than the receiver collection's size?
>
> Bernhard
>
>> Am 28.03.2020 um 16:13 schrieb Martin McClure <martin.mcclure(a)gemtalksystems.com>:
>>
>> Hi Christian and all,
>>
>> #destructDo: is probably not the best name. "Destruct" can be interpreted as either short for "destructured" (which is what you want) or more like "destroy" as in "self-destruct." I initially took "destruct" in the "destroy" sense and guessed that #destructDo: might remove each element from the collection as it iterated. You could lengthen it to #destructured: or #destructuredDo:, but if there's a good short name that would be better.
>>
>> #tupleDo: feels better.
>>
>> But both #tupleDo: and #destructDo: contain "do" which implies
>> iteration. Unless I'm missing something, your #destructDo: does not
>> iterate. I'd really expect a #tupleDo: to iterate -- I'd expect with
>>
>> #(1 2 3 4) tupleDo: [:a :b: | a + b]
>>
>> that the block would be evaluated twice, once with 1 and 2 and once with 3 and 4. This would be a nice pattern; you could also have a tupleCollect: a tupleDetect: and so on.
>>
>> #mapTo: is quite similar to #map: in PetitParser, except IIRC PetitParser's #map: expects an exact match in argument count. But maybe #map: is a good name for consistency.
>>
>> Hope this helps.
>>
>> Regards,
>> -Martin
>>
>> On 3/28/20 7:24 AM, Christian Haider wrote:
>>> Yes, that would be nice. Unfortunately a bit more involved than this
>>> 1-liner…
>>>
>>> Von: Esug-list <esug-list-bounces(a)lists.esug.org> Im Auftrag von
>>> Christophe Dony
>>> Gesendet: Samstag, 28. März 2020 15:17
>>> An: esug-list(a)lists.esug.org
>>> Betreff: Re: [Esug-list] destructDo:
>>>
>>> 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(a)mediagenix.tv
>>>
>>>
>>>
>>> <image001.png>
>>>
>>>
>>> Nieuwe Gentsesteenweg 21/1
>>>
>>> 1702 Groot-Bijgaarden - Belgium
>>>
>>>
>>> <image002.png> <image003.png><image004.png>www.mediagenix.tv
>>>
>>>
>>> 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 <esug-list-bounces(a)lists.esug.org> On Behalf Of
>>> Christian Haider
>>> Sent: zaterdag 28 maart 2020 13:43
>>> To: vwnc(a)cs.uiuc.edu; esug-list(a)lists.esug.org;
>>> amber-lang(a)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(a)lists.esug.org
>>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Esug-list mailing list
>>>
>>> Esug-list(a)lists.esug.org
>>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
>
>
>
> _______________________________________________
> Esug-list mailing list
> Esug-list(a)lists.esug.org
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
--
Tobias Pape
Software Architecture Group | http://www.hpi.uni-potsdam.de/swa/
Future SOC Lab | https://hpi.de/future-soc-lab
Hasso-Plattner-Institut für Digital Engineering gGmbH | Universität Potsdam
Prof.-Dr.-Helmert-Str. 2-3, D-14482 Potsdam, Germany
Amtsgericht Potsdam, HRB 12184 | Geschäftsführung: Prof. Dr. Christoph Meinel
March 28, 2020
Re: [Esug-list] destructDo:
by Christian Haider
Hi Bernhard,
yes, it is very handy for csv tables. I deal a lot with them lately (budgets, CoViD19).
I read a line, separate the fields and use that list for #destructDo: .
Now I can just pick the first n columns I am interested in.
(Mostly, identifying information is in the first columns.)
Real world example:
^stringsOfLine destructDo: [:ignore :string2 :string3 :string4 |
self produktbereich: string2 profitcenter: string3 bezeichnung: string4]
I think that the code becomes much more readable.
Except the name ... :-)
Stay healthy,
Christian
-----Ursprüngliche Nachricht-----
Von: Bernhard Pieber <bernhard(a)pieber.com>
Gesendet: Samstag, 28. März 2020 18:53
An: Martin McClure <martin.mcclure(a)gemtalksystems.com>
Cc: Christian Haider <christian.haider(a)smalltalked-visuals.com>; Christophe Dony <dony(a)lirmm.fr>; esug-list(a)lists.esug.org
Betreff: Re: [Esug-list] destructDo:
Hi everyone,
I find Martin's arguments regarding "destruct" and "do" rather convincing. Which brings me to:
#(1 2 3) destructured: [:a :b :c | a + b + c]
Christian, have you ever used this method in a case in which the number of block arguments was smaller than the receiver collection's size?
Bernhard
> Am 28.03.2020 um 16:13 schrieb Martin McClure <martin.mcclure(a)gemtalksystems.com>:
>
> Hi Christian and all,
>
> #destructDo: is probably not the best name. "Destruct" can be interpreted as either short for "destructured" (which is what you want) or more like "destroy" as in "self-destruct." I initially took "destruct" in the "destroy" sense and guessed that #destructDo: might remove each element from the collection as it iterated. You could lengthen it to #destructured: or #destructuredDo:, but if there's a good short name that would be better.
>
> #tupleDo: feels better.
>
> But both #tupleDo: and #destructDo: contain "do" which implies
> iteration. Unless I'm missing something, your #destructDo: does not
> iterate. I'd really expect a #tupleDo: to iterate -- I'd expect with
>
> #(1 2 3 4) tupleDo: [:a :b: | a + b]
>
> that the block would be evaluated twice, once with 1 and 2 and once with 3 and 4. This would be a nice pattern; you could also have a tupleCollect: a tupleDetect: and so on.
>
> #mapTo: is quite similar to #map: in PetitParser, except IIRC PetitParser's #map: expects an exact match in argument count. But maybe #map: is a good name for consistency.
>
> Hope this helps.
>
> Regards,
> -Martin
>
> On 3/28/20 7:24 AM, Christian Haider wrote:
>> Yes, that would be nice. Unfortunately a bit more involved than this
>> 1-liner…
>>
>> Von: Esug-list <esug-list-bounces(a)lists.esug.org> Im Auftrag von
>> Christophe Dony
>> Gesendet: Samstag, 28. März 2020 15:17
>> An: esug-list(a)lists.esug.org
>> Betreff: Re: [Esug-list] destructDo:
>>
>> 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(a)mediagenix.tv
>>
>>
>>
>> <image001.png>
>>
>>
>> Nieuwe Gentsesteenweg 21/1
>>
>> 1702 Groot-Bijgaarden - Belgium
>>
>>
>> <image002.png> <image003.png><image004.png>www.mediagenix.tv
>>
>>
>> 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 <esug-list-bounces(a)lists.esug.org> On Behalf Of
>> Christian Haider
>> Sent: zaterdag 28 maart 2020 13:43
>> To: vwnc(a)cs.uiuc.edu; esug-list(a)lists.esug.org;
>> amber-lang(a)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(a)lists.esug.org
>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>>
>>
>>
>>
>> _______________________________________________
>> Esug-list mailing list
>>
>> Esug-list(a)lists.esug.org
>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
March 28, 2020
Re: [Esug-list] destructDo:
by Bernhard Pieber
Hi everyone,
I find Martin's arguments regarding "destruct" and "do" rather convincing. Which brings me to:
#(1 2 3) destructured: [:a :b :c | a + b + c]
Christian, have you ever used this method in a case in which the number of block arguments was smaller than the receiver collection's size?
Bernhard
> Am 28.03.2020 um 16:13 schrieb Martin McClure <martin.mcclure(a)gemtalksystems.com>:
>
> Hi Christian and all,
>
> #destructDo: is probably not the best name. "Destruct" can be interpreted as either short for "destructured" (which is what you want) or more like "destroy" as in "self-destruct." I initially took "destruct" in the "destroy" sense and guessed that #destructDo: might remove each element from the collection as it iterated. You could lengthen it to #destructured: or #destructuredDo:, but if there's a good short name that would be better.
>
> #tupleDo: feels better.
>
> But both #tupleDo: and #destructDo: contain "do" which implies iteration. Unless I'm missing something, your #destructDo: does not iterate. I'd really expect a #tupleDo: to iterate -- I'd expect with
>
> #(1 2 3 4) tupleDo: [:a :b: | a + b]
>
> that the block would be evaluated twice, once with 1 and 2 and once with 3 and 4. This would be a nice pattern; you could also have a tupleCollect: a tupleDetect: and so on.
>
> #mapTo: is quite similar to #map: in PetitParser, except IIRC PetitParser's #map: expects an exact match in argument count. But maybe #map: is a good name for consistency.
>
> Hope this helps.
>
> Regards,
> -Martin
>
> On 3/28/20 7:24 AM, Christian Haider wrote:
>> Yes, that would be nice. Unfortunately a bit more involved than this 1-liner…
>>
>> Von: Esug-list <esug-list-bounces(a)lists.esug.org> Im Auftrag von Christophe Dony
>> Gesendet: Samstag, 28. März 2020 15:17
>> An: esug-list(a)lists.esug.org
>> Betreff: Re: [Esug-list] destructDo:
>>
>> 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(a)mediagenix.tv
>>
>>
>>
>> <image001.png>
>>
>>
>> Nieuwe Gentsesteenweg 21/1
>>
>> 1702 Groot-Bijgaarden - Belgium
>>
>>
>> <image002.png> <image003.png><image004.png>www.mediagenix.tv
>>
>>
>> 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 <esug-list-bounces(a)lists.esug.org> On Behalf Of Christian Haider
>> Sent: zaterdag 28 maart 2020 13:43
>> To: vwnc(a)cs.uiuc.edu; esug-list(a)lists.esug.org; amber-lang(a)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(a)lists.esug.org
>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>>
>>
>>
>>
>> _______________________________________________
>> Esug-list mailing list
>>
>> Esug-list(a)lists.esug.org
>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
March 28, 2020
Re: [Esug-list] destructDo:
by Pape, Tobias
> On 28.03.2020, at 17:04, Fabio Niephaus <lists(a)fniephaus.com> wrote:
>
>
>
> On Sat, 28 Mar 2020 at 5:00 pm, Norm Green <norm.green(a)gemtalksystems.com> wrote:
> I agree with Martin. The default connotation of 'destruct' in English is to destroy. I would suggest either #destructuredDo: or #tuppleDo: to avoid confusion.
>
> I agree. How about this:
>
>> #(1 2 3 4) feedInto: [:a :b: | a + b]
>
Or `#(1 2 3 4) partsIn: [:a :b | a + b]`
Best regards
-Tobias
> Cheers,
> Fabio
>
>
>
> Norm
>
>
> On 3/28/2020 8:13 AM, Martin McClure wrote:
>> Hi Christian and all,
>>
>> #destructDo: is probably not the best name. "Destruct" can be interpreted as either short for "destructured" (which is what you want) or more like "destroy" as in "self-destruct." I initially took "destruct" in the "destroy" sense and guessed that #destructDo: might remove each element from the collection as it iterated. You could lengthen it to #destructured: or #destructuredDo:, but if there's a good short name that would be better.
>>
>> #tupleDo: feels better.
>>
>> But both #tupleDo: and #destructDo: contain "do" which implies iteration. Unless I'm missing something, your #destructDo: does not iterate. I'd really expect a #tupleDo: to iterate -- I'd expect with
>>
>> #(1 2 3 4) tupleDo: [:a :b: | a + b]
>>
>> that the block would be evaluated twice, once with 1 and 2 and once with 3 and 4. This would be a nice pattern; you could also have a tupleCollect: a tupleDetect: and so on.
>>
>> #mapTo: is quite similar to #map: in PetitParser, except IIRC PetitParser's #map: expects an exact match in argument count. But maybe #map: is a good name for consistency.
>>
>> Hope this helps.
>>
>> Regards,
>> -Martin
>>
>> On 3/28/20 7:24 AM, Christian Haider wrote:
>>> Yes, that would be nice. Unfortunately a bit more involved than this 1-liner…
>>>
>>>
>>>
>>> Von: Esug-list <esug-list-bounces(a)lists.esug.org> Im Auftrag von Christophe Dony
>>> Gesendet: Samstag, 28. März 2020 15:17
>>> An: esug-list(a)lists.esug.org
>>> Betreff: Re: [Esug-list] destructDo:
>>>
>>>
>>>
>>> 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(a)mediagenix.tv
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Nieuwe Gentsesteenweg 21/1
>>>
>>>
>>> 1702 Groot-Bijgaarden - Belgium
>>>
>>>
>>> www.mediagenix.tv
>>>
>>>
>>> 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 <esug-list-bounces(a)lists.esug.org> On Behalf Of Christian Haider
>>> Sent: zaterdag 28 maart 2020 13:43
>>> To: vwnc(a)cs.uiuc.edu; esug-list(a)lists.esug.org; amber-lang(a)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(a)lists.esug.org
>>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Esug-list mailing list
>>>
>>> Esug-list(a)lists.esug.org
>>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>>
>>
>>
>> _______________________________________________
>> Esug-list mailing list
>>
>> Esug-list(a)lists.esug.org
>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
> _______________________________________________
> Esug-list mailing list
> Esug-list(a)lists.esug.org
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
> _______________________________________________
> Esug-list mailing list
> Esug-list(a)lists.esug.org
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
--
Tobias Pape
Software Architecture Group | http://www.hpi.uni-potsdam.de/swa/
Future SOC Lab | https://hpi.de/future-soc-lab
Hasso-Plattner-Institut für Digital Engineering gGmbH | Universität Potsdam
Prof.-Dr.-Helmert-Str. 2-3, D-14482 Potsdam, Germany
Amtsgericht Potsdam, HRB 12184 | Geschäftsführung: Prof. Dr. Christoph Meinel
March 28, 2020
Re: [Esug-list] destructDo:
by Christian Haider
(somehow, I didn’t get Martins mail)
Yes, Martin, I agree with the misleading xDo: connotation. Thanks for your nice deconstruction of what I wanted :).
Cyril suggests #bind:, which does not feel fully right.
How about #boundTo: ? #(1 2 3) boundTo: [:a :b :c | …]
Happy hacking,
Christian
Von: Esug-list <esug-list-bounces(a)lists.esug.org> Im Auftrag von Fabio Niephaus
Gesendet: Samstag, 28. März 2020 17:04
An: esug-list(a)lists.esug.org
Betreff: Re: [Esug-list] destructDo:
On Sat, 28 Mar 2020 at 5:00 pm, Norm Green <norm.green(a)gemtalksystems.com <mailto:norm.green@gemtalksystems.com> > wrote:
I agree with Martin. The default connotation of 'destruct' in English is to destroy. I would suggest either #destructuredDo: or #tuppleDo: to avoid confusion.
I agree. How about this:
#(1 2 3 4) feedInto: [:a :b: | a + b]
Cheers,
Fabio
Norm
On 3/28/2020 8:13 AM, Martin McClure wrote:
Hi Christian and all,
#destructDo: is probably not the best name. "Destruct" can be interpreted as either short for "destructured" (which is what you want) or more like "destroy" as in "self-destruct." I initially took "destruct" in the "destroy" sense and guessed that #destructDo: might remove each element from the collection as it iterated. You could lengthen it to #destructured: or #destructuredDo:, but if there's a good short name that would be better.
#tupleDo: feels better.
But both #tupleDo: and #destructDo: contain "do" which implies iteration. Unless I'm missing something, your #destructDo: does not iterate. I'd really expect a #tupleDo: to iterate -- I'd expect with
#(1 2 3 4) tupleDo: [:a :b: | a + b]
that the block would be evaluated twice, once with 1 and 2 and once with 3 and 4. This would be a nice pattern; you could also have a tupleCollect: a tupleDetect: and so on.
#mapTo: is quite similar to #map: in PetitParser, except IIRC PetitParser's #map: expects an exact match in argument count. But maybe #map: is a good name for consistency.
Hope this helps.
Regards,
-Martin
On 3/28/20 7:24 AM, Christian Haider wrote:
Yes, that would be nice. Unfortunately a bit more involved than this 1-liner…
Von: Esug-list <mailto:esug-list-bounces@lists.esug.org> <esug-list-bounces(a)lists.esug.org> Im Auftrag von Christophe Dony
Gesendet: Samstag, 28. März 2020 15:17
An: esug-list(a)lists.esug.org <mailto:esug-list@lists.esug.org>
Betreff: Re: [Esug-list] destructDo:
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(a)mediagenix.tv <mailto:mark.plas@mediagenix.tv>
<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> <https://twitter.com/mediagenix_tv> <https://www.facebook.com/MEDIAGENIX/> <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(a)lists.esug.org> On Behalf Of Christian Haider
Sent: zaterdag 28 maart 2020 13:43
To: vwnc(a)cs.uiuc.edu <mailto:vwnc@cs.uiuc.edu> ; esug-list(a)lists.esug.org <mailto:esug-list@lists.esug.org> ; amber-lang(a)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(a)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(a)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(a)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(a)lists.esug.org <mailto:Esug-list@lists.esug.org>
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
March 28, 2020
Re: [Esug-list] destructDo:
by Christian Haider
Yes, exactly the same idea. Cool!
-----Ursprüngliche Nachricht-----
Von: Esug-list <esug-list-bounces(a)lists.esug.org> Im Auftrag von Cyril
Ferlicot D.
Gesendet: Samstag, 28. März 2020 17:02
An: esug-list(a)lists.esug.org
Betreff: Re: [Esug-list] destructDo:
Le 28/03/2020 à 13:42, Christian Haider a écrit :
> 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 dont 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 dont really like the name, but havent 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 Christian,
In Pharo 8 was introduced a #bind method that seems similar to what you do:
SequenceableCollection>>bind: aBlock
"Extract items from the receiver and use them as argumeents of
aBlock.
Signal an error
(ArgumentsCountMismatch) when the arguments count of aBlock does not
match the receiver size."
"(#(1 2 3) bind: [ :first :second :third | first + second + third ])
>>> 6"
^ aBlock valueWithArguments: self
The difference is that arguments are not optionals but I think it would be
cool to make them optional in this #bind: method.
>
>
> _______________________________________________
> Esug-list mailing list
> Esug-list(a)lists.esug.org
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
--
Cyril Ferlicot
https://ferlicot.fr
March 28, 2020
Re: [Esug-list] destructDo:
by Fabio Niephaus
On Sat, 28 Mar 2020 at 5:00 pm, Norm Green <norm.green(a)gemtalksystems.com>
wrote:
> I agree with Martin. The default connotation of 'destruct' in English is
> to destroy. I would suggest either #destructuredDo: or #tuppleDo: to avoid
> confusion.
>
I agree. How about this:
#(1 2 3 4) feedInto: [:a :b: | a + b]
Cheers,
Fabio
>
> Norm
>
>
> On 3/28/2020 8:13 AM, Martin McClure wrote:
>
> Hi Christian and all,
>
> #destructDo: is probably not the best name. "Destruct" can be interpreted
> as either short for "destructured" (which is what you want) or more like
> "destroy" as in "self-destruct." I initially took "destruct" in the
> "destroy" sense and guessed that #destructDo: might remove each element
> from the collection as it iterated. You could lengthen it to #destructured:
> or #destructuredDo:, but if there's a good short name that would be better.
>
> #tupleDo: feels better.
>
> But both #tupleDo: and #destructDo: contain "do" which implies iteration.
> Unless I'm missing something, your #destructDo: does not iterate. I'd
> really expect a #tupleDo: to iterate -- I'd expect with
>
> #(1 2 3 4) tupleDo: [:a :b: | a + b]
>
> that the block would be evaluated twice, once with 1 and 2 and once with 3
> and 4. This would be a nice pattern; you could also have a tupleCollect: a
> tupleDetect: and so on.
>
> #mapTo: is quite similar to #map: in PetitParser, except IIRC
> PetitParser's #map: expects an exact match in argument count. But maybe
> #map: is a good name for consistency.
>
> Hope this helps.
>
> Regards,
> -Martin
>
> On 3/28/20 7:24 AM, Christian Haider wrote:
>
> Yes, that would be nice. Unfortunately a bit more involved than this
> 1-liner…
>
>
>
> *Von:* Esug-list <esug-list-bounces(a)lists.esug.org>
> <esug-list-bounces(a)lists.esug.org> *Im Auftrag von *Christophe Dony
> *Gesendet:* Samstag, 28. März 2020 15:17
> *An:* esug-list(a)lists.esug.org
> *Betreff:* Re: [Esug-list] destructDo:
>
>
>
> 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(a)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
>
> 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(a)lists.esug.org>
> <esug-list-bounces(a)lists.esug.org> *On Behalf Of *Christian Haider
> *Sent:* zaterdag 28 maart 2020 13:43
> *To:* vwnc(a)cs.uiuc.edu; esug-list(a)lists.esug.org;
> amber-lang(a)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(a)lists.esug.org
>
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
>
>
> _______________________________________________
> Esug-list mailing listEsug-list@lists.esug.orghttp://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
>
>
> _______________________________________________
> Esug-list mailing listEsug-list@lists.esug.orghttp://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
>
> _______________________________________________
> Esug-list mailing list
> Esug-list(a)lists.esug.org
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
March 28, 2020
Re: [Esug-list] destructDo:
by Cyril Ferlicot D.
Le 28/03/2020 à 13:42, Christian Haider a écrit :
> 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 Christian,
In Pharo 8 was introduced a #bind method that seems similar to what you do:
SequenceableCollection>>bind: aBlock
"Extract items from the receiver and use them as argumeents of aBlock.
Signal an error
(ArgumentsCountMismatch) when the arguments count of aBlock does not
match the receiver size."
"(#(1 2 3) bind: [ :first :second :third | first + second + third ]) >>> 6"
^ aBlock valueWithArguments: self
The difference is that arguments are not optionals but I think it would
be cool to make them optional in this #bind: method.
>
>
> _______________________________________________
> Esug-list mailing list
> Esug-list(a)lists.esug.org
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
--
Cyril Ferlicot
https://ferlicot.fr
March 28, 2020
Re: [Esug-list] destructDo:
by Norm Green
I agree with Martin. The default connotation of 'destruct' in English is
to destroy. I would suggest either #destructuredDo: or #tuppleDo: to
avoid confusion.
Norm
On 3/28/2020 8:13 AM, Martin McClure wrote:
> Hi Christian and all,
>
> #destructDo: is probably not the best name. "Destruct" can be
> interpreted as either short for "destructured" (which is what you
> want) or more like "destroy" as in "self-destruct." I initially took
> "destruct" in the "destroy" sense and guessed that #destructDo: might
> remove each element from the collection as it iterated. You could
> lengthen it to #destructured: or #destructuredDo:, but if there's a
> good short name that would be better.
>
> #tupleDo: feels better.
>
> But both #tupleDo: and #destructDo: contain "do" which implies
> iteration. Unless I'm missing something, your #destructDo: does not
> iterate. I'd really expect a #tupleDo: to iterate -- I'd expect with
>
> #(1 2 3 4) tupleDo: [:a :b: | a + b]
>
> that the block would be evaluated twice, once with 1 and 2 and once
> with 3 and 4. This would be a nice pattern; you could also have a
> tupleCollect: a tupleDetect: and so on.
>
> #mapTo: is quite similar to #map: in PetitParser, except IIRC
> PetitParser's #map: expects an exact match in argument count. But
> maybe #map: is a good name for consistency.
>
> Hope this helps.
>
> Regards,
> -Martin
>
> On 3/28/20 7:24 AM, Christian Haider wrote:
>>
>> Yes, that would be nice. Unfortunately a bit more involved than this
>> 1-liner…
>>
>> *Von:*Esug-list <esug-list-bounces(a)lists.esug.org> *Im Auftrag von
>> *Christophe Dony
>> *Gesendet:* Samstag, 28. März 2020 15:17
>> *An:* esug-list(a)lists.esug.org
>> *Betreff:* Re: [Esug-list] destructDo:
>>
>> 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(a)mediagenix.tv <mailto: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(a)lists.esug.org>
>> <mailto:esug-list-bounces@lists.esug.org> *On Behalf Of
>> *Christian Haider
>> *Sent:* zaterdag 28 maart 2020 13:43
>> *To:* vwnc(a)cs.uiuc.edu <mailto:vwnc@cs.uiuc.edu>;
>> esug-list(a)lists.esug.org <mailto:esug-list@lists.esug.org>;
>> amber-lang(a)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(a)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(a)lists.esug.org
>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
>
> _______________________________________________
> Esug-list mailing list
> Esug-list(a)lists.esug.org
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
March 28, 2020