|
Boost : |
From: Joel de Guzman (joel_at_[hidden])
Date: 2003-10-17 22:57:44
Powell, Gary <powellg_at_[hidden]> wrote:
> Actually,
>
> switch_(condition)
> [
> case_(label1)[expr1],
> case_(label2)[expr2],
> case_(label3)[expr3]
> default_[expr4]
> ]
> ----------------------------------
> has problems with "default_[expr4]"
Sorry, typo--missing comma :o"
> but I think
>
> switch_(condition)
> [
> case_(label1)[expr1],
> case_(label2)[expr2],
> case_(label3)[expr3]
> .default_[expr4]
> ]
>
> or
> switch_(condition)
> [
> case_(label1)[expr1],
> case_(label2)[expr2],
> case_(label3)[expr3],
> default_(expr4)
> ]
>
> could be made to work.
>
> The nice thing about having .default is that it could end the sequence of
> case_()[]'s by generating a unique expression template which would not allow
> either a operator,(expression) or operator,(case_expression).
I prefer the comma, for consistency. Also, I think this should be
legal (as it is in plain C++):
switch_(condition)
[
default_(expr4),
case_(label1)[expr1],
case_(label2)[expr2],
case_(label3)[expr3]
]
> what you also want to avoid is allowing:
>
> switch_(condition)
> [
> case_(label1)[expr1],
> expr1a,
> case_(label2)[expr2],
> case_(label3)[expr3]
> .default_[expr4]
> ]
>
> or
>
> switch_(condition)
> [
> case_(label1),
> expr1,
> case_(label2)[expr2],
> case_(label3)[expr3]
> .default_[expr4]
> ]
>
> or
> switch_(condition)
> [
> case_(label1),
> expr1,
> case_(label2)[expr2]
> .default_[expr4],
> case_(label3)[expr3]
>
> ]
>
> where a useless expression is inserted into the middle of the case statements.
Right. Those should be illegal.
> BTW, Jaakko and I did most of this work a while ago, playing around, but if
> Phoenix-2 the merger of LL and Phoenix is due out, there is no point in
> pushing updates to LL.
Cool! I'll reply to this in another email and let's discuss this off list....
Cheers,
-- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk