Csound Csound-dev Csound-tekno Search About

[Csnd] Help with forward reference (define)

Date2020-10-09 17:49
FromHlöðver Sigurðsson
Subject[Csnd] Help with forward reference (define)
I'm trying to achieve some sort of hoisting/forward reference where I need to call between two UDOs where one is calling itself and the other one calls the calling function back again.

https://ide.csound.com/editor/CcCca1LfX6EndkffwMlG

The perfect solution would be passing of a function pointer, since that's not yet in csound, I was hoping there was some sort of opcode which I could use, to define A in this example, and redefine it later?

Also any workarounds appreciated!

Cheers,
Hlödver
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-10-10 04:38
Fromandy fillebrown
SubjectRe: [Csnd] Help with forward reference (define)
Maybe implement the A and B paths in opcode AB and use a 3rd argument to switch between the A path or B path when AB calls itself?


On Fri, Oct 9, 2020 at 12:50 PM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
I'm trying to achieve some sort of hoisting/forward reference where I need to call between two UDOs where one is calling itself and the other one calls the calling function back again.

https://ide.csound.com/editor/CcCca1LfX6EndkffwMlG

The perfect solution would be passing of a function pointer, since that's not yet in csound, I was hoping there was some sort of opcode which I could use, to define A in this example, and redefine it later?

Also any workarounds appreciated!

Cheers,
Hlödver
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-10-10 13:53
Fromthorin kerr
SubjectRe: [Csnd] Help with forward reference (define)
This cheats a little, by doing a dummy 'declaration' of opcode B, before redefining it later.

Not sure if that's what you meant.

Thorin



On Sat, Oct 10, 2020 at 2:50 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
I'm trying to achieve some sort of hoisting/forward reference where I need to call between two UDOs where one is calling itself and the other one calls the calling function back again.

https://ide.csound.com/editor/CcCca1LfX6EndkffwMlG

The perfect solution would be passing of a function pointer, since that's not yet in csound, I was hoping there was some sort of opcode which I could use, to define A in this example, and redefine it later?

Also any workarounds appreciated!

Cheers,
Hlödver
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-10-11 00:55
FromHlöðver Sigurðsson
SubjectRe: [Csnd] Help with forward reference (define)
Both ideas sound promising, though I tried thorin's idea of defining and then redefining, I forgot why that didn't work, but I'll try again in my use case and report.

Thanks a lot for the tips!

On Sat, 10 Oct 2020 at 14:54, thorin kerr <thorin.kerr@gmail.com> wrote:
This cheats a little, by doing a dummy 'declaration' of opcode B, before redefining it later.

Not sure if that's what you meant.

Thorin



On Sat, Oct 10, 2020 at 2:50 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
I'm trying to achieve some sort of hoisting/forward reference where I need to call between two UDOs where one is calling itself and the other one calls the calling function back again.

https://ide.csound.com/editor/CcCca1LfX6EndkffwMlG

The perfect solution would be passing of a function pointer, since that's not yet in csound, I was hoping there was some sort of opcode which I could use, to define A in this example, and redefine it later?

Also any workarounds appreciated!

Cheers,
Hlödver
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-10-11 01:56
FromSteven Yi
SubjectRe: [Csnd] Help with forward reference (define)
One issue is that Csound doesn't allow redefining an instrument within
the same compilation pass. I imagine that is what the issue you ran
into is?  This has happened to me before and I think this could
benefit from a change. My use case is different than this though. The
downside is that, if I'm remembering correctly, if you compile a, then
b, then a, b would have a reference to the first a, not the latter a.

On Sat, Oct 10, 2020 at 7:55 PM Hlöðver Sigurðsson  wrote:
>
> Both ideas sound promising, though I tried thorin's idea of defining and then redefining, I forgot why that didn't work, but I'll try again in my use case and report.
>
> Thanks a lot for the tips!
>
> On Sat, 10 Oct 2020 at 14:54, thorin kerr  wrote:
>>
>> This cheats a little, by doing a dummy 'declaration' of opcode B, before redefining it later.
>> https://ide.csound.com/editor/plVSlXzHkWiCGWQUvJmt
>>
>> Not sure if that's what you meant.
>>
>> Thorin
>>
>>
>>
>> On Sat, Oct 10, 2020 at 2:50 AM Hlöðver Sigurðsson  wrote:
>>>
>>> I'm trying to achieve some sort of hoisting/forward reference where I need to call between two UDOs where one is calling itself and the other one calls the calling function back again.
>>>
>>> https://ide.csound.com/editor/CcCca1LfX6EndkffwMlG
>>>
>>> The perfect solution would be passing of a function pointer, since that's not yet in csound, I was hoping there was some sort of opcode which I could use, to define A in this example, and redefine it later?
>>>
>>> Also any workarounds appreciated!
>>>
>>> Cheers,
>>> Hlödver
>>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>
>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2020-10-11 04:45
Fromthorin kerr
SubjectRe: [Csnd] Help with forward reference (define)
It gets a little meta and convoluted, but compilestr and evalstr could be used to workaround.
I've updated that example in the IDE.

Strings and evaluations, it's starting to feel a little lispy

Thorin



On Sun, Oct 11, 2020 at 10:57 AM Steven Yi <stevenyi@gmail.com> wrote:
One issue is that Csound doesn't allow redefining an instrument within
the same compilation pass. I imagine that is what the issue you ran
into is?  This has happened to me before and I think this could
benefit from a change. My use case is different than this though. The
downside is that, if I'm remembering correctly, if you compile a, then
b, then a, b would have a reference to the first a, not the latter a.

On Sat, Oct 10, 2020 at 7:55 PM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
>
> Both ideas sound promising, though I tried thorin's idea of defining and then redefining, I forgot why that didn't work, but I'll try again in my use case and report.
>
> Thanks a lot for the tips!
>
> On Sat, 10 Oct 2020 at 14:54, thorin kerr <thorin.kerr@gmail.com> wrote:
>>
>> This cheats a little, by doing a dummy 'declaration' of opcode B, before redefining it later.
>> https://ide.csound.com/editor/plVSlXzHkWiCGWQUvJmt
>>
>> Not sure if that's what you meant.
>>
>> Thorin
>>
>>
>>
>> On Sat, Oct 10, 2020 at 2:50 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
>>>
>>> I'm trying to achieve some sort of hoisting/forward reference where I need to call between two UDOs where one is calling itself and the other one calls the calling function back again.
>>>
>>> https://ide.csound.com/editor/CcCca1LfX6EndkffwMlG
>>>
>>> The perfect solution would be passing of a function pointer, since that's not yet in csound, I was hoping there was some sort of opcode which I could use, to define A in this example, and redefine it later?
>>>
>>> Also any workarounds appreciated!
>>>
>>> Cheers,
>>> Hlödver
>>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>
>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here