I'm writing a Clojure parser in Clojure. A certain parser reads a
series of forms, and returns a seq (potentially including nil).
Certain other parsers use the first parser to read list forms, vector
forms, map forms, and set forms.

The vector parser calls vec on its contents' sequence, the set parser
calls set, the map parser calls (partial apply hash-map), and the list
parser calls list*. I encountered an error, though, where parsing an
empty list form "()" results in nil rather than (), because (list* ())
is nil.

It's not a big deal; I wrote around it. But it was pretty unexpected.
I thought list* was to list as vec is to vector.

On Jan 22, 2:55 pm, ataggart <alex.tagg...@gmail.com> wrote:
> On Jan 22, 1:30 pm, samppi <rbysam...@gmail.com> wrote:
>
> > This is not a big deal: it is a quibble with a weird and inconvenient
> > behavior of list*: when given an empty sequence, it returns nil
> > instead of the empty list. Why is this? According to list*'s
> > documentation, list* should always return a list.
>
> Judging from the code for list*, as well as its usage in apply, I
> infer the return value is supposed to adhere to seq semantics.  What
> issue were you having such that returning a nil (as opposed to an
> empty list) was a problem?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to