I have a little suggestion: If julia is going to have switch, could we make 
it a bit better?

Basically the switch would take two parameters :* function* and* variable*. 
On each case it would would call the function with those two params, and if 
the functions would return true, it would evaluate the case block.

Note: the function has to return *boolean*.

Example

function divides(a, b)
  return a % b == 0
end

input = 119
switch(divides, input)
  case 2 # this can be translated as ~ if(divides(input, 2))
  case 3 # 3 divides input without remainder
  case 5 # 5 divides input without remainder
  case 7 # 7 divides input without remainder
end

Of course you could achieve the default switch behavior like this:
switch(==, input)
...


What do you think about it?

Reply via email to