Csound Csound-dev Csound-tekno Search About

[Csnd] genarray is strange...

Date2018-10-02 14:22
FromMauro Giubileo
Subject[Csnd] genarray is strange...

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



Date2018-10-02 15:38
FromVictor Lazzarini
SubjectRe: [Csnd] genarray is strange...
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  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 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

Date2018-10-02 16:02
FromMauro Giubileo
SubjectRe: [Csnd] genarray is strange...

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 <mgiubileo@COMPUTERALTAFED.IT> 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 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

Date2018-10-02 17:05
FromVictor Lazzarini
SubjectRe: [Csnd] genarray is strange...
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  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  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 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

Date2018-10-02 18:47
FromMauro Giubileo
SubjectRe: [Csnd] genarray is strange...

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 <mgiubileo@COMPUTERALTAFED.IT> 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 <mgiubileo@COMPUTERALTAFED.IT> 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 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

Date2018-10-02 19:31
FromVictor Lazzarini
SubjectRe: [Csnd] genarray is strange...
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 <mgiubileo@COMPUTERALTAFED.IT> 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 <mgiubileo@COMPUTERALTAFED.IT> 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 <mgiubileo@COMPUTERALTAFED.IT> 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 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

Date2018-10-02 19:51
FromMauro Giubileo
SubjectRe: [Csnd] genarray is strange...

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 <mgiubileo@COMPUTERALTAFED.IT> 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 <mgiubileo@COMPUTERALTAFED.IT> 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 <mgiubileo@COMPUTERALTAFED.IT> 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 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

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


Date2018-10-03 16:52
FromMauro Giubileo
SubjectRe: [Csnd] genarray is strange...

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 <mgiubileo@COMPUTERALTAFED.IT> 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 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