!range(a, b) generates a list [a,b). a is optional and 0 by default.
- !range(-1, 4) generates [-1, 0, 1, 2, 3]
- !range(4) generates [0, 1, 2, 3]
- !range(2, 2) generates []<list<int>>
!range(list) is equivalent to !range(0, !size(list)).
Differential D145871
TableGen: Introduce `!range` operator for half-opened interval chapuni on Mar 12 2023, 7:44 AM. Authored by
Details !range(a, b) generates a list [a,b). a is optional and 0 by default.
!range(list) is equivalent to !range(0, !size(list)).
Diff Detail
Event TimelineComment Actions I'm tempted to suggest that this bang operator should be called !rangelist. The name !range suggests a pair of integers or a sequence of integers not encapsulated in a list. Add a couple of other reviewers so we can get a second opinion. Add some simpler initial tests to range-op.td, such as the examples you gave in the summary. Comment Actions Thanks for your comment. !range(m, n) and !range(n) come from Python. I will accept even if a minimal functionality (m, n) would be landed. Do you think I should drop other syntax sugars?
I will happy if you could nominate anyone, since you ask a second opinion.
I didn't think I could add simpler examples to the test. I will do if it would be better. Comment Actions I've added two reviewers. Could I get a second opinion on the name of this bang operator? I think a few simpler tests first is a good idea. In particular, it helps a future developer understand what is going on. Comment Actions !range makes sense to me because I also see the analogy to Python's range. I have some minor notes inline, apart from that the code looks good to me.
Comment Actions I see the analogy to Python's range(), except that it returns a sequence of numbers, not a list. But I'm not really too worried about this. Comment Actions
Comment Actions Yes, that's the file. You need to add the name to the list in section 1.3.3 and the description to section 1.10. Comment Actions I can't figure out what is going on here. It doesn't look like you added a description of !range.
|