[Csnd] genarray is strange...

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Csnd] genarray is strange...

Mauro Giubileo

Hi, this code generates an array of 128 elements and then prints its size (128):

instr 1
    iArr[]  genarray    1, 128
            printk      1, lenarray(iArr)
endin

But this k-time version prints -1... Why?

instr 1
    kArr[]  genarray    1, 128
            printk      1, lenarray(kArr)
endin


Best Regards,
Mauro


Csound mailing list [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] genarray is strange...

Victor Lazzarini-2
Because you are using the i-rate version of the function, as
printk has no way of selecting k- or i-rate versions, so it defaults to i-rate
To select the desired overload use a hint (:k)

 lenarray:k(kArr)

or use the opcode form rather the function form

 klen lenarray kArr
         printk      1, klen

where the correct overload is chosen. This is how the type system
in Csound 6 currently works. It is discussed in the Csound springer book.

best
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 2 Oct 2018, at 14:22, Mauro Giubileo <[hidden email]> wrote:
>
> Hi, this code generates an array of 128 elements and then prints its size (128):
>
> instr 1
>     iArr[]  genarray    1, 128
>             printk      1, lenarray(iArr)
> endin
>
> But this k-time version prints -1... Why?
>
> instr 1
>     kArr[]  genarray    1, 128
>             printk      1, lenarray(kArr)
> endin
>
>
> Best Regards,
> Mauro
>
>
>
> Csound mailing list [hidden email] 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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] genarray is strange...

Mauro Giubileo

Oh, right... I always tend to forget to add the hint (:k) in such situations when I use the function syntax. Thanks!

P.S.: I don't know if it is feasible, but I think it would be very nice if in such situations Csound could give you a "warning" in the console output to make the user know that the parser doesn't know what rate version of a function it should use and so it defaults to the i-rate one.


Best Regards,
Mauro

 


Il 2018-10-02 16:38 Victor Lazzarini ha scritto:

Because you are using the i-rate version of the function, as
printk has no way of selecting k- or i-rate versions, so it defaults to i-rate
To select the desired overload use a hint (:k)

 lenarray:k(kArr)

or use the opcode form rather the function form

 klen lenarray kArr
         printk      1, klen

where the correct overload is chosen. This is how the type system
in Csound 6 currently works. It is discussed in the Csound springer book.

best
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

On 2 Oct 2018, at 14:22, Mauro Giubileo <[hidden email]> wrote:

Hi, this code generates an array of 128 elements and then prints its size (128):

instr 1
    iArr[]  genarray    1, 128
            printk      1, lenarray(iArr)
endin

But this k-time version prints -1... Why?

instr 1
    kArr[]  genarray    1, 128
            printk      1, lenarray(kArr)
endin


Best Regards,
Mauro



Csound mailing list [hidden email] 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
[hidden email]
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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] genarray is strange...

Victor Lazzarini-2
If we were able to detect what rate was required then we would just select the right opcode, so
a warning then would not be needed.
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 2 Oct 2018, at 16:02, Mauro Giubileo <[hidden email]> wrote:
>
> Oh, right... I always tend to forget to add the hint (:k) in such situations when I use the function syntax. Thanks!
>
> P.S.: I don't know if it is feasible, but I think it would be very nice if in such situations Csound could give you a "warning" in the console output to make the user know that the parser doesn't know what rate version of a function it should use and so it defaults to the i-rate one.
>
>
> Best Regards,
> Mauro
>
>  
>
>
> Il 2018-10-02 16:38 Victor Lazzarini ha scritto:
>
>> Because you are using the i-rate version of the function, as
>> printk has no way of selecting k- or i-rate versions, so it defaults to i-rate
>> To select the desired overload use a hint (:k)
>>
>>  lenarray:k(kArr)
>>
>> or use the opcode form rather the function form
>>
>>  klen lenarray kArr
>>          printk      1, klen
>>
>> where the correct overload is chosen. This is how the type system
>> in Csound 6 currently works. It is discussed in the Csound springer book.
>>
>> best
>> ========================
>> Prof. Victor Lazzarini
>> Dean of Arts, Celtic Studies, and Philosophy,
>> Maynooth University,
>> Maynooth, Co Kildare, Ireland
>> Tel: 00 353 7086936
>> Fax: 00 353 1 7086952
>>
>>> On 2 Oct 2018, at 14:22, Mauro Giubileo <[hidden email]> wrote:
>>>
>>> Hi, this code generates an array of 128 elements and then prints its size (128):
>>>
>>> instr 1
>>>     iArr[]  genarray    1, 128
>>>             printk      1, lenarray(iArr)
>>> endin
>>>
>>> But this k-time version prints -1... Why?
>>>
>>> instr 1
>>>     kArr[]  genarray    1, 128
>>>             printk      1, lenarray(kArr)
>>> endin
>>>
>>>
>>> Best Regards,
>>> Mauro
>>>
>>>
>>>
>>> Csound mailing list [hidden email] 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
>> [hidden email]
>> 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 [hidden email] 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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] genarray is strange...

Mauro Giubileo

Yes, that would be better, but I don't know if it is always possible to detect the right rate the user want.


Il 2018-10-02 18:05 Victor Lazzarini ha scritto:

If we were able to detect what rate was required then we would just select the right opcode, so
a warning then would not be needed.
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

On 2 Oct 2018, at 16:02, Mauro Giubileo <[hidden email]> wrote:

Oh, right... I always tend to forget to add the hint (:k) in such situations when I use the function syntax. Thanks!

P.S.: I don't know if it is feasible, but I think it would be very nice if in such situations Csound could give you a "warning" in the console output to make the user know that the parser doesn't know what rate version of a function it should use and so it defaults to the i-rate one.


Best Regards,
Mauro

 


Il 2018-10-02 16:38 Victor Lazzarini ha scritto:

Because you are using the i-rate version of the function, as
printk has no way of selecting k- or i-rate versions, so it defaults to i-rate
To select the desired overload use a hint (:k)

 lenarray:k(kArr)

or use the opcode form rather the function form

 klen lenarray kArr
         printk      1, klen

where the correct overload is chosen. This is how the type system
in Csound 6 currently works. It is discussed in the Csound springer book.

best
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

On 2 Oct 2018, at 14:22, Mauro Giubileo <[hidden email]> wrote:

Hi, this code generates an array of 128 elements and then prints its size (128):

instr 1
    iArr[]  genarray    1, 128
            printk      1, lenarray(iArr)
endin

But this k-time version prints -1... Why?

instr 1
    kArr[]  genarray    1, 128
            printk      1, lenarray(kArr)
endin


Best Regards,
Mauro



Csound mailing list [hidden email] 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
[hidden email]
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 [hidden email] 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
[hidden email]
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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] genarray is strange...

Victor Lazzarini-2
That's my point, without the extra annotation, it is not possible. Therefore we can't display a warning, because there might be nothing wrong with the code, and it
would be extremely annoying to the user.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 2 Oct 2018, at 18:47, Mauro Giubileo <[hidden email]> wrote:

Yes, that would be better, but I don't know if it is always possible to detect the right rate the user want.


Il 2018-10-02 18:05 Victor Lazzarini ha scritto:

If we were able to detect what rate was required then we would just select the right opcode, so
a warning then would not be needed.
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

On 2 Oct 2018, at 16:02, Mauro Giubileo <[hidden email]> wrote:

Oh, right... I always tend to forget to add the hint (:k) in such situations when I use the function syntax. Thanks!

P.S.: I don't know if it is feasible, but I think it would be very nice if in such situations Csound could give you a "warning" in the console output to make the user know that the parser doesn't know what rate version of a function it should use and so it defaults to the i-rate one.


Best Regards,
Mauro

 


Il 2018-10-02 16:38 Victor Lazzarini ha scritto:

Because you are using the i-rate version of the function, as
printk has no way of selecting k- or i-rate versions, so it defaults to i-rate
To select the desired overload use a hint (:k)

 lenarray:k(kArr)

or use the opcode form rather the function form

 klen lenarray kArr
         printk      1, klen

where the correct overload is chosen. This is how the type system
in Csound 6 currently works. It is discussed in the Csound springer book.

best
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

On 2 Oct 2018, at 14:22, Mauro Giubileo <[hidden email]> wrote:

Hi, this code generates an array of 128 elements and then prints its size (128):

instr 1
    iArr[]  genarray    1, 128
            printk      1, lenarray(iArr)
endin

But this k-time version prints -1... Why?

instr 1
    kArr[]  genarray    1, 128
            printk      1, lenarray(kArr)
endin


Best Regards,
Mauro



Csound mailing list [hidden email] 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
[hidden email]
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 [hidden email] 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
[hidden email]
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 [hidden email] 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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] genarray is strange...

Mauro Giubileo

Maybe with a flag to make the user choice if he wants the warnings? Something like "-noRateWarnings" ?


Il 2018-10-02 20:31 Victor Lazzarini ha scritto:

That's my point, without the extra annotation, it is not possible. Therefore we can't display a warning, because there might be nothing wrong with the code, and it
would be extremely annoying to the user.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 2 Oct 2018, at 18:47, Mauro Giubileo <[hidden email]> wrote:

Yes, that would be better, but I don't know if it is always possible to detect the right rate the user want.


Il 2018-10-02 18:05 Victor Lazzarini ha scritto:

If we were able to detect what rate was required then we would just select the right opcode, so
a warning then would not be needed.
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

On 2 Oct 2018, at 16:02, Mauro Giubileo <[hidden email]> wrote:

Oh, right... I always tend to forget to add the hint (:k) in such situations when I use the function syntax. Thanks!

P.S.: I don't know if it is feasible, but I think it would be very nice if in such situations Csound could give you a "warning" in the console output to make the user know that the parser doesn't know what rate version of a function it should use and so it defaults to the i-rate one.


Best Regards,
Mauro

 


Il 2018-10-02 16:38 Victor Lazzarini ha scritto:

Because you are using the i-rate version of the function, as
printk has no way of selecting k- or i-rate versions, so it defaults to i-rate
To select the desired overload use a hint (:k)

 lenarray:k(kArr)

or use the opcode form rather the function form

 klen lenarray kArr
         printk      1, klen

where the correct overload is chosen. This is how the type system
in Csound 6 currently works. It is discussed in the Csound springer book.

best
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

On 2 Oct 2018, at 14:22, Mauro Giubileo <[hidden email]> wrote:

Hi, this code generates an array of 128 elements and then prints its size (128):

instr 1
    iArr[]  genarray    1, 128
            printk      1, lenarray(iArr)
endin

But this k-time version prints -1... Why?

instr 1
    kArr[]  genarray    1, 128
            printk      1, lenarray(kArr)
endin


Best Regards,
Mauro



Csound mailing list [hidden email] 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
[hidden email]
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 [hidden email] 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
[hidden email]
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 [hidden email] 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 [hidden email] 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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] genarray is strange...

Mauro Giubileo
In reply to this post by Mauro Giubileo

Another problem on genarray... This works:

kArr[]  genarray    1, 128
        printk      1, lenarray:k(kArr)

But this gives to me an error message in the console output:

kArr[]  =           genarray:k(1, 128)
        printk      1, lenarray:k(kArr)

What I missed this time? Genarray should have i-time and k-time versions...

Regards,
Mauro


Il 2018-10-02 17:02 Mauro Giubileo ha scritto:

Oh, right... I always tend to forget to add the hint (:k) in such situations when I use the function syntax. Thanks!

P.S.: I don't know if it is feasible, but I think it would be very nice if in such situations Csound could give you a "warning" in the console output to make the user know that the parser doesn't know what rate version of a function it should use and so it defaults to the i-rate one.


Best Regards,
Mauro

 


Il 2018-10-02 16:38 Victor Lazzarini ha scritto:

Because you are using the i-rate version of the function, as
printk has no way of selecting k- or i-rate versions, so it defaults to i-rate
To select the desired overload use a hint (:k)

 lenarray:k(kArr)

or use the opcode form rather the function form

 klen lenarray kArr
         printk      1, klen

where the correct overload is chosen. This is how the type system
in Csound 6 currently works. It is discussed in the Csound springer book.

best
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

On 2 Oct 2018, at 14:22, Mauro Giubileo <[hidden email]> wrote:

Hi, this code generates an array of 128 elements and then prints its size (128):

instr 1
    iArr[]  genarray    1, 128
            printk      1, lenarray(iArr)
endin

But this k-time version prints -1... Why?

instr 1
    kArr[]  genarray    1, 128
            printk      1, lenarray(kArr)
endin


Best Regards,
Mauro



Csound mailing list [hidden email] 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
[hidden email]
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 [hidden email] 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 [hidden email] 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