Csound Csound-dev Csound-tekno Search About

[Cs-dev] Multiple Return Arguments for Function Calls

Date2015-03-09 18:02
FromSteven Yi
Subject[Cs-dev] Multiple Return Arguments for Function Calls
Hi All,

I wanted to let you know of a change I just put in to the
feature/parser3 branch in response to some discussions I had with
Victor and John.  The following is now accepted:

instr 1
a1, a2 = pan2(vco2(0.5,440), 0.0)
outs a1, a2
endin

Previously, functions could only return a single argument.  With the
latest change, a top-most function can return multiple arguments if it
is together with an assignment. The above ends up essentially being
rewritten as:

a1, a2  pan2  vco2(0.5,440), 0.0

Victor has mentioned some things about doing argument unpacking within
function calls.  This could look something like python's tuple
unpacking, which would allow:

outs(*pan2(vco2(0.5,440),0.0))

which would get compiled as:

#a0 vco2 0.5,440
#a1, #a2 pan2 #a0, 0.0
       outs #a1, a2

There are some complications here that need to be figured out. Because
of overloading of opcodes on output type, we may need to extend the
explicit typing of opcode calls such that some situations may require:

outs(*pan2:aa(vco2(0.5,440),0.0))

with the types given for multiple output args.  I have further
questions about how this might interact with new-style UDO syntax.

Just FYI, we discussed other multiple value return implementations,
namely Common Lisp's multiple-value-bind, Lua, Go, Matlab/Octave, and
Python.  Some of these do not allow unpacking of args within
expressions, others do, but with limitations (only if at the end of an
arg list to a function). There's more to be done, but at least the
multiple return args is implemented now for the assignment case.

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

Date2015-03-09 18:33
FromDave Seidel
SubjectRe: [Cs-dev] Multiple Return Arguments for Function Calls
AttachmentsNone  None  
That will be great. I FINALLY started using the new syntax this weekend, and I love it. It will be even better when it can be used in all expressions.

- Dave

On Mon, Mar 9, 2015 at 2:02 PM, Steven Yi <stevenyi@gmail.com> wrote:
Hi All,

I wanted to let you know of a change I just put in to the
feature/parser3 branch in response to some discussions I had with
Victor and John.  The following is now accepted:

instr 1
a1, a2 = pan2(vco2(0.5,440), 0.0)
outs a1, a2
endin

Previously, functions could only return a single argument.  With the
latest change, a top-most function can return multiple arguments if it
is together with an assignment. The above ends up essentially being
rewritten as:

a1, a2  pan2  vco2(0.5,440), 0.0

Victor has mentioned some things about doing argument unpacking within
function calls.  This could look something like python's tuple
unpacking, which would allow:

outs(*pan2(vco2(0.5,440),0.0))

which would get compiled as:

#a0 vco2 0.5,440
#a1, #a2 pan2 #a0, 0.0
       outs #a1, a2

There are some complications here that need to be figured out. Because
of overloading of opcodes on output type, we may need to extend the
explicit typing of opcode calls such that some situations may require:

outs(*pan2:aa(vco2(0.5,440),0.0))

with the types given for multiple output args.  I have further
questions about how this might interact with new-style UDO syntax.

Just FYI, we discussed other multiple value return implementations,
namely Common Lisp's multiple-value-bind, Lua, Go, Matlab/Octave, and
Python.  Some of these do not allow unpacking of args within
expressions, others do, but with limitations (only if at the end of an
arg list to a function). There's more to be done, but at least the
multiple return args is implemented now for the assignment case.

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


Date2015-03-10 05:11
FromSteven Yi
SubjectRe: [Cs-dev] Multiple Return Arguments for Function Calls
Hi Dave,

Glad to hear you're enjoying the newer style syntax!  It's all coming
along nicely, I think. We'll need a lot of vetting of the newer stuff
in CS7 before we release to make sure we don't design ourselves into
any holes in regards to future language features. We also need to
figure out how to deal with all of this in terms of pedagogy,
especially with so many years of early-style syntax.  I guess that
boils down to there's still a lot to do. :)

steven

On Mon, Mar 9, 2015 at 2:33 PM, Dave Seidel  wrote:
> That will be great. I FINALLY started using the new syntax this weekend, and
> I love it. It will be even better when it can be used in all expressions.
>
> - Dave
>
> On Mon, Mar 9, 2015 at 2:02 PM, Steven Yi  wrote:
>>
>> Hi All,
>>
>> I wanted to let you know of a change I just put in to the
>> feature/parser3 branch in response to some discussions I had with
>> Victor and John.  The following is now accepted:
>>
>> instr 1
>> a1, a2 = pan2(vco2(0.5,440), 0.0)
>> outs a1, a2
>> endin
>>
>> Previously, functions could only return a single argument.  With the
>> latest change, a top-most function can return multiple arguments if it
>> is together with an assignment. The above ends up essentially being
>> rewritten as:
>>
>> a1, a2  pan2  vco2(0.5,440), 0.0
>>
>> Victor has mentioned some things about doing argument unpacking within
>> function calls.  This could look something like python's tuple
>> unpacking, which would allow:
>>
>> outs(*pan2(vco2(0.5,440),0.0))
>>
>> which would get compiled as:
>>
>> #a0 vco2 0.5,440
>> #a1, #a2 pan2 #a0, 0.0
>>        outs #a1, a2
>>
>> There are some complications here that need to be figured out. Because
>> of overloading of opcodes on output type, we may need to extend the
>> explicit typing of opcode calls such that some situations may require:
>>
>> outs(*pan2:aa(vco2(0.5,440),0.0))
>>
>> with the types given for multiple output args.  I have further
>> questions about how this might interact with new-style UDO syntax.
>>
>> Just FYI, we discussed other multiple value return implementations,
>> namely Common Lisp's multiple-value-bind, Lua, Go, Matlab/Octave, and
>> Python.  Some of these do not allow unpacking of args within
>> expressions, others do, but with limitations (only if at the end of an
>> arg list to a function). There's more to be done, but at least the
>> multiple return args is implemented now for the assignment case.
>>
>> 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

Date2015-03-10 22:26
Fromjoachim heintz
SubjectRe: [Cs-dev] Multiple Return Arguments for Function Calls
thanks, steven, for this instructive report!
curious to see the next step ...

	joachim


Am 09.03.2015 um 19:02 schrieb Steven Yi:
> Hi All,
>
> I wanted to let you know of a change I just put in to the
> feature/parser3 branch in response to some discussions I had with
> Victor and John.  The following is now accepted:
>
> instr 1
> a1, a2 = pan2(vco2(0.5,440), 0.0)
> outs a1, a2
> endin
>
> Previously, functions could only return a single argument.  With the
> latest change, a top-most function can return multiple arguments if it
> is together with an assignment. The above ends up essentially being
> rewritten as:
>
> a1, a2  pan2  vco2(0.5,440), 0.0
>
> Victor has mentioned some things about doing argument unpacking within
> function calls.  This could look something like python's tuple
> unpacking, which would allow:
>
> outs(*pan2(vco2(0.5,440),0.0))
>
> which would get compiled as:
>
> #a0 vco2 0.5,440
> #a1, #a2 pan2 #a0, 0.0
>         outs #a1, a2
>
> There are some complications here that need to be figured out. Because
> of overloading of opcodes on output type, we may need to extend the
> explicit typing of opcode calls such that some situations may require:
>
> outs(*pan2:aa(vco2(0.5,440),0.0))
>
> with the types given for multiple output args.  I have further
> questions about how this might interact with new-style UDO syntax.
>
> Just FYI, we discussed other multiple value return implementations,
> namely Common Lisp's multiple-value-bind, Lua, Go, Matlab/Octave, and
> Python.  Some of these do not allow unpacking of args within
> expressions, others do, but with limitations (only if at the end of an
> arg list to a function). There's more to be done, but at least the
> multiple return args is implemented now for the assignment case.
>
> 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