'list*' returns not a list

Description

Function 'list*' returns sequence, but not a list.
It is a bit confusing.

Approach: Change the doc string to say that it returns a seq, not a list.

Patch: list-star-docstring.diff

Environment

None

Attachments

2

Activity

import July 3, 2015 at 2:34 AM

@AndyFingerhut - Thanks for the reminder. Signed, sealed, delivered.

Andy Fingerhut July 2, 2015 at 9:13 PM

To Andy Sheldon, author of patch list-star-docstring.diff: Clojure only accepts patches written by those who have signed a contributor agreement. If you were interested in doing that, details on how are here: http://clojure.org/contributing

Steve Miner February 26, 2015 at 9:11 PM

I bump into this every once in a while and it bothers my pedantic side.

I think it's too late to change the implementation of `list*`. There's a risk of breaking existing code (dealing with lazy-seqs, etc.) It would be good to change the doc string to say it returns a seq, not a list.

But the real issue is the name of the function implies that it will return a list. You could deprecate `list*` (but keep it forever for backwards compatibility.) A better name for the same implementation might be `seq*`.

Marek Srank January 5, 2013 at 12:13 AM

Yep, these are all valid points, thanks! I see this as a question whether the list* function is a list constructor or not. If yes (and it would be possible to implement it in a satisfactory way), it should probably return a list.

We could avoid building a new list by sth like:

(btw, 'vec' also creates a new vector even when the argument itself is a vector)

The contract of next seems to be to return a seq, not a list - its docstring reads: "Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil."

Btw, in some Lisp/Scheme impls I checked, cons seems to be a list as well. E.g. in CLisp (and similar in Guile and Racket):

Michał Marczyk January 4, 2013 at 10:19 PM

I'm in favour of the "list" -> "seq" tweak to the docstring though, assuming impl remains unchanged.

Completed

Details

Assignee

Reporter

Labels

Approval

Patch

Priority

Affects versions

Fix versions

Created September 3, 2012 at 12:32 PM
Updated July 31, 2015 at 9:39 PM
Resolved July 31, 2015 at 9:39 PM