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

Make substr not have an optional argument #113

Closed
masak opened this issue Dec 29, 2015 · 0 comments · Fixed by #123
Closed

Make substr not have an optional argument #113

masak opened this issue Dec 29, 2015 · 0 comments · Fixed by #123

Comments

@masak
Copy link
Owner

masak commented Dec 29, 2015

Right now substr takes an optional third argument. Which means that both 2 and 3 arguments work with calling that function. It's not a big thing, but it's slightly annoying, because nothing else in 007 works that way.

We could go any of the following ways in resolving that:

  1. Make the third parameter non-optional. Live with the consequences: having to write out the third argument always, even when we want the rest of the string.
  2. Split up substr into two functions. Maybe call them substr(s, pos, chars) and suffix(s, pos). For consistency, maybe also add a prefix(s, pos).
  3. Add optional parameters (via Make it possible to switch on optional parameters/parameter defaults/rest parameters #112, but the first step is enough). Declare that the setting as a compilation unit makes use of the optional_parameters pragma.

I'm kind of leaning towards the second option right now because it's easier. (Maybe there is prior art somewhere containing better names than prefix and suffix? It has to be two words that mean "start" and "end"; using "left" and "right" is unfair to RTL writing systems.) But really, any solution on the list is acceptable.

sergot pushed a commit that referenced this issue Mar 9, 2016
make substr take 3 arguments (no optional args), add prefix and suffix methods accordingly
closes #113
@masak masak closed this as completed in #123 Mar 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant