Closed countvajhula closed 2 years ago
This syntax pattern is the reason that the fanout
only accepts numbers. It is an efficient way to compile (fanout N)
for literals, since the flow (-< _ …)
is generated at "compile-time."
For a runtime strategy, maybe adding something like this could work? I haven't tried it:
…
[(_ ({~datum fanout} n:expr))
#'(lambda args
(apply values (apply append (build-list n (thunk args)))))]
…
AKA
…
[(_ ({~datum fanout} n:expr))
;; is this #'(flow (repeat-values n __)) ?
;; or maybe #'(flow (~>> (repeat-values n))) ?
#'(lambda args (apply repeat-values n args))]
…
I think it could be useful to keep both patterns, then, so that you get the compile-time benefit for literals but runtime is still viable.
Fixed in #35
It came up in the inaugural Design Challenge in the #qi room on Discord that
fanout
only accepts literals and not arbitrary Racket expressions (e.g. variables).Example (working):
We'd like it to also support:
This currently results in:
(Pointed out by @benknoble)