Replies: 7 comments 15 replies
-
In general I agree that we could/should clean up the API where possible, but I do not agree with all points. I'm having a hard time to select functions which I would throw out of
So you suggest having: ssize_t keySetValue (const Key * key, const void * value, size_t length, someflag_t flags); where then according to the flag the length parameter would be ignored? In that particular case I prefer the current API, it seems more convenient to me. On the other hand I mostly agree with your proposal for the Key API. The question is: how do we handle the rest of the functions which are thrown out of kdb.h? |
Beta Was this translation helpful? Give feedback.
-
A general clarification: I'm am of course in favour of keeping the API clean. I'm however, not sure To me "minimal" means the absolute minimum to make the API usable (not useful). For To keep the API clean, I think we should restrict An alternative (especially to make migration easier) would be: |
Beta Was this translation helpful? Give feedback.
-
Minimal is related to working with the data structure: every operation the data structure supports efficiently should be available. What can be build from these operations is not minimal anymore and should be moved out of the core (e.g. to libease). In doc/todo/FUTURE there is already a list of which function might be removed. Removing the meta-functions makes sense to me. They got obsolete with the introduction of Merging functions by giving them more parameters does not make the API more minimal.
Also do not forget about #3098. So maybe elektra/core.h for KeySet (libelektra-core), elektra/kdb.h for KDB (libelektra-kdb). |
Beta Was this translation helpful? Give feedback.
-
That is where our definitions of minimal differ. To me efficiently doesn't have anything to with minimal. But even with your definition, I don't think "minimal" shouldn't necessarily be a goal for Now what is "clean"? I think it is very similar to "minimal", but a bit more flexible. For example, I think adding short In that sense, I think keeping static inline Key * keyGetMeta (Key * k, const char * meta) {
return ksLookupByName (keyMeta (k), meta, 0);
}
static inline void keySetMeta (Key * k, const char * meta, const char * value) {
ksAppendKey (keyMeta (k), keyNew (meta, KEY_VALUE, value, KEY_END));
} But currently they are more complicated, partly because they translate e.g. Right now we are also just discussing headers, but we should also discuss the shared libraries. I really dislike the idea that I have to link against another library (e.g. libease) for very basic convenience functions. Maybe there needs to be a step in between. So let's say Basically, I want to avoid a situation, where you could use BTW I think some of the stuff currently in |
Beta Was this translation helpful? Give feedback.
-
This definition is used in C++. They have quite a lot of containers and only offer the methods that can be implemented efficiently. Elektra uses this definition quite some time but not forever. E.g. in the beginning there was also a case-insensitive search of key names which needed O(n). I removed this as it is against minimalism: everyone can iterate over the KeySet and make a case-insensitive comparison themselves (or we would add it to libease if it would be an important functionality for many customers).
Yes, I fully agree.
Yes, I like that idea. Maybe "elektra/aliases.h" states clearer what it is, "elektra/helpers.h" is good, too. If there are no objections I would add it in doc/DESIGN.md.
I fully agree with this goal. static inline helper-functions are not a bad idea. But still we have to be careful with them, as they also need to be consistent with everything else.
This is against the minimalism: if there is any possibility to remove it from the core, we should do so. The core otherwise gets too bloated and not everyone needs arrays or relative names. |
Beta Was this translation helpful? Give feedback.
-
Then maybe there should be step between libcore and libease as well. Not everyone needs arrays, but many plugins do support them. Pulling in all of libease just for basic array support seems a bit silly. |
Beta Was this translation helpful? Give feedback.
-
CMake provides support for it, we do not need to add anything for it. Elektra uses it at several places, e.g.: fcrypt uses code from the crypto plugin; adapters of the IO libs; crypto had the
I agree, we could use private/static libs more, e.g. the utility library does not need to be public. |
Beta Was this translation helpful? Give feedback.
-
In #3606 @markus2330 mentioned that
kdb.h
is supposed to be minimal. I don't think this is the case.IMO the minimal API for
Key
would be:Possibly
keyLock
/keyIsLocked
(or a more generalkeyFlags
/keySetFlags
) could be considered minimal as well. Also replacingkeySetString
andkeySetBinary
withkeySetValue
with an additional flag would be more minimal.Anything else regarding
Key
is at least as much a convenience function as thekeyDup
alias would be.The
KeySet
part of the API is more minimal, butksLookupByName
,ksHead
andksTail
are definitely not minimal.The only part that is actually minimal IMO is the
KDB
part.I think this would be a good task for Stefan. Basically answering the question: "What would be a minimal API to replace
kdb.h
?" Which parts of the answer we want to implement will then be up to us.Beta Was this translation helpful? Give feedback.
All reactions