Comments (5)
I agree that the suffix _clear and _clean are too similar and as such are too confusing.
I have a look at the suffix used by different C library (both containers, numbers). Here is what I get:
NAME | Constructor | Destructor | Empty Object |
---|---|---|---|
M*LIB | _init | _clear | _clean |
C++ | na | na | .clear |
C11 | _init | _destroy | na |
POSIX | _init | _destroy | na |
GMP | _init | _clear | _set_ui |
MPFR | _init | _clear | _set_nan |
MPC | _init | _clear | _set_nan |
LIBBF | _init | _delete | na |
GLIB | _alloc | _free | na |
CMC | _new | _free | _clear |
Collection C | _new | _destroy | na |
CTL | _init | _free | _clear |
KLIB | _init | _destroy | na |
LIBDYNAMIC | _construct | _destruct | clear |
LIBLFDS | _init | _cleanup | na |
SRT | _alloc | _free | _clear / _reset |
QLIBC | none | _free | _clear |
UTHASH | _new / _init | _free / _done | _clear |
SDS | _new | _free | na |
BSTRLIB | _fromcstr | _destroy | na |
SQLITE3 | _initialize | _shutdown | na |
I don't see any winner for the pair constructor / destructor, whereas the "clear" suffix is the winner for emptying the container.
Also, as a subjective note, I found the suffix destroy as too negative, the suffix free as unbalanced (it is associated to an _alloc), and clear/clean far from perfect (confusing with empty object).
Some people also use terminate as the opposite suffix of _init.
This opinion is comforted when I look at theses threads:
https://gist.github.com/maxtruxa/b2ca551e42d3aead2b3d
https://softwareengineering.stackexchange.com/questions/163004/what-is-the-opposite-of-initialize-or-init
The opposite of _init doesn't make consensus.
Changing the _clear suffix would have a lot of impact on the user code: nearly all user code uses such destructor. In comparison, the _clean suffix is much less used.
Therefore, what I propose is to rename _clean suffix and CLEAN operator in _reset suffix and RESET operator. This will avoid the confusion of _clear & _clean. Moreover, _reset is as good as _clean for an operation that empty the container (reset it).
This implies the following steps:
- Create the _reset suffix of the functions.
- Use then in the OPLIST.
- Mark the _clean suffix as obsolete
- Rename the operator CLEAN in RESET (this will break API compatibility but few user programs should use directly this operator of the oplist - I hope).
- Release this version of M*LIB.
- Remove the _clean suffix functions.
from mlib.
Sounds awesome, should we wait for you or do changes and make PR?
from mlib.
should we wait for you or do changes and make PR?
I already performed the first step of renaming of _clean into _reset in master (and making _clean a deprecated function).
from mlib.
The _clean methods have been removed from the master branch.
from mlib.
Awesome, thank you very much )
from mlib.
Related Issues (20)
- Compiler errors HOT 3
- README example not work HOT 3
- Add EMPLACE_TYPE support for B+TREE, DICT, RB-TREE, BUFFER, CONCURRENT HOT 3
- bitset: function for getting minimum index with bit set HOT 3
- Memory leak HOT 5
- How to define REALLOC in OPLIST? HOT 1
- Bug in list? HOT 1
- Allocator customization HOT 2
- How to define a set of pointer? HOT 1
- Github actions failure HOT 1
- Non-null array get() after reset() HOT 1
- Missing explanation of how to access multiple values in a BPTREE_MULTI HOT 2
- Documentation of and access to M-ARRAY being contiguous HOT 10
- clang-cl actions failure
- Inconsistency in I-LIST use of OPLIST HOT 2
- Backward iteration for M-BPTREE HOT 2
- How to define custom malloc and free function in m-i-shared HOT 1
- Documentation for M-BPTREE does not match all functions HOT 1
- M-SHARED pointer cannot use forward-declared type HOT 1
- Change _str suffix HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mlib.