Bug 21650 – parse form that returns elements parsed is too difficult to use

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-02-19T12:53:01Z
Last change time
2024-12-01T16:38:27Z
Assigned to
No Owner
Creator
Steven Schveighoffer
Moved to GitHub: phobos#10457 →

Comments

Comment #0 by schveiguy — 2021-02-19T12:53:01Z
Based on this PR: https://github.com/dlang/phobos/pull/7642 and issue 21233 parse gained an extra parameter which is a Flag, and that indicates whether the return should include a size_t of how many items were parsed. However, the ordering of the new parameter makes it difficult to use, you have to specify the source type in order to get to the Flag parameter. By adding additional overloads in the form: parse(Target, Flag!"doCount", Source)(Source rng) the flag is more accessible. I should not have to specify the Source type in order to specify the flag. In fact, I think this could have been done with an overload originally, but at this point, code probably already exists that uses the form `parse!(long, typeof(s), Yes.doCount)(s)`
Comment #1 by adela.vais99 — 2021-02-20T21:59:18Z
The order you suggested would have introduced breaking changes. See a thread here [1]. [1] https://github.com/dlang/phobos/pull/7642#discussion_r493478675
Comment #2 by schveiguy — 2021-02-21T15:13:36Z
I don't think having both overloads would break any code. Types don't match values, values don't match types. parse(Target, Source, Flag!"doCount" doCount)(Source rng) will match existing uses that specify the source range type explicitly parse(Target, Flag!"doCount" doCount, Source)(Source rng) will match new uses that want to use IFTI to detect the Source range type. What was discussed in that thread is inserting the flag in *existing* functions. I'm talking about adding overloads to address the new usage.
Comment #3 by robert.schadek — 2024-12-01T16:38:27Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10457 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB