| This was something I had hinted at in a previous email with syntax like:
data MyType ivar, kvar, asig
instr 1
ival1 = 1
kval1 init 0
asig init 0
myVal1:MyType // initialize with empty values
myVal:MyType = ival, kval1, asig // use with initializer
myVal1.ivar = 1 // access data type's values
etc.
endin
The only way to do something like this though and be backwards
compatible is to infer types if no type value is given, i.e.:
instr 1
iamp = 1 // i-type
pitch:i = 440 // also i-type
channel0:a = 0 // a-type
channel0 vco2 iamp, pitch
endin
That would be backwards compatible I think. The rule would be:
1)If type given, use it
2)If no type given, infer from initial letter (only available for
classic built-in types, i.e. a-, k-, w-, S-, i-, f-, etc.), or if in
assignment, by the type being assigned
3)Lookup would be contextual, so that variable names could be the same
as opcode names. (This would be the tricky bit)
I think for Csound to run as efficiently as it does now, if we
introduce a type system it should use strong, static typing.
On Mon, Apr 23, 2012 at 4:29 PM, Jacob Joaquin wrote:
> I realize this probably not feasible, at all, but if there was a way
> to get away from hungarian notation, that would potentially make way
> for a cleaner and more modern syntax. Which could in turn really open
> up useful new data types to users in a way in which are potentially
> easier to interact with and give a sense of familiarity.
>
>
> On Mon, Apr 23, 2012 at 7:50 AM, Steven Yi wrote:
>> I like this idea of generic arrays. I think if the Context changes
>> work out, and there is a generic variables map in the Context, we
>> should be able to create a generic list type (and generic type system)
>> i.e.:
>>
>> typedef struct vartype {
>> char* typeName;
>> VARIABLE* (*createVar)(void* args);
>> } VARTYPE;
>>
>> typdef struct var {
>> VARTYPE vartype;
>> int size;
>> void * data;
>> } VARIABLE;
>>
>> The above is probably a bit naive of an implementation, but in
>> general, I think it's the right direction. The parser could parse
>> aSig[] as a array-type of a. Interestingly, with opcode as a type, we
>> might be able to get opcode[] as a possibility too. i.e.
>>
>> asig:a[20] // allocate space
>> vcoArray:vco2[20] // allocate space, but opcodes are not linked into
>> performance chain
>> kcount = 0
>>
>> until (kcount >= len(asig)) do
>> asig[kcount] vcoArray[kcount] 1, 440 + (440 * (kcount / 4)) // see below
>> kcount = kcount + 1
>> od
>>
>> For the line that uses vcoArray, the parser could replace that with an
>> opcode that handles runtime. The opcode could be something like:
>>
>> var opArray arraryVar, arrayVarCounter, args...
>>
>> So for example, opArray's init and performance functions would
>> delegate to the opcode held in vcoArray at the given index. The only
>> tricky bit is init-time; this could maybe done with delaying
>> initialization until first use (tracked with a flag
>> hasBeenInitialized), though that could be problematic.
>>
>> Anyways, the opcode array stuff may be a lot of trouble, but I think
>> having a generic list type would be possible if we introduce a type
>> system to support it.
>>
>> On Mon, Apr 23, 2012 at 9:07 AM, Victor Lazzarini
>> wrote:
>>> Well, it's a toss-up. It's not that it is difficult, but I often wonder whether certain things should be offered as UDOs rather than built into the languages. I guess you are right, but what are the basic things? When should we stop? All the things you named are enabled by Csound, so at least they can be done with the existing syntax.
>>>
>>> Currently t-vars are numeric arrays. To make string arrays we would need to extend it, but also extend the operators. All of this is possible, but I think we need to think of the best way to do all of this. Maybe we need a generic list type instead, which can be extended and contracted at will and can hold multiple types, dynamically.
>>>
>>> Victor
>>> On 23 Apr 2012, at 08:53, joachim heintz wrote:
>>>
>>>> you want to give me new jobs, eh? =)
>>>> i don't mind, but i am wondering whether this should not be a part of
>>>> the language. if you look at the supercollider methods for the array
>>>> class, or at lisp, or python -- reversing an array looks like a basic
>>>> method, and a udo is always something you have to include extra.
>>>> may i ask again about strings? is it difficult or even impossible to
>>>> include them in a tab?
>>>> best -
>>>> j
>>>>
>>>>
>>>> Am 23.04.2012 08:59, schrieb Victor:
>>>>> I wonder whether these can be better done with udos, as of course t vars can be passed back and forth.
>>>>>
>>>>>
>>>>>
>>>>> On 22 Apr 2012, at 22:11, joachim heintz wrote:
>>>>>
>>>>>> sorry, i just see that there is an ongoing discussion at the dev-list
>>>>>> about this topic (i am some 700 cslist and csdevlist posts behind =), so
>>>>>> this might be obsolete.
>>>>>> j
>>>>>>
>>>>>> Am 22.04.2012 22:59, schrieb joachim heintz:
>>>>>>> following up peiman's request for initializing a t-variable as a list of
>>>>>>> values, and steven's request for a len(tab) opcode, these are my
>>>>>>> additional proposals:
>>>>>>> (tSrc is everywhere [0 1 2 3 4])
>>>>>>> 1) reversing a tab:
>>>>>>> tRes tabrev tSrc
>>>>>>> -> [4 3 2 1 0]
>>>>>>> 2) rotating a tab:
>>>>>>> syntax: tRes tabrot tSrc [,iTimes]
>>>>>>> iRes tabrot iSrc
>>>>>>> -> [1 2 3 4 0]
>>>>>>> iRes tabrot iSrc, -1
>>>>>>> -> [4 0 1 2 3]
>>>>>>> iRes tabrot iSrc, 3
>>>>>>> -> [3 4 0 1 2]
>>>>>>> 3) filling (replacing) a tab with an (increasing or decreasing) series
>>>>>>> of number:
>>>>>>> tabser tSrc maxval [, minval [, numsteps [, start]]]
>>>>>>> where minval and start defaults to 0, and numsteps defaults to the
>>>>>>> length of the tab.
>>>>>>> for instance, if tab has a size of 5:
>>>>>>> tRes tabser tSrc, 4
>>>>>>> -> [0 1 2 3 4]
>>>>>>> tRes tabser tSrc, 4, -4
>>>>>>> -> [-4 -2 0 2 4]
>>>>>>> tRes tabser tSrc, 4, 0, 2
>>>>>>> -> [0 4 2 3 4]
>>>>>>> tRes tabser tSrc, 4, 3, 2
>>>>>>> -> [0 1 2 3 0 4]
>>>>>>> 4) permuting randomly the elements in the tab:
>>>>>>> iRes tabpmrnd tSrc
>>>>>>> -> [3 1 4 2 0]
>>>>>>>
>>>>>>> are there, by the way, any chances to have strings in a tab?
>>>>>>>
>>>>>>> as i wanted to understand the new system, i have put together some
>>>>>>> examples for some of the existing options. if you find it useful, feel
>>>>>>> free to put it in the manual or anywhere else:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> instr t_example
>>>>>>>
>>>>>>> ;initialize the array
>>>>>>> ;with size 5 and 1 as initial element
>>>>>>> tArr init 5, 1
>>>>>>>
>>>>>>> ;get the values
>>>>>>> printks "\nInitial values:\n", 1
>>>>>>> kIndx = 0
>>>>>>> get:
>>>>>>> kVal = tArr[kIndx]
>>>>>>> printf "Value at index %d = %f\n", kIndx+1, kIndx, kVal
>>>>>>> loop_lt kIndx, 1, 5, get
>>>>>>>
>>>>>>> ;set new values
>>>>>>> kIndx = 0
>>>>>>> set:
>>>>>>> tArr[kIndx] = kIndx
>>>>>>> loop_lt kIndx, 1, 5, set
>>>>>>>
>>>>>>> ;get the new values
>>>>>>> printks "\nNew values:\n", 1
>>>>>>> kIndx = 0
>>>>>>> getnew:
>>>>>>> kVal = tArr[kIndx]
>>>>>>> printf "Value at index %d = %f\n", kIndx+1, kIndx, kVal
>>>>>>> loop_lt kIndx, 1, 5, getnew
>>>>>>>
>>>>>>> ;get the minimum value
>>>>>>> kMin mintab tArr
>>>>>>> printks "\nMinimum value = %f\n", 1, kMin
>>>>>>>
>>>>>>> ;get the maximum value
>>>>>>> kMax maxtab tArr
>>>>>>> printks "\nMaximum value = %f\n", 1, kMax
>>>>>>>
>>>>>>> ;get the sum of all values
>>>>>>> kSum sumtab tArr
>>>>>>> printks "\nSum of all values = %f\n", 1, kSum
>>>>>>>
>>>>>>> ;scale the values to a min and max
>>>>>>> scalet tArr, -10, 10
>>>>>>>
>>>>>>> ;get the new values
>>>>>>> printks "\nNew values after scaling:\n", 1
>>>>>>> kIndx = 0
>>>>>>> getscaled:
>>>>>>> kVal = tArr[kIndx]
>>>>>>> printf "Value at index %d = %f\n", kIndx+1, kIndx, kVal
>>>>>>> loop_lt kIndx, 1, 5, getscaled
>>>>>>>
>>>>>>> ;turn off this instrument
>>>>>>> turnoff
>>>>>>> endin
>>>>>>>
>>>>>>>
>>>>>>> i "t_example" 0 1
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> all best -
>>>>>>>
>>>>>>> joachim
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> For Developers, A Lot Can Happen In A Second.
>>>>>>> Boundary is the first to Know...and Tell You.
>>>>>>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
>>>>>>> http://p.sf.net/sfu/Boundary-d2dvs2
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> For Developers, A Lot Can Happen In A Second.
>>>>>> Boundary is the first to Know...and Tell You.
>>>>>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
>>>>>> http://p.sf.net/sfu/Boundary-d2dvs2
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> For Developers, A Lot Can Happen In A Second.
>>>>> Boundary is the first to Know...and Tell You.
>>>>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
>>>>> http://p.sf.net/sfu/Boundary-d2dvs2
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> For Developers, A Lot Can Happen In A Second.
>>>> Boundary is the first to Know...and Tell You.
>>>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
>>>> http://p.sf.net/sfu/Boundary-d2dvs2
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>> Dr Victor Lazzarini
>>> Senior Lecturer
>>> Dept. of Music
>>> NUI Maynooth Ireland
>>> tel.: +353 1 708 3545
>>> Victor dot Lazzarini AT nuim dot ie
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> For Developers, A Lot Can Happen In A Second.
>>> Boundary is the first to Know...and Tell You.
>>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
>>> http://p.sf.net/sfu/Boundary-d2dvs2
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> For Developers, A Lot Can Happen In A Second.
>> Boundary is the first to Know...and Tell You.
>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
>> http://p.sf.net/sfu/Boundary-d2dvs2
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
> --
> codehop.com | #code #art #music
>
> ------------------------------------------------------------------------------
> For Developers, A Lot Can Happen In A Second.
> Boundary is the first to Know...and Tell You.
> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
> http://p.sf.net/sfu/Boundary-d2dvs2
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |