-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Added 'openArray[char]' overloads to 'std/parseutils' #20527
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
Conversation
Seems an issue will be converters to |
Nah, it's fine this way IMO. The real issue is here that it's a breaking change which would be easily avoidable by introducing duplication in the form of a new |
In the case where people want a 'weak distinct' it would give the ability to optimise a copy away as the following. Given type NotString = distinct string
converter toString*(s: NotString): lent string = string(s) |
I understand the problem but introducing "converter chaining" at this point would be far too an invasive change. So the next best option is |
bcbbbd2
to
399a967
Compare
399a967
to
869eb81
Compare
This is a kludgy hack. Is there any alternative to creating a copy of an entire module? Why can't the duplicate functions just be added to
Even if it's only for special cases (like openarrays)? |
I forgot that |
Especially if it's only for special cases. These come back and bite you. ;-) |
For custom string types it's nice to have implicit converters to openArray: {.experimental: "views".}
converter toOpen(x: MyString): openArray[byte] =
toOpenArray(x.data, 0, x.data.high) although I don't know if this is the direction we are going, or is it going to cause problems? |
The direction I'd like here is to solve this problem in a simple way, that minimizes redundancy. Ideally by just adding overloads and/or type constraints to procedures in parseutils. |
Adding overloads that support openArray[char] seems to be the best option for now. |
869eb81
to
400681a
Compare
a6f31bf
to
e72cdcc
Compare
e72cdcc
to
ac883a4
Compare
7e29543
to
5f71a80
Compare
Thanks for your hard work on this PR! Hint: mm: orc; opt: speed; options: -d:release |
* Added 'openarray[char]' overloads to 'std/parseutils' * Removed redundant `start` and `last` params from slice using procs * Fixed type for parseIdent overload * fixed one by off with 'substr' * removed missed start parameters for procedures * Added 'openarray[char]' overloads to 'std/parseutils' * Removed redundant `start` and `last` params from slice using procs * Fixed type for parseIdent overload * fixed one by off with 'substr' * removed missed start parameters for procedures * Fixed VM op to work with new 'opcSlice' * Corrected captureBetween's logic to work with openarray * js sys's parsefloat logic now uses openarray Co-authored-by: Clay Sweetser <[email protected]>
* Added 'openarray[char]' overloads to 'std/parseutils' * Removed redundant `start` and `last` params from slice using procs * Fixed type for parseIdent overload * fixed one by off with 'substr' * removed missed start parameters for procedures * Added 'openarray[char]' overloads to 'std/parseutils' * Removed redundant `start` and `last` params from slice using procs * Fixed type for parseIdent overload * fixed one by off with 'substr' * removed missed start parameters for procedures * Fixed VM op to work with new 'opcSlice' * Corrected captureBetween's logic to work with openarray * js sys's parsefloat logic now uses openarray Co-authored-by: Clay Sweetser <[email protected]>
Closes #14810 |
No description provided.