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

Merge editdistance and wordwrap into strmisc #497

Closed
metagn opened this issue Nov 29, 2022 · 3 comments
Closed

Merge editdistance and wordwrap into strmisc #497

metagn opened this issue Nov 29, 2022 · 3 comments

Comments

@metagn
Copy link
Contributor

metagn commented Nov 29, 2022

Abstract

Merge the editdistance and wordwrap modules into the strmisc module.

Motivation

strmisc's description states:

This module contains various string utility routines that are uncommonly used in comparison to the ones in strutils.

editdistance and wordwrap seem to fit this description, and are small enough that they don't need to be in their own module. Having tiny procs like this in their own module clutters the standard library IMO.

Description

The way I would do it is: directly add the code of these modules to strmisc, then do the following:

# editdistance.nim
from std/strmisc import editDistance, editDistanceAscii
export editDistance, editDistanceAscii

# wordwrap.nim
from std/strmisc import wrapWords
export wrapWords

Doesn't matter if we deprecate these or not.

Code Examples

No response

Backwards Compatibility

No response

@Araq
Copy link
Member

Araq commented Dec 3, 2022

editdistance could grow into supporting more than strings though. Same for wordwrap.

More importantly, these algorithms have nothing to do with each other except that they work on string. There are thousands of useful algorithms for strings, should they all be under "strmisc"? And why not under "strutils"? When I import editdistance I get wordwrap for free? Why? It makes no sense. Both "strmisc" and "strutils" are not all that well designed.

@metagn
Copy link
Contributor Author

metagn commented Dec 3, 2022

I would agree with you if we weren't talking about the standard library. It's more arbitrary for the standard library to have separate modules for random algorithms like editdistance and wordwrap than to have a finite number of modules that would ever need to be imported like strmisc and strutils (which is really std/strings). Otherwise yeah strmisc and strutils are really bad package names, but they serve their purpose fine IMO (though strmisc is tiny as of now, I would expect stuff like strutils.formatSize to go in it).

@arnetheduck
Copy link

One way here is to have std/strings/editdistance etc then std/strings reexports every string algo and users can pick their granularity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants