There is an inelegant but highly effective "hack" in GCC/G++ in thuas area.
Since C/C++ are expression language as Rob put it (e.g. a statement like
"3" compiles where in Go it fails with "3 evaluated but not used") GCC took
this a step further and implemented that the last expression evaluated in a
block is the value of that block. This makes "x = {if (a>b) then 7 else
2;}" do what "x = (a>b)?7:2" means but allows any and all code in there.
Won't work in Go because of "3 evaluated but not used" but I've used it
gratefully in macro situations in the past.

On Wed, Dec 19, 2018 at 9:39 PM Jan Mercl <0xj...@gmail.com> wrote:

> On Wed, Dec 19, 2018 at 9:16 PM Jan Mercl <0xj...@gmail.com> wrote:
>
> >> On Wed, Dec 19, 2018 at 9:09 PM Viktor Kojouharov <
> vkojouha...@gmail.com> wrote:
> >>
> >> I'm interested to know whether it was considered (I can't imagine that
> it wasn't) for if and switch statements to be expressions instead
> >
> > I can't imagine it was considered. Is there a precedence in other
> language? Not even C supports that.
>
> FTR: The above about C stands. If statement is not a conditional
> expression. They have different semantics and different syntax. Other
> answers in this thread assume OP is actually asking about conditional
> expressions.
>
> --
>
> -j
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


-- 

*Michael T. jonesmichael.jo...@gmail.com <michael.jo...@gmail.com>*

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to