Select & Try..Catch block syntax limitations

BlitzMax Forums/BlitzMax Programming/Select & Try..Catch block syntax limitations

SuperStrict

Framework brl.blitz

Import brl.standardio

Try
	Throw("doh!")
Catch(e:String) ' Fails
	Print(e)
End Try

Local i:Int = 10

Select(i) ' Yay!
	
	Case(0) ' Works..
	Case(5, 10) ' Fails..
	
End Select


Works here, you have to remove the () after the catch and case

Works here, you have to remove the () after the catch and case
I know that. Hence 'syntax limitations'.

Why allow the parentheses on a single argument to Case but not on multiples?

The parenthesis is being treated as an expression; (0)= 0, but (5, 10) is a syntax error.

Edit: Select/Case are keywords not function calls.

Edit: Select/Case are keywords not function calls.
I understand that. The (0)=0 point is interesting..

Thats just my coding style, I don't like open ended keywords/functions, regardless if they return something.

You can use parenthesis the way you tried, but like this:

Case (5),(10)

I don't know why you would want to though.

I don't know why you would want to though.


I also prefer Select/Case above a elseif construction, it feels cleaner.
Why wouldn't you use it? Ofcource you're going to run into situations where a variable can have more than one value for which you want to execute the same code.

I think he meant, "why would you want to use the parenthesis" in his example - since they don't do anything other than add clutter.
Different if you are using a complex expression instead, of course.

Case (5),(10)
I don't know why you would want to though.
Why would anyone want to do it like that?
Like I said before.. I just prefer to use parentheses at the end of certain keywords.

I hadn't noticed the effect (0) had until it was noted, which pretty much declares this not even a feature in the syntax.

I understand that. The (0)=0 point is interesting..
How is it interesting? The parenthesis is just part of the expression, like (1+2) is the same as 1+2 which is evaluated at compile time to 3.

I usually use parentheses for function calls or expressions in which I need to change the operator precedence.

How is it interesting? The parenthesis is just part of the expression, like (1+2) is the same as 1+2 which is evaluated at compile time to 3.
Something can't be interesting if I hadn't noticed it before posting?

I fully understand that using parentheses is solving an equation, and I knew that before, I just never noticed it in this case because it didn't seem to fit.