Re: Argument order for folds
Marc Nieper-Wißkirchen 03 Sep 2020 11:35 UTC
Am Do., 3. Sept. 2020 um 12:05 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
> So your position is that fold-right is "The Right' fold and deserves the name "fold"? I tend to agree, if we could abandon backward compatibility.
Even when we would be able to "correct" the name for R7RS-large, it
would cause too much confusion when reading or maintaining existing
code.
The only sensible thing we could do would deprecate the name "fold"
and alias it by something new and unambitious.
> My problem is more about the disagreement of two left fold (or should we call it fold gauche?) and I wish it could be named differently. On lists, we already have fold and fold-left. Vector-flavor fold could've adopted the name fold-left.
"fold-gauche" made me laugh! :)
> If we ever have a chance to rename everything, I agree that srfi-1 fold could give up its place---foldx as you suggested may be good. We could have foldl (R6RS fold-left) and foldr (fold-right).
foldr and foldl (with a SRFI 133-like kons) would make a lot of sense
as a uniform interface for sequence-like data types. Who is going to
write the SRFI?
The next construction site are then the unfold operations (which,
conceptually work on streams or, more generally, on coinductive data
types). The vector protocol is different from the list protocol. The
vector protocol has the advantage of allowing zero or more than one
seed value. Unfold-right is the "correct" unfold composed with list
reversal.
What would be a good consistent naming convention here?
Marc