* [ruby-core:49267] [ruby-trunk - Feature #7340][Open] 'each_with' or 'into' alias for 'each_with_object'
@ 2012-11-12 23:17 nathan.f77 (Nathan Broadbent)
2012-11-13 2:06 ` [ruby-core:49277] [ruby-trunk - Feature #7340] " matz (Yukihiro Matsumoto)
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: nathan.f77 (Nathan Broadbent) @ 2012-11-12 23:17 UTC (permalink / raw
To: ruby-core
Issue #7340 has been reported by nathan.f77 (Nathan Broadbent).
----------------------------------------
Feature #7340: 'each_with' or 'into' alias for 'each_with_object'
https://bugs.ruby-lang.org/issues/7340
Author: nathan.f77 (Nathan Broadbent)
Status: Open
Priority: Low
Assignee:
Category: lib
Target version: next minor
Following on from the discussions at #7297 and #7241, it is apparent that a shorter alias for 'each_with_object' would be much appreciated.
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ruby-core:49277] [ruby-trunk - Feature #7340] 'each_with' or 'into' alias for 'each_with_object'
2012-11-12 23:17 [ruby-core:49267] [ruby-trunk - Feature #7340][Open] 'each_with' or 'into' alias for 'each_with_object' nathan.f77 (Nathan Broadbent)
@ 2012-11-13 2:06 ` matz (Yukihiro Matsumoto)
2012-11-13 2:24 ` [ruby-core:49280] " merborne (kyo endo)
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: matz (Yukihiro Matsumoto) @ 2012-11-13 2:06 UTC (permalink / raw
To: ruby-core
Issue #7340 has been updated by matz (Yukihiro Matsumoto).
I dislike #into because it may or may not put something into the argument.
I am OK with #each_with.
Matz.
----------------------------------------
Feature #7340: 'each_with' or 'into' alias for 'each_with_object'
https://bugs.ruby-lang.org/issues/7340#change-32832
Author: nathan.f77 (Nathan Broadbent)
Status: Open
Priority: Low
Assignee:
Category: lib
Target version: next minor
Following on from the discussions at #7297 and #7241, it is apparent that a shorter alias for 'each_with_object' would be much appreciated.
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ruby-core:49280] [ruby-trunk - Feature #7340] 'each_with' or 'into' alias for 'each_with_object'
2012-11-12 23:17 [ruby-core:49267] [ruby-trunk - Feature #7340][Open] 'each_with' or 'into' alias for 'each_with_object' nathan.f77 (Nathan Broadbent)
2012-11-13 2:06 ` [ruby-core:49277] [ruby-trunk - Feature #7340] " matz (Yukihiro Matsumoto)
@ 2012-11-13 2:24 ` merborne (kyo endo)
2012-11-13 11:25 ` [ruby-core:49295] " rosenfeld (Rodrigo Rosenfeld Rosas)
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: merborne (kyo endo) @ 2012-11-13 2:24 UTC (permalink / raw
To: ruby-core
Issue #7340 has been updated by merborne (kyo endo).
matz (Yukihiro Matsumoto) wrote:
> I dislike #into because it may or may not put something into the argument.
> I am OK with #each_with.
>
> Matz.
I would appreciate if you could look at #6687. but #each_with is OK for me :-)
----------------------------------------
Feature #7340: 'each_with' or 'into' alias for 'each_with_object'
https://bugs.ruby-lang.org/issues/7340#change-32835
Author: nathan.f77 (Nathan Broadbent)
Status: Open
Priority: Low
Assignee:
Category: lib
Target version: next minor
Following on from the discussions at #7297 and #7241, it is apparent that a shorter alias for 'each_with_object' would be much appreciated.
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ruby-core:49295] [ruby-trunk - Feature #7340] 'each_with' or 'into' alias for 'each_with_object'
2012-11-12 23:17 [ruby-core:49267] [ruby-trunk - Feature #7340][Open] 'each_with' or 'into' alias for 'each_with_object' nathan.f77 (Nathan Broadbent)
2012-11-13 2:06 ` [ruby-core:49277] [ruby-trunk - Feature #7340] " matz (Yukihiro Matsumoto)
2012-11-13 2:24 ` [ruby-core:49280] " merborne (kyo endo)
@ 2012-11-13 11:25 ` rosenfeld (Rodrigo Rosenfeld Rosas)
2012-11-13 11:37 ` [ruby-core:49297] " Matthew Kerwin
2014-05-10 15:21 ` [ruby-core:62507] " akr
` (2 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: rosenfeld (Rodrigo Rosenfeld Rosas) @ 2012-11-13 11:25 UTC (permalink / raw
To: ruby-core
Issue #7340 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas).
The reason I dislike each_with_object and each_with is the "each" on them. "each"'s return value isn't meaningful to me. That's why I would prefer "map_to", "map_into" or just "into".
"into" here doesn't mean putting values "into" the array or hash. It means: "turn/map object into a hash/array/whatever". It is not about putting something into the passed object, but about converting the original object (say numbers) into the object being passed as the initial value like a hash or an array.
It is ok to chain operations as a pattern (like the one used by jQuery) so that an_array.each{...}.sort would justify "each" returning the original "an_array", but only to be able to chain operations and not because "each" implies returning anything meaningful.
In that sense, each_with_object is currently supposed to return some meaningful value. That is why I'd prefer to call it "map_to", "map_into" or just "into".
numbers.map_into({}){...} should read "map numbers into a hash where ...". It would be even shorter if we just abbreviated "map_into" as just "into".
Also, if there is any chance that this wouldn't be an alias to each_with_object, I'd prefer the block's arguments order to be inverted to be symmetric to "inject".
----------------------------------------
Feature #7340: 'each_with' or 'into' alias for 'each_with_object'
https://bugs.ruby-lang.org/issues/7340#change-32853
Author: nathan.f77 (Nathan Broadbent)
Status: Open
Priority: Low
Assignee:
Category: lib
Target version: next minor
Following on from the discussions at #7297 and #7241, it is apparent that a shorter alias for 'each_with_object' would be much appreciated.
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ruby-core:49297] Re: [ruby-trunk - Feature #7340] 'each_with' or 'into' alias for 'each_with_object'
2012-11-13 11:25 ` [ruby-core:49295] " rosenfeld (Rodrigo Rosenfeld Rosas)
@ 2012-11-13 11:37 ` Matthew Kerwin
0 siblings, 0 replies; 8+ messages in thread
From: Matthew Kerwin @ 2012-11-13 11:37 UTC (permalink / raw
To: ruby-core
[-- Attachment #1: Type: text/plain, Size: 2113 bytes --]
On 13 November 2012 21:25, rosenfeld (Rodrigo Rosenfeld Rosas) <
rr.rosas@gmail.com> wrote:
>
> Issue #7340 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas).
>
>
> The reason I dislike each_with_object and each_with is the "each" on them.
> "each"'s return value isn't meaningful to me. That's why I would prefer
> "map_to", "map_into" or just "into".
>
> "into" here doesn't mean putting values "into" the array or hash. It
> means: "turn/map object into a hash/array/whatever". It is not about
> putting something into the passed object, but about converting the original
> object (say numbers) into the object being passed as the initial value like
> a hash or an array.
>
> It is ok to chain operations as a pattern (like the one used by jQuery) so
> that an_array.each{...}.sort would justify "each" returning the original
> "an_array", but only to be able to chain operations and not because "each"
> implies returning anything meaningful.
>
> In that sense, each_with_object is currently supposed to return some
> meaningful value. That is why I'd prefer to call it "map_to", "map_into" or
> just "into".
>
> numbers.map_into({}){...} should read "map numbers into a hash where ...".
> It would be even shorter if we just abbreviated "map_into" as just "into".
>
> Also, if there is any chance that this wouldn't be an alias to
> each_with_object, I'd prefer the block's arguments order to be inverted to
> be symmetric to "inject".
I believe, given that explanation, that #map_to is a far more appropriate
name than #map_into . . . and suddenly the reservations I had about this
alias start to fade away.
There is a clear semantic distinction between #each_with, where the focus
is on the action performed in the block, and #map_to, where the focus is on
the object returned from the block. So the question is: is this
alias/method meant to be an analogue for #each, or for #map ?
--
Matthew Kerwin, B.Sc (CompSci) (Hons)
http://matthew.kerwin.net.au/
ABN: 59-013-727-651
"You'll never find a programming language that frees
you from the burden of clarifying your ideas." - xkcd
[-- Attachment #2: Type: text/html, Size: 2815 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ruby-core:62507] [ruby-trunk - Feature #7340] 'each_with' or 'into' alias for 'each_with_object'
2012-11-12 23:17 [ruby-core:49267] [ruby-trunk - Feature #7340][Open] 'each_with' or 'into' alias for 'each_with_object' nathan.f77 (Nathan Broadbent)
` (2 preceding siblings ...)
2012-11-13 11:25 ` [ruby-core:49295] " rosenfeld (Rodrigo Rosenfeld Rosas)
@ 2014-05-10 15:21 ` akr
2014-05-10 15:22 ` [ruby-core:62509] " akr
2014-05-10 15:23 ` [ruby-core:62512] " akr
5 siblings, 0 replies; 8+ messages in thread
From: akr @ 2014-05-10 15:21 UTC (permalink / raw
To: ruby-core
Issue #7340 has been updated by Akira Tanaka.
Related to Feature #7384: Rename #each_with_object to #each_with added
----------------------------------------
Feature #7340: 'each_with' or 'into' alias for 'each_with_object'
https://bugs.ruby-lang.org/issues/7340#change-46668
* Author: Nathan Broadbent
* Status: Open
* Priority: Low
* Assignee:
* Category: lib
* Target version: next minor
----------------------------------------
Following on from the discussions at #7297 and #7241, it is apparent that a shorter alias for 'each_with_object' would be much appreciated.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ruby-core:62509] [ruby-trunk - Feature #7340] 'each_with' or 'into' alias for 'each_with_object'
2012-11-12 23:17 [ruby-core:49267] [ruby-trunk - Feature #7340][Open] 'each_with' or 'into' alias for 'each_with_object' nathan.f77 (Nathan Broadbent)
` (3 preceding siblings ...)
2014-05-10 15:21 ` [ruby-core:62507] " akr
@ 2014-05-10 15:22 ` akr
2014-05-10 15:23 ` [ruby-core:62512] " akr
5 siblings, 0 replies; 8+ messages in thread
From: akr @ 2014-05-10 15:22 UTC (permalink / raw
To: ruby-core
Issue #7340 has been updated by Akira Tanaka.
Related to Feature #7297: map_to alias for each_with_object added
----------------------------------------
Feature #7340: 'each_with' or 'into' alias for 'each_with_object'
https://bugs.ruby-lang.org/issues/7340#change-46670
* Author: Nathan Broadbent
* Status: Open
* Priority: Low
* Assignee:
* Category: lib
* Target version: next minor
----------------------------------------
Following on from the discussions at #7297 and #7241, it is apparent that a shorter alias for 'each_with_object' would be much appreciated.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ruby-core:62512] [ruby-trunk - Feature #7340] 'each_with' or 'into' alias for 'each_with_object'
2012-11-12 23:17 [ruby-core:49267] [ruby-trunk - Feature #7340][Open] 'each_with' or 'into' alias for 'each_with_object' nathan.f77 (Nathan Broadbent)
` (4 preceding siblings ...)
2014-05-10 15:22 ` [ruby-core:62509] " akr
@ 2014-05-10 15:23 ` akr
5 siblings, 0 replies; 8+ messages in thread
From: akr @ 2014-05-10 15:23 UTC (permalink / raw
To: ruby-core
Issue #7340 has been updated by Akira Tanaka.
Related to Feature #6687: Enumerable#with added
----------------------------------------
Feature #7340: 'each_with' or 'into' alias for 'each_with_object'
https://bugs.ruby-lang.org/issues/7340#change-46672
* Author: Nathan Broadbent
* Status: Open
* Priority: Low
* Assignee:
* Category: lib
* Target version: next minor
----------------------------------------
Following on from the discussions at #7297 and #7241, it is apparent that a shorter alias for 'each_with_object' would be much appreciated.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-05-10 15:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-12 23:17 [ruby-core:49267] [ruby-trunk - Feature #7340][Open] 'each_with' or 'into' alias for 'each_with_object' nathan.f77 (Nathan Broadbent)
2012-11-13 2:06 ` [ruby-core:49277] [ruby-trunk - Feature #7340] " matz (Yukihiro Matsumoto)
2012-11-13 2:24 ` [ruby-core:49280] " merborne (kyo endo)
2012-11-13 11:25 ` [ruby-core:49295] " rosenfeld (Rodrigo Rosenfeld Rosas)
2012-11-13 11:37 ` [ruby-core:49297] " Matthew Kerwin
2014-05-10 15:21 ` [ruby-core:62507] " akr
2014-05-10 15:22 ` [ruby-core:62509] " akr
2014-05-10 15:23 ` [ruby-core:62512] " akr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).