ion-docs icon indicating copy to clipboard operation
ion-docs copied to clipboard

Consider having `for` error on uneven stream lengths.

Open toddjonker opened this issue 2 years ago • 1 comments
trafficstars

I can't think of a use case where we would want to silently drop the end of the longer stream, and so being able to see that there are more elements remaining in stream could allow me (as a macro author) to raise an error when it occurs.

Is there any particular reason for it not to be an error when the streams are different lengths?

Originally posted by @popematt in https://github.com/amazon-ion/ion-docs/pull/198#discussion_r1170451166

toddjonker avatar Apr 18 '23 20:04 toddjonker

It was pointed out that allowing uneven streams as inputs enables decomposition of an input stream, eg peeling off the first element of a stream. Besides going against our tenet that macros are intended for composing data, not destructuring it, this could be a Turing-completeness issue. (As in, you may be able to use streams to represent integers, and start doing math with them.)

toddjonker avatar Jun 01 '23 18:06 toddjonker