Skip to content

Clarify rules for repeat macro #350

@popematt

Description

@popematt

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions