Csound Csound-dev Csound-tekno Search About

Re: [Csnd] Problems With If-Then Statements: Switch

Date2012-10-12 18:09
Fromjohn ffitch
SubjectRe: [Csnd] Problems With If-Then Statements: Switch
Do people really want this?  Not two hard (with new parser)
>>>>> "David" == David Mooney  writes:

 David> This doesn't really address your problem, but when using multiple
 David> conditionals as you show I've often thought it would be handy if
 David> Csound had a switch structure, as in C++. Given the variable kval (or
 David> ival), and possible numerical values 1-n for kval, a switch looks like
 David> this:

 David> switch(kval) {
 David>   case 1:
 David>     
 David>   case 2:
 David>     
 David>   case 3:
 David>     
 David> .
 David> .
 David> .
 David>   case n:
 David>     
 David>   break
 David> }

 David>  All of the  codes could be kgoto."break" at the end stops
 David> the switch, which is generally used inside of a while loop. In C++,
 David> this is done using a blank case (case ' ') or a newline escape
 David> sequence (case '\n').

 David> Just a thought.

==John ffitch

Date2012-10-12 18:53
FromVictor Lazzarini
SubjectRe: [Csnd] Problems With If-Then Statements: Switch
Sounds like syntactic sugar to me. Fairly inoffensive, I'd say.
On 12 Oct 2012, at 18:09, john ffitch wrote:

> Do people really want this?  Not two hard (with new parser)
>>>>>> "David" == David Mooney  writes:
> 
> David> This doesn't really address your problem, but when using multiple
> David> conditionals as you show I've often thought it would be handy if
> David> Csound had a switch structure, as in C++. Given the variable kval (or
> David> ival), and possible numerical values 1-n for kval, a switch looks like
> David> this:
> 
> David> switch(kval) {
> David>   case 1:
> David>     
> David>   case 2:
> David>     
> David>   case 3:
> David>     
> David> .
> David> .
> David> .
> David>   case n:
> David>     
> David>   break
> David> }
> 
> David>  All of the  codes could be kgoto."break" at the end stops
> David> the switch, which is generally used inside of a while loop. In C++,
> David> this is done using a blank case (case ' ') or a newline escape
> David> sequence (case '\n').
> 
> David> Just a thought.
> 
> ==John ffitch
> 
> 
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





Date2012-10-12 18:58
FromSteven Yi
SubjectRe: [Csnd] Problems With If-Then Statements: Switch
Should we allow {} in new parser then too in place of then/endif ? or
only allow {} with switch?  Seems like we need to design this to be
consistent to be with until and if-then-else.

On Fri, Oct 12, 2012 at 6:53 PM, Victor Lazzarini
 wrote:
> Sounds like syntactic sugar to me. Fairly inoffensive, I'd say.
> On 12 Oct 2012, at 18:09, john ffitch wrote:
>
>> Do people really want this?  Not two hard (with new parser)
>>>>>>> "David" == David Mooney  writes:
>>
>> David> This doesn't really address your problem, but when using multiple
>> David> conditionals as you show I've often thought it would be handy if
>> David> Csound had a switch structure, as in C++. Given the variable kval (or
>> David> ival), and possible numerical values 1-n for kval, a switch looks like
>> David> this:
>>
>> David> switch(kval) {
>> David>   case 1:
>> David>     
>> David>   case 2:
>> David>     
>> David>   case 3:
>> David>     
>> David> .
>> David> .
>> David> .
>> David>   case n:
>> David>     
>> David>   break
>> David> }
>>
>> David>  All of the  codes could be kgoto."break" at the end stops
>> David> the switch, which is generally used inside of a while loop. In C++,
>> David> this is done using a blank case (case ' ') or a newline escape
>> David> sequence (case '\n').
>>
>> David> Just a thought.
>>
>> ==John ffitch
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>>
>
> Dr Victor Lazzarini
> Senior Lecturer
> Dept. of Music
> NUI Maynooth Ireland
> tel.: +353 1 708 3545
> Victor dot Lazzarini AT nuim dot ie
>
>
>
>
>
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>

Date2012-10-12 19:19
FromRory Walsh
SubjectRe: [Csnd] Problems With If-Then Statements: Switch
Yes please!

if(this==works){
....why not?
}





On 12 October 2012 18:58, Steven Yi  wrote:
> Should we allow {} in new parser then too in place of then/endif ? or
> only allow {} with switch?  Seems like we need to design this to be
> consistent to be with until and if-then-else.
>
> On Fri, Oct 12, 2012 at 6:53 PM, Victor Lazzarini
>  wrote:
>> Sounds like syntactic sugar to me. Fairly inoffensive, I'd say.
>> On 12 Oct 2012, at 18:09, john ffitch wrote:
>>
>>> Do people really want this?  Not two hard (with new parser)
>>>>>>>> "David" == David Mooney  writes:
>>>
>>> David> This doesn't really address your problem, but when using multiple
>>> David> conditionals as you show I've often thought it would be handy if
>>> David> Csound had a switch structure, as in C++. Given the variable kval (or
>>> David> ival), and possible numerical values 1-n for kval, a switch looks like
>>> David> this:
>>>
>>> David> switch(kval) {
>>> David>   case 1:
>>> David>     
>>> David>   case 2:
>>> David>     
>>> David>   case 3:
>>> David>     
>>> David> .
>>> David> .
>>> David> .
>>> David>   case n:
>>> David>     
>>> David>   break
>>> David> }
>>>
>>> David>  All of the  codes could be kgoto."break" at the end stops
>>> David> the switch, which is generally used inside of a while loop. In C++,
>>> David> this is done using a blank case (case ' ') or a newline escape
>>> David> sequence (case '\n').
>>>
>>> David> Just a thought.
>>>
>>> ==John ffitch
>>>
>>>
>>> Send bugs reports to the Sourceforge bug tracker
>>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>>> Discussions of bugs and features can be posted here
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>>>
>>
>> Dr Victor Lazzarini
>> Senior Lecturer
>> Dept. of Music
>> NUI Maynooth Ireland
>> tel.: +353 1 708 3545
>> Victor dot Lazzarini AT nuim dot ie
>>
>>
>>
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>>
>
>
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>

Date2012-10-15 21:47
FromLouis Cohen
SubjectRe: [Csnd] Problems With If-Then Statements: Switch
Or how about the more general:

switch{
	case 
		
	case 
		
	case 
		
	case 
		
	break}
...

-Lou


On Oct 12, 2012, at 1:09 PM, john ffitch wrote:

> Do people really want this?  Not two hard (with new parser)
>>>>>> "David" == David Mooney  writes:
>
> David> This doesn't really address your problem, but when using  
> multiple
> David> conditionals as you show I've often thought it would be handy  
> if
> David> Csound had a switch structure, as in C++. Given the variable  
> kval (or
> David> ival), and possible numerical values 1-n for kval, a switch  
> looks like
> David> this:
>
> David> switch(kval) {
> David>   case 1:
> David>     
> David>   case 2:
> David>     
> David>   case 3:
> David>     
> David> .
> David> .
> David> .
> David>   case n:
> David>     
> David>   break
> David> }
>
> David>  All of the  codes could be kgoto."break" at the end  
> stops
> David> the switch, which is generally used inside of a while loop.  
> In C++,
> David> this is done using a blank case (case ' ') or a newline escape
> David> sequence (case '\n').
>
> David> Just a thought.
>
> ==John ffitch
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>


Date2012-10-15 21:55
FromJustin Smith
SubjectRe: [Csnd] Problems With If-Then Statements: Switch
break is either not needed at all, or needed after every case that
should not fallthrough.

break after the last case will never do anything, since there is
nowhere for that case to fallthrough to.

On Mon, Oct 15, 2012 at 1:47 PM, Louis Cohen  wrote:
> Or how about the more general:
>
> switch{
>         case 
>                 
>         case 
>                 
>         case 
>                 
>         case 
>                 
>         break}
> ...
>
> -Lou
>
>
>
> On Oct 12, 2012, at 1:09 PM, john ffitch wrote:
>
>> Do people really want this?  Not two hard (with new parser)
>>>>>>>
>>>>>>> "David" == David Mooney  writes:
>>
>>
>> David> This doesn't really address your problem, but when using multiple
>> David> conditionals as you show I've often thought it would be handy if
>> David> Csound had a switch structure, as in C++. Given the variable kval
>> (or
>> David> ival), and possible numerical values 1-n for kval, a switch looks
>> like
>> David> this:
>>
>> David> switch(kval) {
>> David>   case 1:
>> David>     
>> David>   case 2:
>> David>     
>> David>   case 3:
>> David>     
>> David> .
>> David> .
>> David> .
>> David>   case n:
>> David>     
>> David>   break
>> David> }
>>
>> David>  All of the  codes could be kgoto."break" at the end stops
>> David> the switch, which is generally used inside of a while loop. In C++,
>> David> this is done using a blank case (case ' ') or a newline escape
>> David> sequence (case '\n').
>>
>> David> Just a thought.
>>
>> ==John ffitch
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>