I think I get it. fun -> is a way to create a anonymous function, and
you'd probably use fun() -> if your function code is only a single
line and used in one place. You would go with a full def, if your
custom function were more advanced or was used repeatedly. Correct?
>> add_protocol("dolebrai",
>> fun (arg,delay) ->
>> get_process_lines("#{scripts}dolebrai-filename #{quote(arg)}"))
In this case, the function has two args, arg and delay. How are the
values for those arguments being supplied? I don't see any explicit
calls to to add_protocol.
I'm not sure there if you sense much need for this, but if you help me
understand the language I can try to write a code generator for simple
use cases. Maybe something something like a config file that defines
how you want tracks rotated, backup sources and so on, and a ruby
script (that's what I use most) that generates a .liq based on
contents of config.
On Fri, Apr 17, 2009 at 9:46 AM, Romain Beauxis <[email protected]> wrote:
> 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