This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

collect clause in progn in loop facility

3 posts · 2645 views

Suppose I have a loop form (using the loop facility) and within it is a do clause, and within the do clause is a let form, and somewhere deep within the let form are two collect clauses (like COLLECT .. INTO ..), except it's not a legal syntax to put collect clauses or any clauses in those positions. What are my options in this case?

If it were just one collect clause, I could instead put the entire let form inside a collect clause. Things seem tricky when there are two collect clauses.

I could turn the two collect clauses into two push forms but then I would be sort of reinventing the loop facility's collect feature.

Re: collect clause in progn in loop facility

CL's LOOP can be a useful tool, but it is not fully general purpose. Many language purists find it to be an abomination. Many pragmatists find it to be beautiful despite its rough spots.

Recommendation: Value results over style. Only worry about style when bugs keep cropping up in the same section of ugly code. Then refactor that code, remembering to value results over style.

:-)

Re: collect clause in progn in loop facility

It's better to specify a particular snippet why do you need have collects in a let form than just saying. In this case I can only link you to loop that it has also intial and final clauses which with collect might be used in your issue.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.