Is INTEGER! in PARSE Too Obfuscating?

Maybe it's just my use cases. But I don't really find myself having literal numbers of times to run a rule very often.

I almost never use something like:

parse data [... 5 rule ...]

The very few times such things come up, I think it would be clearer as:

parse data [... repeat 5 rule ...]

If integers in PARSE were literal, that would make it easier to pass them to functions like, say, SKIP.

parse data [... skip 3 ...]
parse data [... skip -1 ...]

Since I prefer NEXT as a variable name to an operation (and want people to use NEXT OF instead of NEXT on series), I'm probably not going to push for NEXT as an arity-0 parse keyword. But skip 1 is a bit smoother to type than <any> and is literate/generic, opening the doors to other skips.

(I like skip 3 better than 3 <any> for what is intended.)

I've Demonstrated You can Define INTEGER! As Repeat Count

The existence of the INTEGER! combinator shows you can do it if you want to. And Redbol PARSE wants to.

But is it really worth it...compared to keeping our beloved mathematical abstraction of the INTEGER! abstract, to be passed to any combinator to interpret?

PARSE is getting more power, with the ability to define off-the-cuff combinators and use them inline in a single parse call. So that's quite a lot of combinators that could generically interpret integers. REPEAT feels like a drop in the bucket of things you might want to do.

So I say make INTEGER! a combinator that doesn't move the parse position and just evaluates to the integer. How about that?

2 Likes