Hello,
Post by Kai-Uwe BehrmannUser might not know if a key name space supports arrays. And there I
want to help them to get the expected results. That means a persistent
storage of their keys. The API should be shot and forget style.
The API is shot and forget style. It does not matter if the underlying storage
"supports" (i.e. format nicely) arrays or not.
In yajl you get:
"array" : ["a", "b", "c"]
in XML, without arrays, you might get clumsy stuff like:
<array><#0>a</#0><#1>b</#1><#2>c</#2></array>
or anything else like:
<array><entry>a</entry><entry>b</entry><entry>c</entry></array>
Nevertheless, the user experience using kdbGet()/kdbSet() will be the same in
every ways (during discussion we also had INI examples, same thing there).
Post by Kai-Uwe BehrmannBob wants to add a key set, k1,k2 to user/array/. The array contains
some fields already. Which address shall he use to place the new keys
into an new array field?
(user/array/[#0,#1] exist already)
user/array/#2/k1
user/array/#2/k2
The proposed API ksAppendArray would take care that keys get the next
available index entries.
Post by Kai-Uwe BehrmannLinda wants to add a key set k3,k4 to user/maybe_array. She does not
know up front, how many fields are inside user/maybe_array.
She easily can find out: just kdbGet() and exhaustively iterate until end is
found (or use value once proposal is implemented).
Post by Kai-Uwe BehrmannIf the yajl
backend is not mounted to user/maybe_array, she wants still some useful
fallback, so that here keys get not lost. Which address can she use if
user/maybe_array has no keys yet below?
(user/maybe_array/ has no keys yet and yajl is not mounted to that name
space)
user/maybe_array/first/k3
user/maybe_array/first/k4
or ...
user/maybe_array/#0/k3
user/maybe_array/#0/k4
How to figure out the proper name?
I hope to could have made my point clearer.
I hope my initial explanation made clearer what an array is. There is no such
thing as "maybe_array". You can always take the next index. If you (as
application developer) define something is an array, it is.
You are, however, correct that arrays cause problems in distribution context.
Suppose software A, B add something during installation to an array:
user/array/#0 ; was added earlier by admin
user/array/#1 ; added by A
user/array/#2 ; added by A, but changed by admin
user/array/#3 ; added by B
When software A is purged (i.e. its configuration should be removed) there is
no obvious way to detect which entries were added during installation
(especially if the administrator alters parts of it). We could do reference
counting in meta data, but I am not really happy with that.
Another problem is if something is expected to be an array but in fact is not.
Currently, yajl has undefined behaviour if something starts with #0 but is not
an array and applications have problems, too. But thats basically only another
reason why configuration files must be validated. Users always can write garbage
in configuration files, thats a fundamental problem unrelated to arrays.
Post by Kai-Uwe BehrmannBtw. ksAppendArray(KeySet*, Key *); would help only in a case, where a
array contains single keys. That is not of much help for both of Linda
and Bob above.
It should be generic and always help. But maybe I still did not understand ;)
Can come up with a monitor/keyboard example which makes more clear if k1, k2
is intended to be a subkey below an array index or as key to be added as array
index.
best regards,
--
Markus Raab http://www.libelektra.org
Technische UniversitÀt Wien ***@markus-raab.org
Institut fÃŒr Computersprachen Phone: (+431) 58801/185185
Argentinierstr. 8, 1040 Wien, Austria FAX: (+431) 58801/18598
DVR 0005886