Csound Csound-dev Csound-tekno Search About

[Csnd-dev] default arguments for UDOs in new syntax

Date2025-07-29 19:14
Fromjoachim heintz
Subject[Csnd-dev] default arguments for UDOs in new syntax
in the old UDO syntax, we had opj etc for some default values of arguments.
is there something in the new UDO syntax?
i tried
	opcode test(arg1:i=1,arg2:i=13):void
but this did not work.

Date2025-07-29 19:35
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd-dev] [EXTERNAL] [Csnd-dev] default arguments for UDOs in new syntax
Defaults arguments are not implemented as far as I can see. 
This works - but I think it is a fluke.

opcode myop(var1:i,var2:p):void
print var1, var2
endop

Steven should be able to clarify. I’ll have a look at the code

========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 29 Jul 2025, at 19:14, joachim heintz  wrote:
> 
> *Warning*
> 
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> 
> in the old UDO syntax, we had opj etc for some default values of arguments.
> is there something in the new UDO syntax?
> i tried
>       opcode test(arg1:i=1,arg2:i=13):void
> but this did not work.


Date2025-07-29 20:48
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd-dev] [EXTERNAL] [Csnd-dev] default arguments for UDOs in new syntax
I’ve made a PR fixing this.
Optional types as per classic-style UDO are now allowed as types.

https://github.com/csound/csound/pull/2214

========================
Prof. Victor Lazzarini
Maynooth University
Ireland






> On 29 Jul 2025, at 19:35, Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE> wrote:
> 
> Defaults arguments are not implemented as far as I can see. 
> This works - but I think it is a fluke.
> 
> opcode myop(var1:i,var2:p):void
> print var1, var2
> endop
> 
> Steven should be able to clarify. I’ll have a look at the code
> 
> ========================
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
> 
>> On 29 Jul 2025, at 19:14, joachim heintz  wrote:
>> 
>> *Warning*
>> 
>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>> 
>> in the old UDO syntax, we had opj etc for some default values of arguments.
>> is there something in the new UDO syntax?
>> i tried
>>      opcode test(arg1:i=1,arg2:i=13):void
>> but this did not work.
> 


Date2025-07-29 21:51
FromEduardo Moguillansky
SubjectRe: [Csnd-dev] [EXTERNAL] [Csnd-dev] default arguments for UDOs in new syntax
The parser is an area of csound which I know nothing about. How far is it from being able to implement named arguments at the call site and, with that, arbitrary default arguments? 

On Tue, Jul 29, 2025 at 9:48 PM Victor Lazzarini <000010b17ddd988e-dmarc-request@listserv.heanet.ie> wrote:
I’ve made a PR fixing this.
Optional types as per classic-style UDO are now allowed as types.

https://github.com/csound/csound/pull/2214

========================
Prof. Victor Lazzarini
Maynooth University
Ireland






> On 29 Jul 2025, at 19:35, Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE> wrote:
>
> Defaults arguments are not implemented as far as I can see.
> This works - but I think it is a fluke.
>
> opcode myop(var1:i,var2:p):void
> print var1, var2
> endop
>
> Steven should be able to clarify. I’ll have a look at the code
>
> ========================
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
>> On 29 Jul 2025, at 19:14, joachim heintz <jh@JOACHIMHEINTZ.DE> wrote:
>>
>> *Warning*
>>
>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>>
>> in the old UDO syntax, we had opj etc for some default values of arguments.
>> is there something in the new UDO syntax?
>> i tried
>>      opcode test(arg1:i=1,arg2:i=13):void
>> but this did not work.
>


Date2025-07-29 22:50
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd-dev] [EXTERNAL] [Csnd-dev] default arguments for UDOs in new syntax
This fix is just to bring newstyle UDOs to the same level of functionality as the original form. I did not touch the parser per se, just adjusted the semantic analysis to accept and translate optional types into i or k, as needed.

To get a syntax like 

opcode myop(var:i=5) 

we need to insert a rule in the parser to look for that pattern, then add code in the semantic analysis to understand it, and then adapt the UDO inargs reading to understand it.

I have not looked into it to see how much work it is yet, so I can't really say. One thing I noticed is that the new parser is much easier to extend than the previous iteration.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 29 Jul 2025, at 17:51, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:


The parser is an area of csound which I know nothing about. How far is it from being able to implement named arguments at the call site and, with that, arbitrary default arguments? 

On Tue, Jul 29, 2025 at 9:48 PM Victor Lazzarini <000010b17ddd988e-dmarc-request@listserv.heanet.ie> wrote:
I’ve made a PR fixing this.
Optional types as per classic-style UDO are now allowed as types.

https://github.com/csound/csound/pull/2214

========================
Prof. Victor Lazzarini
Maynooth University
Ireland






> On 29 Jul 2025, at 19:35, Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE> wrote:
>
> Defaults arguments are not implemented as far as I can see.
> This works - but I think it is a fluke.
>
> opcode myop(var1:i,var2:p):void
> print var1, var2
> endop
>
> Steven should be able to clarify. I’ll have a look at the code
>
> ========================
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
>> On 29 Jul 2025, at 19:14, joachim heintz <jh@JOACHIMHEINTZ.DE> wrote:
>>
>> *Warning*
>>
>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>>
>> in the old UDO syntax, we had opj etc for some default values of arguments.
>> is there something in the new UDO syntax?
>> i tried
>>      opcode test(arg1:i=1,arg2:i=13):void
>> but this did not work.
>