Csound Csound-dev Csound-tekno Search About

[Cs-dev] User-Defined Types (Structs)

Date2015-02-19 05:23
FromSteven Yi
Subject[Cs-dev] User-Defined Types (Structs)
Hi All,

I've been working away in the feature/parser3 branch and have just
gotten through implementing the basics for user-defined types
(structs). The example code pasted below shows:

1. defining a struct type called MyType
2. Use of explicit and implicit typed member vars
3. Using init to create a MyType
4. setting and updating of MyType member vars

To note, the way compilation is done, the members of structs are used
directly.  So the init and printks function calls have their argument
pointers pointing directly into the memory allocated for the struct
var.  This all type checks correctly and run-time type identification
should all be working as I'm using CS_VAR_MEM's to store data.

The next step here is to get structs working with UDO's.  However,
I've run up against a design issue.  UDO's do not have a good way to
modify how their arguments should be specified when it comes to in-
and out-args. I think we will need a new way to define UDO's to
accommodate different kinds of types.  I'm currently thinking we
should create an additional way to define UDO's, one that is more
flexible in regards to var types.  What I am thinking is something
like:

opcode processMyType(inValue:MyType, kval1, kval2):MyType
  retVal:MyType = inValue
  retVal.imaginary *= kval1
  reVal.real *= kval2
  return retVal
endop

What this would do is specify both the input argument names as well as
types at the same time, as well as specify the output type.  The
parser then would be responsible for generating the correct inarg and
outarg strings for the generated OENTRY (something like ":MyType;"
and  ":MyType;kk").  The compiler would then also insert a line for a
generated "xin" call with the types, as well as replace the "return"
with "xout".  (return would just be an alias for xout then).  One
thing though is that return would also be sure to type check against
the specified out-type.

I'm going to proceed with implementing the newer UDO definition as
above for now, just so that I can keep on moving forward with the
implementation.  However, the syntax for the above or the work on
structs so far is not set in stone.  Any comments appreciated.

Thanks,
steven


== STRUCT EXAMPLE ==




sr = 44100
ksmps = 1
nchnls = 2
0dbfs = 1

struct MyType imaginary:k, real:k, kimaginary, kreal

instr 1

var0:MyType init 1, 2, 3, 4
;var1:MyType = init:MyType(0, 0, 1, 1)

var0.imaginary init 5
var0.real init 6
var0.kimaginary init 7
var0.kreal init 9

var0.imaginary += 1
var0.real += 2
var0.kimaginary += 3
var0.kreal += 4

printks "i %d r %d ki %d kr %d\n", 0.2, var0.imaginary, var0.real,
var0.kimaginary, var0.kreal

endin


; ==============================================

i1 0 0.5





------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-02-19 16:37
FromRory Walsh
SubjectRe: [Cs-dev] User-Defined Types (Structs)
This sounds very interesting Steven. I'm eagerly following your
progress. Is the syntax you are proposing regarding UDOs as follows:

opcode opcodeName(in types....):out type

endop

If that's wrong, what is going on after the colon at the end of the
parenthesis?

On 19 February 2015 at 05:23, Steven Yi  wrote:
> Hi All,
>
> I've been working away in the feature/parser3 branch and have just
> gotten through implementing the basics for user-defined types
> (structs). The example code pasted below shows:
>
> 1. defining a struct type called MyType
> 2. Use of explicit and implicit typed member vars
> 3. Using init to create a MyType
> 4. setting and updating of MyType member vars
>
> To note, the way compilation is done, the members of structs are used
> directly.  So the init and printks function calls have their argument
> pointers pointing directly into the memory allocated for the struct
> var.  This all type checks correctly and run-time type identification
> should all be working as I'm using CS_VAR_MEM's to store data.
>
> The next step here is to get structs working with UDO's.  However,
> I've run up against a design issue.  UDO's do not have a good way to
> modify how their arguments should be specified when it comes to in-
> and out-args. I think we will need a new way to define UDO's to
> accommodate different kinds of types.  I'm currently thinking we
> should create an additional way to define UDO's, one that is more
> flexible in regards to var types.  What I am thinking is something
> like:
>
> opcode processMyType(inValue:MyType, kval1, kval2):MyType
>   retVal:MyType = inValue
>   retVal.imaginary *= kval1
>   reVal.real *= kval2
>   return retVal
> endop
>
> What this would do is specify both the input argument names as well as
> types at the same time, as well as specify the output type.  The
> parser then would be responsible for generating the correct inarg and
> outarg strings for the generated OENTRY (something like ":MyType;"
> and  ":MyType;kk").  The compiler would then also insert a line for a
> generated "xin" call with the types, as well as replace the "return"
> with "xout".  (return would just be an alias for xout then).  One
> thing though is that return would also be sure to type check against
> the specified out-type.
>
> I'm going to proceed with implementing the newer UDO definition as
> above for now, just so that I can keep on moving forward with the
> implementation.  However, the syntax for the above or the work on
> structs so far is not set in stone.  Any comments appreciated.
>
> Thanks,
> steven
>
>
> == STRUCT EXAMPLE ==
>
> 
> 
>
> sr = 44100
> ksmps = 1
> nchnls = 2
> 0dbfs = 1
>
> struct MyType imaginary:k, real:k, kimaginary, kreal
>
> instr 1
>
> var0:MyType init 1, 2, 3, 4
> ;var1:MyType = init:MyType(0, 0, 1, 1)
>
> var0.imaginary init 5
> var0.real init 6
> var0.kimaginary init 7
> var0.kreal init 9
>
> var0.imaginary += 1
> var0.real += 2
> var0.kimaginary += 3
> var0.kreal += 4
>
> printks "i %d r %d ki %d kr %d\n", 0.2, var0.imaginary, var0.real,
> var0.kimaginary, var0.kreal
>
> endin
>
> 
> ; ==============================================
> 
> i1 0 0.5
>
>
> 
> 
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-02-19 16:44
FromSteven Yi
SubjectRe: [Cs-dev] User-Defined Types (Structs)
You got it right there Rory.  Within parentheses would be in args, and
the  last part is the out type.  One thing though is that Csound
allows multiple outs, so maybe it would have to be something like
this:

opcode myOpcode(in_types):(out_types)

endop

To work with multiple outs.  I'll go with this and see what happens.
Once the infrastructure is there, it's easy enough to change the
syntax.

On Thu, Feb 19, 2015 at 11:37 AM, Rory Walsh  wrote:
> This sounds very interesting Steven. I'm eagerly following your
> progress. Is the syntax you are proposing regarding UDOs as follows:
>
> opcode opcodeName(in types....):out type
>
> endop
>
> If that's wrong, what is going on after the colon at the end of the
> parenthesis?
>
> On 19 February 2015 at 05:23, Steven Yi  wrote:
>> Hi All,
>>
>> I've been working away in the feature/parser3 branch and have just
>> gotten through implementing the basics for user-defined types
>> (structs). The example code pasted below shows:
>>
>> 1. defining a struct type called MyType
>> 2. Use of explicit and implicit typed member vars
>> 3. Using init to create a MyType
>> 4. setting and updating of MyType member vars
>>
>> To note, the way compilation is done, the members of structs are used
>> directly.  So the init and printks function calls have their argument
>> pointers pointing directly into the memory allocated for the struct
>> var.  This all type checks correctly and run-time type identification
>> should all be working as I'm using CS_VAR_MEM's to store data.
>>
>> The next step here is to get structs working with UDO's.  However,
>> I've run up against a design issue.  UDO's do not have a good way to
>> modify how their arguments should be specified when it comes to in-
>> and out-args. I think we will need a new way to define UDO's to
>> accommodate different kinds of types.  I'm currently thinking we
>> should create an additional way to define UDO's, one that is more
>> flexible in regards to var types.  What I am thinking is something
>> like:
>>
>> opcode processMyType(inValue:MyType, kval1, kval2):MyType
>>   retVal:MyType = inValue
>>   retVal.imaginary *= kval1
>>   reVal.real *= kval2
>>   return retVal
>> endop
>>
>> What this would do is specify both the input argument names as well as
>> types at the same time, as well as specify the output type.  The
>> parser then would be responsible for generating the correct inarg and
>> outarg strings for the generated OENTRY (something like ":MyType;"
>> and  ":MyType;kk").  The compiler would then also insert a line for a
>> generated "xin" call with the types, as well as replace the "return"
>> with "xout".  (return would just be an alias for xout then).  One
>> thing though is that return would also be sure to type check against
>> the specified out-type.
>>
>> I'm going to proceed with implementing the newer UDO definition as
>> above for now, just so that I can keep on moving forward with the
>> implementation.  However, the syntax for the above or the work on
>> structs so far is not set in stone.  Any comments appreciated.
>>
>> Thanks,
>> steven
>>
>>
>> == STRUCT EXAMPLE ==
>>
>> 
>> 
>>
>> sr = 44100
>> ksmps = 1
>> nchnls = 2
>> 0dbfs = 1
>>
>> struct MyType imaginary:k, real:k, kimaginary, kreal
>>
>> instr 1
>>
>> var0:MyType init 1, 2, 3, 4
>> ;var1:MyType = init:MyType(0, 0, 1, 1)
>>
>> var0.imaginary init 5
>> var0.real init 6
>> var0.kimaginary init 7
>> var0.kreal init 9
>>
>> var0.imaginary += 1
>> var0.real += 2
>> var0.kimaginary += 3
>> var0.kreal += 4
>>
>> printks "i %d r %d ki %d kr %d\n", 0.2, var0.imaginary, var0.real,
>> var0.kimaginary, var0.kreal
>>
>> endin
>>
>> 
>> ; ==============================================
>> 
>> i1 0 0.5
>>
>>
>> 
>> 
>>
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-02-19 16:48
FromMichael Gogins
SubjectRe: [Cs-dev] User-Defined Types (Structs)
Yes, I think ():() is good.

Best,
Mike

-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Thu, Feb 19, 2015 at 11:44 AM, Steven Yi  wrote:
> You got it right there Rory.  Within parentheses would be in args, and
> the  last part is the out type.  One thing though is that Csound
> allows multiple outs, so maybe it would have to be something like
> this:
>
> opcode myOpcode(in_types):(out_types)
>
> endop
>
> To work with multiple outs.  I'll go with this and see what happens.
> Once the infrastructure is there, it's easy enough to change the
> syntax.
>
> On Thu, Feb 19, 2015 at 11:37 AM, Rory Walsh  wrote:
>> This sounds very interesting Steven. I'm eagerly following your
>> progress. Is the syntax you are proposing regarding UDOs as follows:
>>
>> opcode opcodeName(in types....):out type
>>
>> endop
>>
>> If that's wrong, what is going on after the colon at the end of the
>> parenthesis?
>>
>> On 19 February 2015 at 05:23, Steven Yi  wrote:
>>> Hi All,
>>>
>>> I've been working away in the feature/parser3 branch and have just
>>> gotten through implementing the basics for user-defined types
>>> (structs). The example code pasted below shows:
>>>
>>> 1. defining a struct type called MyType
>>> 2. Use of explicit and implicit typed member vars
>>> 3. Using init to create a MyType
>>> 4. setting and updating of MyType member vars
>>>
>>> To note, the way compilation is done, the members of structs are used
>>> directly.  So the init and printks function calls have their argument
>>> pointers pointing directly into the memory allocated for the struct
>>> var.  This all type checks correctly and run-time type identification
>>> should all be working as I'm using CS_VAR_MEM's to store data.
>>>
>>> The next step here is to get structs working with UDO's.  However,
>>> I've run up against a design issue.  UDO's do not have a good way to
>>> modify how their arguments should be specified when it comes to in-
>>> and out-args. I think we will need a new way to define UDO's to
>>> accommodate different kinds of types.  I'm currently thinking we
>>> should create an additional way to define UDO's, one that is more
>>> flexible in regards to var types.  What I am thinking is something
>>> like:
>>>
>>> opcode processMyType(inValue:MyType, kval1, kval2):MyType
>>>   retVal:MyType = inValue
>>>   retVal.imaginary *= kval1
>>>   reVal.real *= kval2
>>>   return retVal
>>> endop
>>>
>>> What this would do is specify both the input argument names as well as
>>> types at the same time, as well as specify the output type.  The
>>> parser then would be responsible for generating the correct inarg and
>>> outarg strings for the generated OENTRY (something like ":MyType;"
>>> and  ":MyType;kk").  The compiler would then also insert a line for a
>>> generated "xin" call with the types, as well as replace the "return"
>>> with "xout".  (return would just be an alias for xout then).  One
>>> thing though is that return would also be sure to type check against
>>> the specified out-type.
>>>
>>> I'm going to proceed with implementing the newer UDO definition as
>>> above for now, just so that I can keep on moving forward with the
>>> implementation.  However, the syntax for the above or the work on
>>> structs so far is not set in stone.  Any comments appreciated.
>>>
>>> Thanks,
>>> steven
>>>
>>>
>>> == STRUCT EXAMPLE ==
>>>
>>> 
>>> 
>>>
>>> sr = 44100
>>> ksmps = 1
>>> nchnls = 2
>>> 0dbfs = 1
>>>
>>> struct MyType imaginary:k, real:k, kimaginary, kreal
>>>
>>> instr 1
>>>
>>> var0:MyType init 1, 2, 3, 4
>>> ;var1:MyType = init:MyType(0, 0, 1, 1)
>>>
>>> var0.imaginary init 5
>>> var0.real init 6
>>> var0.kimaginary init 7
>>> var0.kreal init 9
>>>
>>> var0.imaginary += 1
>>> var0.real += 2
>>> var0.kimaginary += 3
>>> var0.kreal += 4
>>>
>>> printks "i %d r %d ki %d kr %d\n", 0.2, var0.imaginary, var0.real,
>>> var0.kimaginary, var0.kreal
>>>
>>> endin
>>>
>>> 
>>> ; ==============================================
>>> 
>>> i1 0 0.5
>>>
>>>
>>> 
>>> 
>>>
>>> ------------------------------------------------------------------------------
>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>> Get technology previously reserved for billion-dollar corporations, FREE
>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-02-19 16:56
FromRory Walsh
SubjectRe: [Cs-dev] User-Defined Types (Structs)
This looks tidy. Cool.

On 19 February 2015 at 16:48, Michael Gogins  wrote:
> Yes, I think ():() is good.
>
> Best,
> Mike
>
> -----------------------------------------------------
> Michael Gogins
> Irreducible Productions
> http://michaelgogins.tumblr.com
> Michael dot Gogins at gmail dot com
>
>
> On Thu, Feb 19, 2015 at 11:44 AM, Steven Yi  wrote:
>> You got it right there Rory.  Within parentheses would be in args, and
>> the  last part is the out type.  One thing though is that Csound
>> allows multiple outs, so maybe it would have to be something like
>> this:
>>
>> opcode myOpcode(in_types):(out_types)
>>
>> endop
>>
>> To work with multiple outs.  I'll go with this and see what happens.
>> Once the infrastructure is there, it's easy enough to change the
>> syntax.
>>
>> On Thu, Feb 19, 2015 at 11:37 AM, Rory Walsh  wrote:
>>> This sounds very interesting Steven. I'm eagerly following your
>>> progress. Is the syntax you are proposing regarding UDOs as follows:
>>>
>>> opcode opcodeName(in types....):out type
>>>
>>> endop
>>>
>>> If that's wrong, what is going on after the colon at the end of the
>>> parenthesis?
>>>
>>> On 19 February 2015 at 05:23, Steven Yi  wrote:
>>>> Hi All,
>>>>
>>>> I've been working away in the feature/parser3 branch and have just
>>>> gotten through implementing the basics for user-defined types
>>>> (structs). The example code pasted below shows:
>>>>
>>>> 1. defining a struct type called MyType
>>>> 2. Use of explicit and implicit typed member vars
>>>> 3. Using init to create a MyType
>>>> 4. setting and updating of MyType member vars
>>>>
>>>> To note, the way compilation is done, the members of structs are used
>>>> directly.  So the init and printks function calls have their argument
>>>> pointers pointing directly into the memory allocated for the struct
>>>> var.  This all type checks correctly and run-time type identification
>>>> should all be working as I'm using CS_VAR_MEM's to store data.
>>>>
>>>> The next step here is to get structs working with UDO's.  However,
>>>> I've run up against a design issue.  UDO's do not have a good way to
>>>> modify how their arguments should be specified when it comes to in-
>>>> and out-args. I think we will need a new way to define UDO's to
>>>> accommodate different kinds of types.  I'm currently thinking we
>>>> should create an additional way to define UDO's, one that is more
>>>> flexible in regards to var types.  What I am thinking is something
>>>> like:
>>>>
>>>> opcode processMyType(inValue:MyType, kval1, kval2):MyType
>>>>   retVal:MyType = inValue
>>>>   retVal.imaginary *= kval1
>>>>   reVal.real *= kval2
>>>>   return retVal
>>>> endop
>>>>
>>>> What this would do is specify both the input argument names as well as
>>>> types at the same time, as well as specify the output type.  The
>>>> parser then would be responsible for generating the correct inarg and
>>>> outarg strings for the generated OENTRY (something like ":MyType;"
>>>> and  ":MyType;kk").  The compiler would then also insert a line for a
>>>> generated "xin" call with the types, as well as replace the "return"
>>>> with "xout".  (return would just be an alias for xout then).  One
>>>> thing though is that return would also be sure to type check against
>>>> the specified out-type.
>>>>
>>>> I'm going to proceed with implementing the newer UDO definition as
>>>> above for now, just so that I can keep on moving forward with the
>>>> implementation.  However, the syntax for the above or the work on
>>>> structs so far is not set in stone.  Any comments appreciated.
>>>>
>>>> Thanks,
>>>> steven
>>>>
>>>>
>>>> == STRUCT EXAMPLE ==
>>>>
>>>> 
>>>> 
>>>>
>>>> sr = 44100
>>>> ksmps = 1
>>>> nchnls = 2
>>>> 0dbfs = 1
>>>>
>>>> struct MyType imaginary:k, real:k, kimaginary, kreal
>>>>
>>>> instr 1
>>>>
>>>> var0:MyType init 1, 2, 3, 4
>>>> ;var1:MyType = init:MyType(0, 0, 1, 1)
>>>>
>>>> var0.imaginary init 5
>>>> var0.real init 6
>>>> var0.kimaginary init 7
>>>> var0.kreal init 9
>>>>
>>>> var0.imaginary += 1
>>>> var0.real += 2
>>>> var0.kimaginary += 3
>>>> var0.kreal += 4
>>>>
>>>> printks "i %d r %d ki %d kr %d\n", 0.2, var0.imaginary, var0.real,
>>>> var0.kimaginary, var0.kreal
>>>>
>>>> endin
>>>>
>>>> 
>>>> ; ==============================================
>>>> 
>>>> i1 0 0.5
>>>>
>>>>
>>>> 
>>>> 
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>> ------------------------------------------------------------------------------
>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>> Get technology previously reserved for billion-dollar corporations, FREE
>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-02-19 19:09
FromVictor Lazzarini
SubjectRe: [Cs-dev] User-Defined Types (Structs)
It would be nice to adopt this syntax for all cases and deprecate the old one (but keep it for backwards compat.)

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

> On 19 Feb 2015, at 16:56, Rory Walsh  wrote:
> 
> This looks tidy. Cool.
> 
>> On 19 February 2015 at 16:48, Michael Gogins  wrote:
>> Yes, I think ():() is good.
>> 
>> Best,
>> Mike
>> 
>> -----------------------------------------------------
>> Michael Gogins
>> Irreducible Productions
>> http://michaelgogins.tumblr.com
>> Michael dot Gogins at gmail dot com
>> 
>> 
>>> On Thu, Feb 19, 2015 at 11:44 AM, Steven Yi  wrote:
>>> You got it right there Rory.  Within parentheses would be in args, and
>>> the  last part is the out type.  One thing though is that Csound
>>> allows multiple outs, so maybe it would have to be something like
>>> this:
>>> 
>>> opcode myOpcode(in_types):(out_types)
>>> 
>>> endop
>>> 
>>> To work with multiple outs.  I'll go with this and see what happens.
>>> Once the infrastructure is there, it's easy enough to change the
>>> syntax.
>>> 
>>>> On Thu, Feb 19, 2015 at 11:37 AM, Rory Walsh  wrote:
>>>> This sounds very interesting Steven. I'm eagerly following your
>>>> progress. Is the syntax you are proposing regarding UDOs as follows:
>>>> 
>>>> opcode opcodeName(in types....):out type
>>>> 
>>>> endop
>>>> 
>>>> If that's wrong, what is going on after the colon at the end of the
>>>> parenthesis?
>>>> 
>>>>> On 19 February 2015 at 05:23, Steven Yi  wrote:
>>>>> Hi All,
>>>>> 
>>>>> I've been working away in the feature/parser3 branch and have just
>>>>> gotten through implementing the basics for user-defined types
>>>>> (structs). The example code pasted below shows:
>>>>> 
>>>>> 1. defining a struct type called MyType
>>>>> 2. Use of explicit and implicit typed member vars
>>>>> 3. Using init to create a MyType
>>>>> 4. setting and updating of MyType member vars
>>>>> 
>>>>> To note, the way compilation is done, the members of structs are used
>>>>> directly.  So the init and printks function calls have their argument
>>>>> pointers pointing directly into the memory allocated for the struct
>>>>> var.  This all type checks correctly and run-time type identification
>>>>> should all be working as I'm using CS_VAR_MEM's to store data.
>>>>> 
>>>>> The next step here is to get structs working with UDO's.  However,
>>>>> I've run up against a design issue.  UDO's do not have a good way to
>>>>> modify how their arguments should be specified when it comes to in-
>>>>> and out-args. I think we will need a new way to define UDO's to
>>>>> accommodate different kinds of types.  I'm currently thinking we
>>>>> should create an additional way to define UDO's, one that is more
>>>>> flexible in regards to var types.  What I am thinking is something
>>>>> like:
>>>>> 
>>>>> opcode processMyType(inValue:MyType, kval1, kval2):MyType
>>>>>  retVal:MyType = inValue
>>>>>  retVal.imaginary *= kval1
>>>>>  reVal.real *= kval2
>>>>>  return retVal
>>>>> endop
>>>>> 
>>>>> What this would do is specify both the input argument names as well as
>>>>> types at the same time, as well as specify the output type.  The
>>>>> parser then would be responsible for generating the correct inarg and
>>>>> outarg strings for the generated OENTRY (something like ":MyType;"
>>>>> and  ":MyType;kk").  The compiler would then also insert a line for a
>>>>> generated "xin" call with the types, as well as replace the "return"
>>>>> with "xout".  (return would just be an alias for xout then).  One
>>>>> thing though is that return would also be sure to type check against
>>>>> the specified out-type.
>>>>> 
>>>>> I'm going to proceed with implementing the newer UDO definition as
>>>>> above for now, just so that I can keep on moving forward with the
>>>>> implementation.  However, the syntax for the above or the work on
>>>>> structs so far is not set in stone.  Any comments appreciated.
>>>>> 
>>>>> Thanks,
>>>>> steven
>>>>> 
>>>>> 
>>>>> == STRUCT EXAMPLE ==
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> sr = 44100
>>>>> ksmps = 1
>>>>> nchnls = 2
>>>>> 0dbfs = 1
>>>>> 
>>>>> struct MyType imaginary:k, real:k, kimaginary, kreal
>>>>> 
>>>>> instr 1
>>>>> 
>>>>> var0:MyType init 1, 2, 3, 4
>>>>> ;var1:MyType = init:MyType(0, 0, 1, 1)
>>>>> 
>>>>> var0.imaginary init 5
>>>>> var0.real init 6
>>>>> var0.kimaginary init 7
>>>>> var0.kreal init 9
>>>>> 
>>>>> var0.imaginary += 1
>>>>> var0.real += 2
>>>>> var0.kimaginary += 3
>>>>> var0.kreal += 4
>>>>> 
>>>>> printks "i %d r %d ki %d kr %d\n", 0.2, var0.imaginary, var0.real,
>>>>> var0.kimaginary, var0.kreal
>>>>> 
>>>>> endin
>>>>> 
>>>>> 
>>>>> ; ==============================================
>>>>> 
>>>>> i1 0 0.5
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> ------------------------------------------------------------------------------
>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>> 
>>> ------------------------------------------------------------------------------
>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>> Get technology previously reserved for billion-dollar corporations, FREE
>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>> 
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-02-19 20:20
FromSteven Yi
SubjectRe: [Cs-dev] User-Defined Types (Structs)
I was thinking along the same lines.  My thought was to promote the
newer syntax for moving forward. We can keep the older syntax there
for backwards compatibility, but just freeze it and not commit any
further time to develop it.

As a sidenote, I had the thought to simplify testing, once this is in
a good state to test, we can put together a web version of the parser3
branch.  Besides power users who are compiling Csound themselves, this
should allow us to get feedback from other users without them having
to modify their Csound installations.  It might be an interesting
thing to try to have multiple versions of web Csound hosted online at
the same site (i.e. user uses Csound-notebook, can choose whether to
use "stable", "development", or "experimental" versions of Csound.)

On Thu, Feb 19, 2015 at 2:09 PM, Victor Lazzarini
 wrote:
> It would be nice to adopt this syntax for all cases and deprecate the old one (but keep it for backwards compat.)
>
> Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy
> Maynooth University
> Ireland
>
>> On 19 Feb 2015, at 16:56, Rory Walsh  wrote:
>>
>> This looks tidy. Cool.
>>
>>> On 19 February 2015 at 16:48, Michael Gogins  wrote:
>>> Yes, I think ():() is good.
>>>
>>> Best,
>>> Mike
>>>
>>> -----------------------------------------------------
>>> Michael Gogins
>>> Irreducible Productions
>>> http://michaelgogins.tumblr.com
>>> Michael dot Gogins at gmail dot com
>>>
>>>
>>>> On Thu, Feb 19, 2015 at 11:44 AM, Steven Yi  wrote:
>>>> You got it right there Rory.  Within parentheses would be in args, and
>>>> the  last part is the out type.  One thing though is that Csound
>>>> allows multiple outs, so maybe it would have to be something like
>>>> this:
>>>>
>>>> opcode myOpcode(in_types):(out_types)
>>>>
>>>> endop
>>>>
>>>> To work with multiple outs.  I'll go with this and see what happens.
>>>> Once the infrastructure is there, it's easy enough to change the
>>>> syntax.
>>>>
>>>>> On Thu, Feb 19, 2015 at 11:37 AM, Rory Walsh  wrote:
>>>>> This sounds very interesting Steven. I'm eagerly following your
>>>>> progress. Is the syntax you are proposing regarding UDOs as follows:
>>>>>
>>>>> opcode opcodeName(in types....):out type
>>>>>
>>>>> endop
>>>>>
>>>>> If that's wrong, what is going on after the colon at the end of the
>>>>> parenthesis?
>>>>>
>>>>>> On 19 February 2015 at 05:23, Steven Yi  wrote:
>>>>>> Hi All,
>>>>>>
>>>>>> I've been working away in the feature/parser3 branch and have just
>>>>>> gotten through implementing the basics for user-defined types
>>>>>> (structs). The example code pasted below shows:
>>>>>>
>>>>>> 1. defining a struct type called MyType
>>>>>> 2. Use of explicit and implicit typed member vars
>>>>>> 3. Using init to create a MyType
>>>>>> 4. setting and updating of MyType member vars
>>>>>>
>>>>>> To note, the way compilation is done, the members of structs are used
>>>>>> directly.  So the init and printks function calls have their argument
>>>>>> pointers pointing directly into the memory allocated for the struct
>>>>>> var.  This all type checks correctly and run-time type identification
>>>>>> should all be working as I'm using CS_VAR_MEM's to store data.
>>>>>>
>>>>>> The next step here is to get structs working with UDO's.  However,
>>>>>> I've run up against a design issue.  UDO's do not have a good way to
>>>>>> modify how their arguments should be specified when it comes to in-
>>>>>> and out-args. I think we will need a new way to define UDO's to
>>>>>> accommodate different kinds of types.  I'm currently thinking we
>>>>>> should create an additional way to define UDO's, one that is more
>>>>>> flexible in regards to var types.  What I am thinking is something
>>>>>> like:
>>>>>>
>>>>>> opcode processMyType(inValue:MyType, kval1, kval2):MyType
>>>>>>  retVal:MyType = inValue
>>>>>>  retVal.imaginary *= kval1
>>>>>>  reVal.real *= kval2
>>>>>>  return retVal
>>>>>> endop
>>>>>>
>>>>>> What this would do is specify both the input argument names as well as
>>>>>> types at the same time, as well as specify the output type.  The
>>>>>> parser then would be responsible for generating the correct inarg and
>>>>>> outarg strings for the generated OENTRY (something like ":MyType;"
>>>>>> and  ":MyType;kk").  The compiler would then also insert a line for a
>>>>>> generated "xin" call with the types, as well as replace the "return"
>>>>>> with "xout".  (return would just be an alias for xout then).  One
>>>>>> thing though is that return would also be sure to type check against
>>>>>> the specified out-type.
>>>>>>
>>>>>> I'm going to proceed with implementing the newer UDO definition as
>>>>>> above for now, just so that I can keep on moving forward with the
>>>>>> implementation.  However, the syntax for the above or the work on
>>>>>> structs so far is not set in stone.  Any comments appreciated.
>>>>>>
>>>>>> Thanks,
>>>>>> steven
>>>>>>
>>>>>>
>>>>>> == STRUCT EXAMPLE ==
>>>>>>
>>>>>> 
>>>>>> 
>>>>>>
>>>>>> sr = 44100
>>>>>> ksmps = 1
>>>>>> nchnls = 2
>>>>>> 0dbfs = 1
>>>>>>
>>>>>> struct MyType imaginary:k, real:k, kimaginary, kreal
>>>>>>
>>>>>> instr 1
>>>>>>
>>>>>> var0:MyType init 1, 2, 3, 4
>>>>>> ;var1:MyType = init:MyType(0, 0, 1, 1)
>>>>>>
>>>>>> var0.imaginary init 5
>>>>>> var0.real init 6
>>>>>> var0.kimaginary init 7
>>>>>> var0.kreal init 9
>>>>>>
>>>>>> var0.imaginary += 1
>>>>>> var0.real += 2
>>>>>> var0.kimaginary += 3
>>>>>> var0.kreal += 4
>>>>>>
>>>>>> printks "i %d r %d ki %d kr %d\n", 0.2, var0.imaginary, var0.real,
>>>>>> var0.kimaginary, var0.kreal
>>>>>>
>>>>>> endin
>>>>>>
>>>>>> 
>>>>>> ; ==============================================
>>>>>> 
>>>>>> i1 0 0.5
>>>>>>
>>>>>>
>>>>>> 
>>>>>> 
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>> ------------------------------------------------------------------------------
>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>> Get technology previously reserved for billion-dollar corporations, FREE
>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-02-19 22:36
FromRory Walsh
SubjectRe: [Cs-dev] User-Defined Types (Structs)
It would also be nice to be able to enable this parser as we used to
be able to do with the last one. Would this be possible?

On 19 February 2015 at 20:20, Steven Yi  wrote:
> I was thinking along the same lines.  My thought was to promote the
> newer syntax for moving forward. We can keep the older syntax there
> for backwards compatibility, but just freeze it and not commit any
> further time to develop it.
>
> As a sidenote, I had the thought to simplify testing, once this is in
> a good state to test, we can put together a web version of the parser3
> branch.  Besides power users who are compiling Csound themselves, this
> should allow us to get feedback from other users without them having
> to modify their Csound installations.  It might be an interesting
> thing to try to have multiple versions of web Csound hosted online at
> the same site (i.e. user uses Csound-notebook, can choose whether to
> use "stable", "development", or "experimental" versions of Csound.)
>
> On Thu, Feb 19, 2015 at 2:09 PM, Victor Lazzarini
>  wrote:
>> It would be nice to adopt this syntax for all cases and deprecate the old one (but keep it for backwards compat.)
>>
>> Victor Lazzarini
>> Dean of Arts, Celtic Studies, and Philosophy
>> Maynooth University
>> Ireland
>>
>>> On 19 Feb 2015, at 16:56, Rory Walsh  wrote:
>>>
>>> This looks tidy. Cool.
>>>
>>>> On 19 February 2015 at 16:48, Michael Gogins  wrote:
>>>> Yes, I think ():() is good.
>>>>
>>>> Best,
>>>> Mike
>>>>
>>>> -----------------------------------------------------
>>>> Michael Gogins
>>>> Irreducible Productions
>>>> http://michaelgogins.tumblr.com
>>>> Michael dot Gogins at gmail dot com
>>>>
>>>>
>>>>> On Thu, Feb 19, 2015 at 11:44 AM, Steven Yi  wrote:
>>>>> You got it right there Rory.  Within parentheses would be in args, and
>>>>> the  last part is the out type.  One thing though is that Csound
>>>>> allows multiple outs, so maybe it would have to be something like
>>>>> this:
>>>>>
>>>>> opcode myOpcode(in_types):(out_types)
>>>>>
>>>>> endop
>>>>>
>>>>> To work with multiple outs.  I'll go with this and see what happens.
>>>>> Once the infrastructure is there, it's easy enough to change the
>>>>> syntax.
>>>>>
>>>>>> On Thu, Feb 19, 2015 at 11:37 AM, Rory Walsh  wrote:
>>>>>> This sounds very interesting Steven. I'm eagerly following your
>>>>>> progress. Is the syntax you are proposing regarding UDOs as follows:
>>>>>>
>>>>>> opcode opcodeName(in types....):out type
>>>>>>
>>>>>> endop
>>>>>>
>>>>>> If that's wrong, what is going on after the colon at the end of the
>>>>>> parenthesis?
>>>>>>
>>>>>>> On 19 February 2015 at 05:23, Steven Yi  wrote:
>>>>>>> Hi All,
>>>>>>>
>>>>>>> I've been working away in the feature/parser3 branch and have just
>>>>>>> gotten through implementing the basics for user-defined types
>>>>>>> (structs). The example code pasted below shows:
>>>>>>>
>>>>>>> 1. defining a struct type called MyType
>>>>>>> 2. Use of explicit and implicit typed member vars
>>>>>>> 3. Using init to create a MyType
>>>>>>> 4. setting and updating of MyType member vars
>>>>>>>
>>>>>>> To note, the way compilation is done, the members of structs are used
>>>>>>> directly.  So the init and printks function calls have their argument
>>>>>>> pointers pointing directly into the memory allocated for the struct
>>>>>>> var.  This all type checks correctly and run-time type identification
>>>>>>> should all be working as I'm using CS_VAR_MEM's to store data.
>>>>>>>
>>>>>>> The next step here is to get structs working with UDO's.  However,
>>>>>>> I've run up against a design issue.  UDO's do not have a good way to
>>>>>>> modify how their arguments should be specified when it comes to in-
>>>>>>> and out-args. I think we will need a new way to define UDO's to
>>>>>>> accommodate different kinds of types.  I'm currently thinking we
>>>>>>> should create an additional way to define UDO's, one that is more
>>>>>>> flexible in regards to var types.  What I am thinking is something
>>>>>>> like:
>>>>>>>
>>>>>>> opcode processMyType(inValue:MyType, kval1, kval2):MyType
>>>>>>>  retVal:MyType = inValue
>>>>>>>  retVal.imaginary *= kval1
>>>>>>>  reVal.real *= kval2
>>>>>>>  return retVal
>>>>>>> endop
>>>>>>>
>>>>>>> What this would do is specify both the input argument names as well as
>>>>>>> types at the same time, as well as specify the output type.  The
>>>>>>> parser then would be responsible for generating the correct inarg and
>>>>>>> outarg strings for the generated OENTRY (something like ":MyType;"
>>>>>>> and  ":MyType;kk").  The compiler would then also insert a line for a
>>>>>>> generated "xin" call with the types, as well as replace the "return"
>>>>>>> with "xout".  (return would just be an alias for xout then).  One
>>>>>>> thing though is that return would also be sure to type check against
>>>>>>> the specified out-type.
>>>>>>>
>>>>>>> I'm going to proceed with implementing the newer UDO definition as
>>>>>>> above for now, just so that I can keep on moving forward with the
>>>>>>> implementation.  However, the syntax for the above or the work on
>>>>>>> structs so far is not set in stone.  Any comments appreciated.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> steven
>>>>>>>
>>>>>>>
>>>>>>> == STRUCT EXAMPLE ==
>>>>>>>
>>>>>>> 
>>>>>>> 
>>>>>>>
>>>>>>> sr = 44100
>>>>>>> ksmps = 1
>>>>>>> nchnls = 2
>>>>>>> 0dbfs = 1
>>>>>>>
>>>>>>> struct MyType imaginary:k, real:k, kimaginary, kreal
>>>>>>>
>>>>>>> instr 1
>>>>>>>
>>>>>>> var0:MyType init 1, 2, 3, 4
>>>>>>> ;var1:MyType = init:MyType(0, 0, 1, 1)
>>>>>>>
>>>>>>> var0.imaginary init 5
>>>>>>> var0.real init 6
>>>>>>> var0.kimaginary init 7
>>>>>>> var0.kreal init 9
>>>>>>>
>>>>>>> var0.imaginary += 1
>>>>>>> var0.real += 2
>>>>>>> var0.kimaginary += 3
>>>>>>> var0.kreal += 4
>>>>>>>
>>>>>>> printks "i %d r %d ki %d kr %d\n", 0.2, var0.imaginary, var0.real,
>>>>>>> var0.kimaginary, var0.kreal
>>>>>>>
>>>>>>> endin
>>>>>>>
>>>>>>> 
>>>>>>> ; ==============================================
>>>>>>> 
>>>>>>> i1 0 0.5
>>>>>>>
>>>>>>>
>>>>>>> 
>>>>>>> 
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>> ------------------------------------------------------------------------------
>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>> Get technology previously reserved for billion-dollar corporations, FREE
>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-02-19 23:06
FromSteven Yi
SubjectRe: [Cs-dev] User-Defined Types (Structs)
I think it would not be easy to do this like we did with Csound 5.
The reason being that with Csound 5, we had a new parser besides the
old parser, but it had it's own set of compilation and semantic
analysis functions. They both used the same common end data
structures, but everything from parse-time through compilation was two
distinct paths.

With the work I've been doing in the parser3 branch, I've modified a
number of functions in the semantic analyzer and compiler code.  I
think I'd have to go back and basically copy in the code from the
develop branch and rename the functions so that they could be there in
parallel.  I'd say at this point, it might be more error prone to try
to do that versus just switching to the new parser/compiler outright.

To note, there were other changes I had to do to get to this point.
Parser3 generates a slightly different TREE structure than CS6's
parser for one thing.  This made the grammar simpler in the end, and
enabled me to more easily add explicit types for variables.  It was
great that we had the option to switch between old and new parser in
CS5 days, but I think it's going to be too much work to retroactively
do that for this work.

On the other hand, we're in a much different place going from CS6 ->
CS7.  We have the test suite of CSD's and unit tests for one (and at
least right now, parser3 is passing on all tests).  Plus we can revive
the scripts to test the parser against the Csound Catalog, which we
were using during CS6 work. I'd say there's a much higher confidence
level that CS7 is going to properly be backwards compatible to CS6 as
there was comparing NewParser to the old parser.

On Thu, Feb 19, 2015 at 5:36 PM, Rory Walsh  wrote:
> It would also be nice to be able to enable this parser as we used to
> be able to do with the last one. Would this be possible?
>
> On 19 February 2015 at 20:20, Steven Yi  wrote:
>> I was thinking along the same lines.  My thought was to promote the
>> newer syntax for moving forward. We can keep the older syntax there
>> for backwards compatibility, but just freeze it and not commit any
>> further time to develop it.
>>
>> As a sidenote, I had the thought to simplify testing, once this is in
>> a good state to test, we can put together a web version of the parser3
>> branch.  Besides power users who are compiling Csound themselves, this
>> should allow us to get feedback from other users without them having
>> to modify their Csound installations.  It might be an interesting
>> thing to try to have multiple versions of web Csound hosted online at
>> the same site (i.e. user uses Csound-notebook, can choose whether to
>> use "stable", "development", or "experimental" versions of Csound.)
>>
>> On Thu, Feb 19, 2015 at 2:09 PM, Victor Lazzarini
>>  wrote:
>>> It would be nice to adopt this syntax for all cases and deprecate the old one (but keep it for backwards compat.)
>>>
>>> Victor Lazzarini
>>> Dean of Arts, Celtic Studies, and Philosophy
>>> Maynooth University
>>> Ireland
>>>
>>>> On 19 Feb 2015, at 16:56, Rory Walsh  wrote:
>>>>
>>>> This looks tidy. Cool.
>>>>
>>>>> On 19 February 2015 at 16:48, Michael Gogins  wrote:
>>>>> Yes, I think ():() is good.
>>>>>
>>>>> Best,
>>>>> Mike
>>>>>
>>>>> -----------------------------------------------------
>>>>> Michael Gogins
>>>>> Irreducible Productions
>>>>> http://michaelgogins.tumblr.com
>>>>> Michael dot Gogins at gmail dot com
>>>>>
>>>>>
>>>>>> On Thu, Feb 19, 2015 at 11:44 AM, Steven Yi  wrote:
>>>>>> You got it right there Rory.  Within parentheses would be in args, and
>>>>>> the  last part is the out type.  One thing though is that Csound
>>>>>> allows multiple outs, so maybe it would have to be something like
>>>>>> this:
>>>>>>
>>>>>> opcode myOpcode(in_types):(out_types)
>>>>>>
>>>>>> endop
>>>>>>
>>>>>> To work with multiple outs.  I'll go with this and see what happens.
>>>>>> Once the infrastructure is there, it's easy enough to change the
>>>>>> syntax.
>>>>>>
>>>>>>> On Thu, Feb 19, 2015 at 11:37 AM, Rory Walsh  wrote:
>>>>>>> This sounds very interesting Steven. I'm eagerly following your
>>>>>>> progress. Is the syntax you are proposing regarding UDOs as follows:
>>>>>>>
>>>>>>> opcode opcodeName(in types....):out type
>>>>>>>
>>>>>>> endop
>>>>>>>
>>>>>>> If that's wrong, what is going on after the colon at the end of the
>>>>>>> parenthesis?
>>>>>>>
>>>>>>>> On 19 February 2015 at 05:23, Steven Yi  wrote:
>>>>>>>> Hi All,
>>>>>>>>
>>>>>>>> I've been working away in the feature/parser3 branch and have just
>>>>>>>> gotten through implementing the basics for user-defined types
>>>>>>>> (structs). The example code pasted below shows:
>>>>>>>>
>>>>>>>> 1. defining a struct type called MyType
>>>>>>>> 2. Use of explicit and implicit typed member vars
>>>>>>>> 3. Using init to create a MyType
>>>>>>>> 4. setting and updating of MyType member vars
>>>>>>>>
>>>>>>>> To note, the way compilation is done, the members of structs are used
>>>>>>>> directly.  So the init and printks function calls have their argument
>>>>>>>> pointers pointing directly into the memory allocated for the struct
>>>>>>>> var.  This all type checks correctly and run-time type identification
>>>>>>>> should all be working as I'm using CS_VAR_MEM's to store data.
>>>>>>>>
>>>>>>>> The next step here is to get structs working with UDO's.  However,
>>>>>>>> I've run up against a design issue.  UDO's do not have a good way to
>>>>>>>> modify how their arguments should be specified when it comes to in-
>>>>>>>> and out-args. I think we will need a new way to define UDO's to
>>>>>>>> accommodate different kinds of types.  I'm currently thinking we
>>>>>>>> should create an additional way to define UDO's, one that is more
>>>>>>>> flexible in regards to var types.  What I am thinking is something
>>>>>>>> like:
>>>>>>>>
>>>>>>>> opcode processMyType(inValue:MyType, kval1, kval2):MyType
>>>>>>>>  retVal:MyType = inValue
>>>>>>>>  retVal.imaginary *= kval1
>>>>>>>>  reVal.real *= kval2
>>>>>>>>  return retVal
>>>>>>>> endop
>>>>>>>>
>>>>>>>> What this would do is specify both the input argument names as well as
>>>>>>>> types at the same time, as well as specify the output type.  The
>>>>>>>> parser then would be responsible for generating the correct inarg and
>>>>>>>> outarg strings for the generated OENTRY (something like ":MyType;"
>>>>>>>> and  ":MyType;kk").  The compiler would then also insert a line for a
>>>>>>>> generated "xin" call with the types, as well as replace the "return"
>>>>>>>> with "xout".  (return would just be an alias for xout then).  One
>>>>>>>> thing though is that return would also be sure to type check against
>>>>>>>> the specified out-type.
>>>>>>>>
>>>>>>>> I'm going to proceed with implementing the newer UDO definition as
>>>>>>>> above for now, just so that I can keep on moving forward with the
>>>>>>>> implementation.  However, the syntax for the above or the work on
>>>>>>>> structs so far is not set in stone.  Any comments appreciated.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> steven
>>>>>>>>
>>>>>>>>
>>>>>>>> == STRUCT EXAMPLE ==
>>>>>>>>
>>>>>>>> 
>>>>>>>> 
>>>>>>>>
>>>>>>>> sr = 44100
>>>>>>>> ksmps = 1
>>>>>>>> nchnls = 2
>>>>>>>> 0dbfs = 1
>>>>>>>>
>>>>>>>> struct MyType imaginary:k, real:k, kimaginary, kreal
>>>>>>>>
>>>>>>>> instr 1
>>>>>>>>
>>>>>>>> var0:MyType init 1, 2, 3, 4
>>>>>>>> ;var1:MyType = init:MyType(0, 0, 1, 1)
>>>>>>>>
>>>>>>>> var0.imaginary init 5
>>>>>>>> var0.real init 6
>>>>>>>> var0.kimaginary init 7
>>>>>>>> var0.kreal init 9
>>>>>>>>
>>>>>>>> var0.imaginary += 1
>>>>>>>> var0.real += 2
>>>>>>>> var0.kimaginary += 3
>>>>>>>> var0.kreal += 4
>>>>>>>>
>>>>>>>> printks "i %d r %d ki %d kr %d\n", 0.2, var0.imaginary, var0.real,
>>>>>>>> var0.kimaginary, var0.kreal
>>>>>>>>
>>>>>>>> endin
>>>>>>>>
>>>>>>>> 
>>>>>>>> ; ==============================================
>>>>>>>> 
>>>>>>>> i1 0 0.5
>>>>>>>>
>>>>>>>>
>>>>>>>> 
>>>>>>>> 
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>> ------------------------------------------------------------------------------
>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>> Get technology previously reserved for billion-dollar corporations, FREE
>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-02-19 23:20
FromRory Walsh
SubjectRe: [Cs-dev] User-Defined Types (Structs)
Thanks. I had a feeling this might be the case. Apart from that I
think having an online mechanism to test these new features would be
really great.

On 19 February 2015 at 23:06, Steven Yi  wrote:
> I think it would not be easy to do this like we did with Csound 5.
> The reason being that with Csound 5, we had a new parser besides the
> old parser, but it had it's own set of compilation and semantic
> analysis functions. They both used the same common end data
> structures, but everything from parse-time through compilation was two
> distinct paths.
>
> With the work I've been doing in the parser3 branch, I've modified a
> number of functions in the semantic analyzer and compiler code.  I
> think I'd have to go back and basically copy in the code from the
> develop branch and rename the functions so that they could be there in
> parallel.  I'd say at this point, it might be more error prone to try
> to do that versus just switching to the new parser/compiler outright.
>
> To note, there were other changes I had to do to get to this point.
> Parser3 generates a slightly different TREE structure than CS6's
> parser for one thing.  This made the grammar simpler in the end, and
> enabled me to more easily add explicit types for variables.  It was
> great that we had the option to switch between old and new parser in
> CS5 days, but I think it's going to be too much work to retroactively
> do that for this work.
>
> On the other hand, we're in a much different place going from CS6 ->
> CS7.  We have the test suite of CSD's and unit tests for one (and at
> least right now, parser3 is passing on all tests).  Plus we can revive
> the scripts to test the parser against the Csound Catalog, which we
> were using during CS6 work. I'd say there's a much higher confidence
> level that CS7 is going to properly be backwards compatible to CS6 as
> there was comparing NewParser to the old parser.
>
> On Thu, Feb 19, 2015 at 5:36 PM, Rory Walsh  wrote:
>> It would also be nice to be able to enable this parser as we used to
>> be able to do with the last one. Would this be possible?
>>
>> On 19 February 2015 at 20:20, Steven Yi  wrote:
>>> I was thinking along the same lines.  My thought was to promote the
>>> newer syntax for moving forward. We can keep the older syntax there
>>> for backwards compatibility, but just freeze it and not commit any
>>> further time to develop it.
>>>
>>> As a sidenote, I had the thought to simplify testing, once this is in
>>> a good state to test, we can put together a web version of the parser3
>>> branch.  Besides power users who are compiling Csound themselves, this
>>> should allow us to get feedback from other users without them having
>>> to modify their Csound installations.  It might be an interesting
>>> thing to try to have multiple versions of web Csound hosted online at
>>> the same site (i.e. user uses Csound-notebook, can choose whether to
>>> use "stable", "development", or "experimental" versions of Csound.)
>>>
>>> On Thu, Feb 19, 2015 at 2:09 PM, Victor Lazzarini
>>>  wrote:
>>>> It would be nice to adopt this syntax for all cases and deprecate the old one (but keep it for backwards compat.)
>>>>
>>>> Victor Lazzarini
>>>> Dean of Arts, Celtic Studies, and Philosophy
>>>> Maynooth University
>>>> Ireland
>>>>
>>>>> On 19 Feb 2015, at 16:56, Rory Walsh  wrote:
>>>>>
>>>>> This looks tidy. Cool.
>>>>>
>>>>>> On 19 February 2015 at 16:48, Michael Gogins  wrote:
>>>>>> Yes, I think ():() is good.
>>>>>>
>>>>>> Best,
>>>>>> Mike
>>>>>>
>>>>>> -----------------------------------------------------
>>>>>> Michael Gogins
>>>>>> Irreducible Productions
>>>>>> http://michaelgogins.tumblr.com
>>>>>> Michael dot Gogins at gmail dot com
>>>>>>
>>>>>>
>>>>>>> On Thu, Feb 19, 2015 at 11:44 AM, Steven Yi  wrote:
>>>>>>> You got it right there Rory.  Within parentheses would be in args, and
>>>>>>> the  last part is the out type.  One thing though is that Csound
>>>>>>> allows multiple outs, so maybe it would have to be something like
>>>>>>> this:
>>>>>>>
>>>>>>> opcode myOpcode(in_types):(out_types)
>>>>>>>
>>>>>>> endop
>>>>>>>
>>>>>>> To work with multiple outs.  I'll go with this and see what happens.
>>>>>>> Once the infrastructure is there, it's easy enough to change the
>>>>>>> syntax.
>>>>>>>
>>>>>>>> On Thu, Feb 19, 2015 at 11:37 AM, Rory Walsh  wrote:
>>>>>>>> This sounds very interesting Steven. I'm eagerly following your
>>>>>>>> progress. Is the syntax you are proposing regarding UDOs as follows:
>>>>>>>>
>>>>>>>> opcode opcodeName(in types....):out type
>>>>>>>>
>>>>>>>> endop
>>>>>>>>
>>>>>>>> If that's wrong, what is going on after the colon at the end of the
>>>>>>>> parenthesis?
>>>>>>>>
>>>>>>>>> On 19 February 2015 at 05:23, Steven Yi  wrote:
>>>>>>>>> Hi All,
>>>>>>>>>
>>>>>>>>> I've been working away in the feature/parser3 branch and have just
>>>>>>>>> gotten through implementing the basics for user-defined types
>>>>>>>>> (structs). The example code pasted below shows:
>>>>>>>>>
>>>>>>>>> 1. defining a struct type called MyType
>>>>>>>>> 2. Use of explicit and implicit typed member vars
>>>>>>>>> 3. Using init to create a MyType
>>>>>>>>> 4. setting and updating of MyType member vars
>>>>>>>>>
>>>>>>>>> To note, the way compilation is done, the members of structs are used
>>>>>>>>> directly.  So the init and printks function calls have their argument
>>>>>>>>> pointers pointing directly into the memory allocated for the struct
>>>>>>>>> var.  This all type checks correctly and run-time type identification
>>>>>>>>> should all be working as I'm using CS_VAR_MEM's to store data.
>>>>>>>>>
>>>>>>>>> The next step here is to get structs working with UDO's.  However,
>>>>>>>>> I've run up against a design issue.  UDO's do not have a good way to
>>>>>>>>> modify how their arguments should be specified when it comes to in-
>>>>>>>>> and out-args. I think we will need a new way to define UDO's to
>>>>>>>>> accommodate different kinds of types.  I'm currently thinking we
>>>>>>>>> should create an additional way to define UDO's, one that is more
>>>>>>>>> flexible in regards to var types.  What I am thinking is something
>>>>>>>>> like:
>>>>>>>>>
>>>>>>>>> opcode processMyType(inValue:MyType, kval1, kval2):MyType
>>>>>>>>>  retVal:MyType = inValue
>>>>>>>>>  retVal.imaginary *= kval1
>>>>>>>>>  reVal.real *= kval2
>>>>>>>>>  return retVal
>>>>>>>>> endop
>>>>>>>>>
>>>>>>>>> What this would do is specify both the input argument names as well as
>>>>>>>>> types at the same time, as well as specify the output type.  The
>>>>>>>>> parser then would be responsible for generating the correct inarg and
>>>>>>>>> outarg strings for the generated OENTRY (something like ":MyType;"
>>>>>>>>> and  ":MyType;kk").  The compiler would then also insert a line for a
>>>>>>>>> generated "xin" call with the types, as well as replace the "return"
>>>>>>>>> with "xout".  (return would just be an alias for xout then).  One
>>>>>>>>> thing though is that return would also be sure to type check against
>>>>>>>>> the specified out-type.
>>>>>>>>>
>>>>>>>>> I'm going to proceed with implementing the newer UDO definition as
>>>>>>>>> above for now, just so that I can keep on moving forward with the
>>>>>>>>> implementation.  However, the syntax for the above or the work on
>>>>>>>>> structs so far is not set in stone.  Any comments appreciated.
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> steven
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> == STRUCT EXAMPLE ==
>>>>>>>>>
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>>
>>>>>>>>> sr = 44100
>>>>>>>>> ksmps = 1
>>>>>>>>> nchnls = 2
>>>>>>>>> 0dbfs = 1
>>>>>>>>>
>>>>>>>>> struct MyType imaginary:k, real:k, kimaginary, kreal
>>>>>>>>>
>>>>>>>>> instr 1
>>>>>>>>>
>>>>>>>>> var0:MyType init 1, 2, 3, 4
>>>>>>>>> ;var1:MyType = init:MyType(0, 0, 1, 1)
>>>>>>>>>
>>>>>>>>> var0.imaginary init 5
>>>>>>>>> var0.real init 6
>>>>>>>>> var0.kimaginary init 7
>>>>>>>>> var0.kreal init 9
>>>>>>>>>
>>>>>>>>> var0.imaginary += 1
>>>>>>>>> var0.real += 2
>>>>>>>>> var0.kimaginary += 3
>>>>>>>>> var0.kreal += 4
>>>>>>>>>
>>>>>>>>> printks "i %d r %d ki %d kr %d\n", 0.2, var0.imaginary, var0.real,
>>>>>>>>> var0.kimaginary, var0.kreal
>>>>>>>>>
>>>>>>>>> endin
>>>>>>>>>
>>>>>>>>> 
>>>>>>>>> ; ==============================================
>>>>>>>>> 
>>>>>>>>> i1 0 0.5
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>>
>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>>>>>> _______________________________________________
>>>>>>>>> Csound-devel mailing list
>>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>> ------------------------------------------------------------------------------
>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>> Get technology previously reserved for billion-dollar corporations, FREE
>>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net