2011/11/7 Martin Hamant <[email protected]>:
>
>
> Le 07/11/2011 11:57, Romain Beauxis a écrit :
>>
>> I am wondering something tough: could you benefit from another design
>> of your solution?
>
> Why not !
>>
>> Sources IDs are unique and retrievable using source.id. Thus, why not
>> using a separate list of source's metadata_url values, indexed by
>> source ID? Something like:
>
> Do you speak about the source ID I specify at output creation ?
>
> output = out(id="#{stream_id}".....)
>
> Because if yes - as this is the same stream_id I use in robinet - the only
> thing I would need to pass on telnet to call update_url correctly is
>
> update_url <stream_id>|<metadata_url>
Correct! The only detail is that the id you pass may be rewritten if
there is already another source registered in the system with the same
ID. In this case, source.id(output) should return the updated ID. Of
course, if you did the right thing, this should not happen :-)
>>
>> # The list
>> sources_metadata_urls = ref []
>>
>> # Update it
>> def update_url(source, url) =
>> id = source.id(s)
>> elem = (id, url)
>
> def update_url(uri) =
>
> param = string.split(separator="\|",uri)
> id = list.nth(param,0)
> url = list.nth(param,1)
>
> elem = (id, url)
> (...)
>
> Would be right ?
>
>>
>> # Directly append if not already present
>> if not list.mem_assoc(id, !sources_metadata_urls) then
>> sources_metadata_urls := list.append([elem], !sources_metadata_urls)
>> else
>> # This is more painful..
>> def f(x, cur) =
>> test_id = fst(x)
>> # Update if given element matches
>> if test_id == id then
>> list.append([elem], cur)
>> else
>> # Otherwise, put it back
>> list.append([x], cur)
>> end
>> end
>> sources_metadata_urls := list.fold(f, !sources_metadata_urls)
>
> I have added the missing "end" of the "if not..." here
>>
>> end
Woops :-)
> BTW I have a type error with that example I am not capable to decrypt:
> At line 201, char 41:
> this value has type
> (...)->[_] (infered at line 191 char 5 - line 200 char 7)
> but it should be a subtype of
> (...)->(_*_)
>
> It's still difficult for me to understand type errors
It is my call to list.fold which is incorrect. It should be:
sources_metadata_urls := list.fold(f, [], !sources_metadata_urls)
Romain
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users