www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2928] New: Swap order of paramaters for std.range's "take"

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2928

           Summary: Swap order of paramaters for std.range's "take"
           Product: D
           Version: 2.029
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: cbkbbejeap mailinator.com


According to the docs, in std.range, "take" takes the range as its second
parameter and 'n' as the first parameter. This ordering should be swapped, 1.
to be consistent with stride, advance, retreatN, and cycle, and 2. to allow the
syntax "a.take(n)" like with advance.


-- 
May 03 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2928





------- Comment #1 from andrei metalanguage.com  2009-05-03 15:36 -------
Undecided. take is inspired from Haskell et al where the range comes last.


-- 
May 03 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2928





------- Comment #2 from jarrett.billingsley gmail.com  2009-05-03 15:48 -------
Keep in mind that Haskell's parameter ordering is based on partial application,
a feature that D obviously does not have.  


-- 
May 03 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2928





------- Comment #3 from andrei metalanguage.com  2009-05-03 16:06 -------
(In reply to comment #2)
 Keep in mind that Haskell's parameter ordering is based on partial application,
 a feature that D obviously does not have.  
 

Sort of does: import std.functional, std.range, std.stdio; void main() { auto a = [ 1, 2, 3 ][]; alias curry!(take, 2) take2; foreach (e; take2(a)) { writeln(e); } } But I agree there are good arguments in favor of swapping arguments. --
May 03 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2928


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 11 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2928


Lutger <lutger.blijdestijn gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lutger.blijdestijn gmail.co
                   |                            |m


--- Comment #4 from Lutger <lutger.blijdestijn gmail.com> 2009-12-08 06:18:52
PST ---
Please consider this also for replicate* and any other functions (though
replicate and take are the only ones I could find.)

Note that in haskell's prelude, there are many functions that also can be found
in phobos, such as splitAt and until, for which the same argument could be
made. Haskell does seem to be more consistent in argument ordering, always the
predicate first and then the list, this makes it easy to remember.  

It's a bit weird that when uniform function call syntax will be implemented,
this will work:

iota(0,10).stride(2).until(8)

but this won't work:

iota(0,10).stride(2).take(4)

I'd rather give up currying myself to make this work, even for the benefit of
consistency alone. 


* note that std.string.repeat is defined as string repeat(string s, size_t n);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 08 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2928


Kyle Foley <k-foley onu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |k-foley onu.edu


--- Comment #5 from Kyle Foley <k-foley onu.edu> 2010-01-22 16:58:03 PST ---
What is the status on this?  I would like to see it it changed to 

Take!(R) take(R)(R input, size_t n);
Take!(Repeat!(T)) replicate(T)(T value, size_t n);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 22 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2928



--- Comment #6 from Andrei Alexandrescu <andrei metalanguage.com> 2010-01-22
17:16:25 PST ---
I'll change that soon. Thanks!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 22 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2928


Kyle Foley <k-foley onu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


--- Comment #7 from Kyle Foley <k-foley onu.edu> 2010-05-01 16:00:42 PDT ---
Fixed in 2.041

http://digitalmars.com/d/2.0/changelog.html#new2_041

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 01 2010