Thanks Philippe! Great solution!

I have two remarks.

Remark 1: I understand that your mixin will be expanded into cascaded if...else statements. It would probably be more efficient to expand into switch...case, don't you think?

Remark 2: I infer from your code that the "delegate" keyword is not mandatory, so my solution could also be called like this:

mixin Select!(value,
  if0, { then0(); },
  if1, { then1(); },
  if2, { foo(); bar(); },
  { thenDefault(); }
);

instead of:

mixin Select!(value,
  if0, delegate { then0(); },
  if1, delegate { then1(); },
  if2, delegate { foo(); bar(); },
  delegate { thenDefault(); }
);

Is that correct?


Reply via email to