Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify rules for repeat macro #350

Open
popematt opened this issue Oct 11, 2024 · 1 comment
Open

Clarify rules for repeat macro #350

popematt opened this issue Oct 11, 2024 · 1 comment
Labels
specification 1.1 Ion 1.1 specification work

Comments

@popematt
Copy link
Contributor

popematt commented Oct 11, 2024

It's pretty obvious that something like this should be illegal:

(:repeat -2 true)

Should this be allowed?

(:repeat 0 true)

My thoughts are...

  • It could be surprising either way.
  • We're specifically not trying to make sure the macro system is suitable for general purpose computing. Disallowing 0 here helps to make sure that you can't do something like (.if_none (.repeat (%x) '') "x is 0" "x is more than 0").
  • In some implementations, it may be easier to implement the repeat macro if we can just raise an error for 0 rather than potentially adding special logic to advance the reader appropriately when it is 0.

I'm inclined to say no.

Second question is should the n parameter be flex_uint::n?

@popematt popematt added the specification 1.1 Ion 1.1 specification work label Oct 11, 2024
@popematt popematt changed the title Does the repeat macro allow n = 0? Clarify rules for repeat macro Oct 11, 2024
@popematt
Copy link
Contributor Author

In amazon-ion/ion-tests#133, we decided that a repeat of 0 is allowed, and confirmed that repeating an empty stream is also allowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
specification 1.1 Ion 1.1 specification work
Projects
Development

No branches or pull requests

1 participant