On the naming of the 'kons/knil' argument in flexvector-fold{,-right}
Zhu Zihao 04 Jan 2026 17:47 UTC
The signature of flexvector-fold{,-right} is:
(flexvector-fold kons knil fv1 fv2 ...)
Though the procedure that aggregates values is called 'kons' (and the
accmulate argument is called 'knil'), its argument order doesn't conform
to the metaphor of 'cons' and 'nil'. For example, we can't simply use
(flexvector-fold-right cons '() fv) to transform a flexvector to
corresponding list.
Quoted from SRFI: "kons is applied as (kons state (flexvector-ref fv1 i)
(flexvector-ref fv2 i) ...) where state is the current state value—the
current state value begins with knil, and becomes whatever kons returned
on the previous iteration—and i is the current index."
In SRFI-1, 'fold-right' has 'kons' and 'knil' argument, however, it's
being used like (kons e1 e* ... knil).
I would suggest to change the naming of 'kons' and 'knil' argument in
'flexvector-fold' to 'combine' and 'nil', which inspired from how R6RS
name the argument of 'fold-left/right'.
--
Retrieve my PGP public key:
执行下列命令以获取我的 PGP 公有密钥:
gpg --recv-keys B3EBC086AB0EBC0F45E0B4D433DB374BCEE4D9DC
Zihao / 閱卜錄