in reply to Re: curious behavior: why does it do this?
in thread curious behavior: why does it do this?
I.e. If I have a switch or option parser, say for the command line, and you want to have one option that can take 0 or more parameters, what would be a good syntax for specifying that?
I was looking at the syntax of the range operator as a possible model for such an option, which is why I think I said I was playing around with the range syntax -- trying to think what my needs were, and how to make such a specification intuitive and useful.
While the hash might not be directly useful, having the range specified in a dynamic array would be, as collected input could be stored there. Simply listing options for range syntax doesn't give me a feel for how such would be included in a data structure.
If you put your examples into an array with other specifications named in a hash. Your examples might look more like what I was working with if you had them in a {}, since instead of (or in addition to), I have thought about specifying a min/max (but that didn't feel right) as well as one or more functions for validation and/or processing of the options on-input and perhaps for specifying a stopping condition.
I mentioned that I used an alias -- because, at least while playing, I often start with 1-liners, or "few-liners" to get an idea on how something might look or might work.
I hit the "-1" example when thinking about a way to specify "no maximum" # of params. Even specifying 0..5... looking at it I think 0 to 5 params (i.e. having no args would be ok too), but that's really not what that notation means...(*sigh*)
Note: I'm not asking folks to solve that problem, just giving the context of how I ran into this and the reason for the form of the problem.
|
|---|