Hi Martin,

On Thu, Jun 16, 2011 at 1:09 PM, Martin Hamant <[email protected]> wrote:
> Is it right to say, output.icecast() take a format and a source as args,
> "returning" a new source ?
> So what about the type (format, source) => source

It is right to say that, and the type you wrote is correct. Precisely,
we would write (format,source)->source (and in fact,
(format('a),source('a))->source('a)) but not format->source->source
(Romain wrote this as a shortcut, and because it is written like that
in other languages).

>> But if you do:
>>   out(%mp3)
>> Then the variable out is still of type format ->  source ->  source
>> because the above was not kept..
>
> can you define "not kept" (from ? why ?)

The expression out(%mp3) is correct but you need to do something with
it. In your case, you want to update the definition of out to become
out(%mp3). So the new definition should not be inside the conditional.
You can write this as follows (I write extra parenthesis to clarify):

# initial def
out = output.icecast(...)
# new definition
out = (if ... then out(%mp3) else ... end)
# at this point out may actually be out(%mp3)
# so it only expects a source now

The important point is to write the if-then-else inside the second
definition, and not the other way around. This may seem unusual, but
the key is to realize that if-then-else is an expression constructor
like another. This is unlike in language like C/Java/Python/etc where
if-then-else only forms statements/instructions (something like x :=
1, print(x)) but not expressions (something like x+1, x<=3, etc). In
fact, everything is an expression in liquidsoap (and more generally in
functional languages).

Hope this helps,
-- 
David

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to