dict type?
Havoc Pennington
hp@redhat.com
11 Oct 2003 18:22:02 -0400
Hi,
Questioning the dict type. A method signature like this:
foo (array<string> keys, array<int> values)
gives you equivalent performance and data transfer as the dict type,
except that the values have homogeneous type.
Perhaps we should have an "any"/variant type:
foo (array<string> keys, array<variant> values)
Would that be more useful and involve less code than
the dict?
One way to think about this is that array<variant> is essentially
equivalent to a struct, while dict is essentially equivalent to a struct
with a name for each struct field.
I don't believe either the variant array or the dict maps all that well
to a reasonable GLib/Qt API. You end up with GValue/QVariant which will
be a pain to use, or with some kind of "marshal array into a struct"
which would require code generation from an IDL.
However, dict may well map nicely to a reasonable API in something like
python, since you could dynamically build a python dict out of it.
Havoc