Hi, Oleg.
On Tue, 28 Jun 2022 at 13:18, Oleg Nesterov <[email protected]> wrote:
> On 06/27, Yann Orlarey wrote:
> >
> > The current implementation of letrec is extremely simple and
> > almost like syntactic sugar,
>
> Yes, but I'm afraid it is only simple to you and other faust devs ;)
>
> Once I was greatly puzzled why letrec doesn't work as I'd expect, and
> I had to dig into the compiler sources to understand.
>
> For example, I think it is not immediately clear why this code
>
> process = _ : bug;
>
> bug = x,y letrec {
> 'x = _;
> 'y = 0;
> };
>
> doesn't even compile. IIUC, this is because buildRecursiveBodyDef() turns
> the code above into something like
>
> LETRECBODY = \(x, y).( ... ) ~ (_,_);
> // makeRecProjectionsList()
> x = LETRECBODY : _,!;
> y = LETRECBODY : !,_;
>
Are there cases where makeRecProjectionList() isn't redundant?
Specifically, couldn't we just translate the bug example above into the
following?
process = _ : bug;
// bug = x , y
// letrec {
// 'x = _;
// 'y = 0;
// };
bug = LETRECBODY
with {
LETRECBODY = \(x, y).(_ , 0) ~ (_ , _);
};
>
> Perhaps letrec needs more documentation? In particular, the doc could
> explain that yes, it is just syntactic sugar, and you can always avoid it.
>
As I was telling Yann in another conversation, I was thinking that
extending `with` to allow recursive definitions could be a good idea,
although I'm not against extending or improving letrec as well.
To get back to the example in my first email, the code
onePoleSwitching(att, rel, x) = y
with {
'y = (1.0 - coeff) * x + coeff * y;
coeff = ba.if(x > y, ba.tau2pole(att), ba.tau2pole(rel));
};
could be translated into
onePoleSwitching(att, rel, x) =
\(y).((1.0 - coeff) * x + coeff * y
with {
coeff = ba.if(x > y, ba.tau2pole(att), ba.tau2pole(rel));
}
) ~ _;
Does that make sense?
Dario
> And I recall I have already asked this question, but nobody replied. See
>
> https://sourceforge.net/p/faudiostream/mailman/message/36587927/
>
> and this reminds me that I'd really like to have a better way to name the
> outputs ;)
>
> Oleg.
>
>
_______________________________________________
Faudiostream-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/faudiostream-users