RFC: result/value-split - list/dict/propdict iterators

2008-06-23 Thread Sébastien Cevey
Hello folks! I'm in the process of doing the so-called “result-value split”, i.e. introducing a new xmms_value_t type dissociated from the current xmmsc_result_t used everywhere. In the new version, result notifiers are passed a value_t instead of a result_t (the function return value is used to

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Anders Waldenborg
Sébastien Cevey wrote: Hello folks! Hello! [here was a nice high level motivation description] Here follows some quick comments. Here is my proposed API, strongly based on anders' ideas: /* Prototypes */ xmms_value_list_t * xmms_value_list_get_iterator (xmms_value_t *val); int xmms_

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Sebastien Cevey
Selon Anders Waldenborg <[EMAIL PROTECTED]>: > I think I would s/xmms_value_list/xmms_value_iter/ Since we will probably have different iterators for lists, dicts and propdicts, you need to reflect that in the type name too. Initially I had xmms_value_list_iter_t, but I thought it was too long..

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Anders Waldenborg
Sebastien Cevey wrote: Selon Anders Waldenborg <[EMAIL PROTECTED]>: Selon! Selon! I think I would s/xmms_value_list/xmms_value_iter/ Since we will probably have different iterators for lists, dicts and propdicts, you need to reflect that in the type name too. Initially I had xmms_value_li

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Erik Massop
Dear List, I have also done some drafting some day ago and came up with this: /* Node of the doubly-linked-list of list, dict and propdict */ typedef struct xmms_generic_iterator_St { xmms_generic_iterator_t *prev; xmms_generic_iterator_t *next; xmms_generic_iterator_head_

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Anders Waldenborg
theefer forgot to cc list. --- Begin Message --- Enligt Anders Waldenborg <[EMAIL PROTECTED]>: > I really want _iter_ in the name.. Ok. > Also, is it xmms_ or xmmsc_? Maybe it is a entirely new system: > "xmmsv_", which gives: v(alue) doesn't seem to live in the same "namespace" as c(lient)

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Sebastien Cevey
Enligt Anders Waldenborg <[EMAIL PROTECTED]>: > I really want _iter_ in the name.. Ok. > Also, is it xmms_ or xmmsc_? Maybe it is a entirely new system: > "xmmsv_", which gives: v(alue) doesn't seem to live in the same "namespace" as c(lient) or (server). mh and we have xmmsc_coll_t, also used

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Sebastien Cevey
Sorry for the dupe, I thought anders' didn't forward it. Selon Sebastien Cevey <[EMAIL PROTECTED]>: > > x_list_t is bi-directional no? I would not mind making it circular. > > No, it isn't (currently). Don't listen to me, I'm lying. It is, as nesciens' said. -- Sebastien Cevey - inso.cc --

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Anders Waldenborg
Erik Massop wrote: Currently dict are ...-key-value-key-value-... lists and propdict ...-source-key-value-source-key-value-... lists, so they can be quite related to lists, if you keep up this linear design. Performancewise binary-trees or hash-tables might be better. Just a quick note before I

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Anders Waldenborg
Sebastien Cevey wrote: xmmsv_t xmmsv_coll_t xmmsv_list_iter_t Yeah, this also gives nice short names. I think that is the way to go. [] Sure I agree with that. The question is what happens to the state of the internal pointer. With: def append(v, entry): it = v.iter() it.l

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Erik Massop
On Tue, 24 Jun 2008 16:36:05 +0200 Anders Waldenborg <[EMAIL PROTECTED]> wrote: > Erik Massop wrote: > > Currently dict are ...-key-value-key-value-... lists and propdict > > ...-source-key-value-source-key-value-... lists, so they can be quite > > related to lists, if you keep up this linear desi

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Erik Massop
On Tue, 24 Jun 2008 16:56:51 +0200 Anders Waldenborg <[EMAIL PROTECTED]> wrote: > I was thinking along these lines: > > key = xmmsv_new_string("artist") > val = xmmsv_new_string("Metallica") > entry=xmmsv_new_pair(key,val) > list_append(list,entry) Would key really be an xmmsv_value_t, as that mi

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Daniel Svensson
On Tue, Jun 24, 2008 at 4:29 PM, Sebastien Cevey <[EMAIL PROTECTED]> wrote: > int callback (xmms_value_t *val) { >iter = xmms_value_get_list_iterator (val); /* allocates */ > >/* do stuff */ > >xmms_value_unref (val); >xmms_value_iter_unref (iter); > } What's the reason we don't

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Anders Waldenborg
Erik Massop wrote: I was thinking along these lines: key = xmmsv_new_string("artist") val = xmmsv_new_string("Metallica") entry=xmmsv_new_pair(key,val) list_append(list,entry) Would key really be an xmmsv_value_t, as that might disallows bindings to convert dicts to the native hash-tables, un

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Anders Waldenborg
Daniel Svensson wrote: int callback (xmms_value_t *val) { iter = xmms_value_get_list_iterator (val); /* allocates */ /* do stuff */ xmms_value_unref (val); xmms_value_iter_unref (iter); } What's the reason we don't do like this: None. Callee should always borrow the callers re

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Sébastien Cevey
At Tue, 24 Jun 2008 17:17:22 +0200, Daniel Svensson wrote: > What's the reason we don't do like this: Sorry, I think that's already the way I implemented it actually. -- Sébastien Cevey / inso.cc " A designer knows he has achieved perfection not when there is nothing left to add, but when th

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Sébastien Cevey
At Tue, 24 Jun 2008 18:17:15 +0200, Anders Waldenborg wrote: > Are you thinking about some specific language? e.g. in Ruby, we currently use symbols as dict keys. KISS. > Also just because xmmsv allows you to do strange things doesn't mean > you have to :) I don't see why we should allow to do

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Daniel Chokola
Sébastien Cevey wrote: Hello folks! Hi, theefer! I'm in the process of doing the so-called “result-value split”, i.e. introducing a new xmms_value_t type dissociated from the current xmmsc_result_t used everywhere. In the new version, result notifiers are passed a value_t instead of a result

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Daniel Chokola
Oh, see, I should have read one more email. nesciens' proposal seems similar to my code. Erik Massop wrote: Some notes: a) I have no clue about the proper names of the types. (Maybe (probably) these shouldn't even be called iterators!) b) x_list is not used. c) key and source are in the iterat

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Daniel Chokola
Erik Massop wrote: On Tue, 24 Jun 2008 16:56:51 +0200 Anders Waldenborg <[EMAIL PROTECTED]> wrote: I was thinking along these lines: key = xmmsv_new_string("artist") val = xmmsv_new_string("Metallica") entry=xmmsv_new_pair(key,val) list_append(list,entry) Would key really be an xmmsv_value_t,

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-24 Thread Daniel Chokola
Sébastien Cevey wrote: At Tue, 24 Jun 2008 18:17:15 +0200, Anders Waldenborg wrote: Are you thinking about some specific language? e.g. in Ruby, we currently use symbols as dict keys. KISS. In Ruby, we use Objects (any type) ;) But I wouldn't advocate that. irb(main):001:0> {Object.new =>

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-25 Thread Sebastien Cevey
Selon Erik Massop <[EMAIL PROTECTED]>: > /* Node of the doubly-linked-list of list, dict and propdict */ > typedef struct xmms_generic_iterator_St { > xmms_generic_iterator_t *prev; > xmms_generic_iterator_t *next; > xmms_generic_iterator_head_t *parent; > > xmms_val

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-25 Thread Erik Massop
On Tue, 24 Jun 2008 23:10:56 -0400 Daniel Chokola <[EMAIL PROTECTED]> wrote: > > i) IMHO xmms_generic_iterator_head_t should really be in the union (the > > generic pointer would probably have to be removed) > > See how I arranged my list code. The head is the only thing users get to > touch, wh

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-25 Thread Erik Massop
On Wed, 25 Jun 2008 09:23:35 +0200 Sebastien Cevey <[EMAIL PROTECTED]> wrote: > Selon Erik Massop <[EMAIL PROTECTED]>: > > > /* Node of the doubly-linked-list of list, dict and propdict */ > > typedef struct xmms_generic_iterator_St { > > xmms_generic_iterator_t *prev; > > xmms_generic_it

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-25 Thread Erik Massop
On Wed, 25 Jun 2008 10:27:10 +0200 Erik Massop <[EMAIL PROTECTED]> wrote: > /* Repetitive */ Too much so apparently... > static void xmmsv_generic_iter_remove (xmmsv_generic_iter_t *it) { > it->prev->next = it->next; > it->next->prev = it->prev; > > free (it); > } > /* FIXME: r

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-25 Thread Sebastien Cevey
Please be on IRC if you're online ;-P We've just discussed with anders and puzzles and we believe we can get rid of propdicts if we translate the source_prefs on the server anyway (which is the plan). It would still be possible to retrieve [source, key, value] tuples, but because we don't emulate

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-25 Thread Peter Stuge
On Wed, Jun 25, 2008 at 11:27:57AM +0200, Sebastien Cevey wrote: > your magic cluster thing? I love magic cluster things! //Peter -- ___ Xmms2-devel mailing list Xmms2-devel@lists.xmms.se http://lists.xmms.se/cgi-bin/mailman/listinfo/xmms2-devel

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-26 Thread Daniel Chokola
Erik Massop wrote: On Tue, 24 Jun 2008 23:10:56 -0400 Daniel Chokola <[EMAIL PROTECTED]> wrote: i) IMHO xmms_generic_iterator_head_t should really be in the union (the generic pointer would probably have to be removed) See how I arranged my list code. The head is the only thing users get to to

Re: RFC: result/value-split - list/dict/propdict iterators

2008-06-27 Thread Sébastien Cevey
At Fri, 27 Jun 2008 02:34:22 -0400, Daniel Chokola wrote: > But supposedly dicts and propdicts merge if we move source preference to > the client side. *server* side. > I really wish someone would show me an example, because I'm not > understanding how this works. :( medialib_set_source_pref