Le Friday 17 April 2009 09:23:12 Brandon Casci, vous avez écrit :
> I've been checking out this script. It's interesting!
>
> http://savonet.sourceforge.net/doc-svn/dolebrai.html
>
> What language is the liq script based on? It's unlike anything I'm used to.

Well, it is a liquidsoap script, so the language is liquidsoap itself :)

> I've read about specific functions in the API docs, but I'm still
> unclear. These areas for example
>
> ###############
>
> default = single(id="default",default)
>
> s =
>   request.dynamic(id="scheduler",default_duration=30.,length=1.,
>     fun () ->
>       request(get_process_output("#{scripts}/scheduler.pl 2>>
> #{scripts}/log")))
>
> s = fallback([ request.queue(id="q"), s, default ])
>
> ###################
>
> >> default = single(id="default",default)
>
> I understand what is happening here, you're taking an individual mp3
> file, and setting up to be a source.
>
> >> s =
> >>  request.dynamic(id="scheduler",default_duration=30.,length=1.,
> >>    fun () ->
> >>      request(get_process_output("#{scripts}/scheduler.pl 2>>
> >> #{scripts}/log")))
>
> This is a little confusing to me. I understand this is probably the
> source which calls a perl script, which queries your database and
> outputs a result in the annotated format you mentioned. I don't
> understand the purpose of fun(). I noticed fun() is defined in an
> add_protocol function, and is setup to take parameters. Though no
> parameters are passed in though request.dynamic, at least not in a way
> I understand. Can you explain what's happening here?

Well, you basically got it right :)

fun is a keyword specific to functional language. In fact:
  fun (x) -> print(x)
is "equivalent" to:
  def f(x) = 
    print(x)
  end

It is not really equivalent in the sense that there can be syntactic side-
effects, but that's the idea..

Hence, here:
  fun () ->
     request(get_process_output("#{scripts}/scheduler.pl 2>> #{scripts}/log"))
Is a function that takes no value and returns a new query.

In particular:
  get_process_output: returns the output of the script.
  request: create a request based on the output of this script.

Romain

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to