Csound Csound-dev Csound-tekno Search About

[Cs-dev] Static Arrays Initializers

Date2015-03-10 04:49
FromSteven Yi
Subject[Cs-dev] Static Arrays Initializers
Hi All,

I just finished another addition to the feature/parser3 branch, which
is static array initializers.  This was something that was difficult
to implement in Csound 6, but was made simpler to do in parser3.

With the new change, it is possible to do:

kvals[] = [1,2,3]
Svals[] = ["1", "test", "45"]

as well as to create arrays as arguments to function calls, such as:

my_print(["test", "test2, "test3])

I have pasted a copy of the test CSD I used for implementing this.
The results when running this is:

instr 1:  #i1 = 10.000
instr 1:  #i1 = 20.000
instr 1:  #i1 = 30.000
Test test2 test 3
print_str_array: Test test2 test 3
print_str_array: I am an inline string array.

Note: I have only tested with this CSD.  Further test CSD's would be
very much appreciated.  I also noticed that some ambiguities have
crept into the report that Bison generates.  Currently all csdtests
pass, but I think the ambiguities will need some further looking into.

Cheers!
steven





opcode print_str_array(vals:S[]):void
  icounter = 0
  Sres = ""
  while (icounter < lenarray(vals)) do
    Sres = strcat(Sres, vals[icounter])
    icounter += 1
  od

  prints "print_str_array: "
  prints Sres
  prints "\n"
endop

instr 1
;create
SArr[] = [ "Test", " test2", " test 3"]
ivals[] = [10, 20, 30]

;print
icounter = 0
Sres = ""
while (icounter < 3) do
  print(ivals[icounter])
  Sres = strcat(Sres, SArr[icounter])
  icounter += 1
od
puts Sres, 1

print_str_array(SArr)

print_str_array(["I", " am", " an", " inline", " string", " array."])

endin



i1 0 0



------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-03-10 10:21
FromRory Walsh
SubjectRe: [Cs-dev] Static Arrays Initializers
Another nice addition Steven!

On 10 March 2015 at 04:49, Steven Yi  wrote:
> Hi All,
>
> I just finished another addition to the feature/parser3 branch, which
> is static array initializers.  This was something that was difficult
> to implement in Csound 6, but was made simpler to do in parser3.
>
> With the new change, it is possible to do:
>
> kvals[] = [1,2,3]
> Svals[] = ["1", "test", "45"]
>
> as well as to create arrays as arguments to function calls, such as:
>
> my_print(["test", "test2, "test3])
>
> I have pasted a copy of the test CSD I used for implementing this.
> The results when running this is:
>
> instr 1:  #i1 = 10.000
> instr 1:  #i1 = 20.000
> instr 1:  #i1 = 30.000
> Test test2 test 3
> print_str_array: Test test2 test 3
> print_str_array: I am an inline string array.
>
> Note: I have only tested with this CSD.  Further test CSD's would be
> very much appreciated.  I also noticed that some ambiguities have
> crept into the report that Bison generates.  Currently all csdtests
> pass, but I think the ambiguities will need some further looking into.
>
> Cheers!
> steven
>
>
> 
> 
>
> opcode print_str_array(vals:S[]):void
>   icounter = 0
>   Sres = ""
>   while (icounter < lenarray(vals)) do
>     Sres = strcat(Sres, vals[icounter])
>     icounter += 1
>   od
>
>   prints "print_str_array: "
>   prints Sres
>   prints "\n"
> endop
>
> instr 1
> ;create
> SArr[] = [ "Test", " test2", " test 3"]
> ivals[] = [10, 20, 30]
>
> ;print
> icounter = 0
> Sres = ""
> while (icounter < 3) do
>   print(ivals[icounter])
>   Sres = strcat(Sres, SArr[icounter])
>   icounter += 1
> od
> puts Sres, 1
>
> print_str_array(SArr)
>
> print_str_array(["I", " am", " an", " inline", " string", " array."])
>
> endin
>
> 
> 
> i1 0 0
> 
> 
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-03-10 22:29
Fromjoachim heintz
SubjectRe: [Cs-dev] Static Arrays Initializers
+1!!

Am 10.03.2015 um 11:21 schrieb Rory Walsh:
> Another nice addition Steven!
>
> On 10 March 2015 at 04:49, Steven Yi  wrote:
>> Hi All,
>>
>> I just finished another addition to the feature/parser3 branch, which
>> is static array initializers.  This was something that was difficult
>> to implement in Csound 6, but was made simpler to do in parser3.
>>
>> With the new change, it is possible to do:
>>
>> kvals[] = [1,2,3]
>> Svals[] = ["1", "test", "45"]
>>
>> as well as to create arrays as arguments to function calls, such as:
>>
>> my_print(["test", "test2, "test3])
>>
>> I have pasted a copy of the test CSD I used for implementing this.
>> The results when running this is:
>>
>> instr 1:  #i1 = 10.000
>> instr 1:  #i1 = 20.000
>> instr 1:  #i1 = 30.000
>> Test test2 test 3
>> print_str_array: Test test2 test 3
>> print_str_array: I am an inline string array.
>>
>> Note: I have only tested with this CSD.  Further test CSD's would be
>> very much appreciated.  I also noticed that some ambiguities have
>> crept into the report that Bison generates.  Currently all csdtests
>> pass, but I think the ambiguities will need some further looking into.
>>
>> Cheers!
>> steven
>>
>>
>> 
>> 
>>
>> opcode print_str_array(vals:S[]):void
>>    icounter = 0
>>    Sres = ""
>>    while (icounter < lenarray(vals)) do
>>      Sres = strcat(Sres, vals[icounter])
>>      icounter += 1
>>    od
>>
>>    prints "print_str_array: "
>>    prints Sres
>>    prints "\n"
>> endop
>>
>> instr 1
>> ;create
>> SArr[] = [ "Test", " test2", " test 3"]
>> ivals[] = [10, 20, 30]
>>
>> ;print
>> icounter = 0
>> Sres = ""
>> while (icounter < 3) do
>>    print(ivals[icounter])
>>    Sres = strcat(Sres, SArr[icounter])
>>    icounter += 1
>> od
>> puts Sres, 1
>>
>> print_str_array(SArr)
>>
>> print_str_array(["I", " am", " an", " inline", " string", " array."])
>>
>> endin
>>
>> 
>> 
>> i1 0 0
>> 
>> 
>>
>> ------------------------------------------------------------------------------
>> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
>> by Intel and developed in partnership with Slashdot Media, is your hub for all
>> things parallel software development, from weekly thought leadership blogs to
>> news, videos, case studies, tutorials and more. Take a look and join the
>> conversation now. http://goparallel.sourceforge.net/
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net