| Hi Joachim,
I think colon is more appropriate here as it is declaring what are the
types of the outputs for the opcode. To note, this kind of syntax has
some precedence in other languages, i.e.:
Pascal [1]
function name(argument(s): type1; argument(s): type2; ...): function_type;
local declarations;
begin
...
< statements >
...
name:= expression;
end;
Scala [2]
def functionName ([list of parameters]) : [return type] = {
function body
return [expr]
}
Go has something similar in syntax, just without the colon [3]. It
uses () for returning multiple args, but single word without parens
for single return value types.
I think for myself, I prefer the colon syntax, and I think it's okay
to be different here than the previous opcode style. I think having
more points of view here would be useful.
steven
[1] - http://www.tutorialspoint.com/pascal/pascal_functions.htm
[2] - http://www.tutorialspoint.com/scala/scala_functions.htm
[3] - http://www.tutorialspoint.com/go/go_functions.htm
On Wed, Feb 25, 2015 at 3:18 PM, joachim heintz wrote:
> hi steven -
>
> great to see this growing.
>
> i am wondering whether it would be better to seperate input and output
> args in the new syntax by comma rather than by colon:
> opcode myadd_new2(value0:i),(i) instead of
> opcode myadd_new2(value0:i):(i).
>
> two reasons for this suggestion:
> 1) would be in the usual csound style (to seperate args by comma)
> 2) shouldn't colons be reserved for the type identifier?
>
> ciao -
> j
>
>
> Am 25.02.2015 um 00:45 schrieb Steven Yi:
>> Hi All,
>>
>> Just an update, I got the basics working now in the feature/parser3
>> branch for new-style UDO's. With the following examples of UDO's:
>>
>> opcode testop, 0, 0
>> prints "HELLO WORLD \n"
>> endop
>>
>> opcode myadd, i,i
>> ival xin
>> xout ival + 1
>> endop
>>
>> opcode testop_new():()
>> prints "HELLO WORLD 2\n"
>> endop
>>
>> opcode myadd_new(ival):(i)
>> prints "In myadd_new\n"
>> xout ival + 1
>> endop
>>
>> opcode myadd_new2(value0:i):(i)
>> xout value0 + 1
>> endop
>>
>> instr 1
>>
>> testop()
>> testop_new()
>> ival = myadd(4)
>> print ival
>>
>> ival2 = myadd_new(4)
>> print ival2
>>
>>
>> ival3 = myadd_new2(4)
>> print ival3
>>
>> turnoff
>>
>> endin
>>
>>
>> The result of running this (full CSD attached) gives:
>>
>> HELLO WORLD
>> HELLO WORLD 2
>> instr 1: ival = 5.000
>> In myadd_new
>> instr 1: ival2 = 5.000
>> instr 1: ival3 = 5.000
>>
>> Note for new-style UDO's, the current syntax is to use comma separated
>> args for in-args and out-arg-types.
>>
>> I do think that the syntax is a little ugly for the out-args. I'm
>> wondering about adding these possibilities:
>>
>> ; allow void instead of ()
>> opcode someOpcode():void
>> endop
>>
>> ; if single output-arg, allow just single type without parens
>> opcode someOpcode():i
>> endop
>>
>> Now that the new-style UDO's are working, I'll be looking at getting
>> structs to work as arguments.
>>
>> Thanks!
>> steven
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
>> by Intel and developed in partnership with Slashdot Media, is your hub for all
>> things parallel software development, from weekly thought leadership blogs to
>> news, videos, case studies, tutorials and more. Take a look and join the
>> conversation now. http://goparallel.sourceforge.net/
>>
>>
>>
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |