Missed opportunities
Missed opportunities
Posted Jun 10, 2013 8:11 UTC (Mon) by jezuch (subscriber, #52988)In reply to: Missed opportunities by ncm
Parent article: Little things that matter in language design
> we sometimes see
>
> Ob::Ob
> ( int a
> , int b
> , int c
> )
> : _x( a + b - c)
> , _y( a - b + c)
> , _z(-a + b + c)
> {}
>
> enum T
> { T1
> , T2
> , T3
> };
>
> Ob::Ob
> ( int a
> , int b
> , int c
> )
> : _x( a + b - c)
> , _y( a - b + c)
> , _z(-a + b + c)
> {}
>
> enum T
> { T1
> , T2
> , T3
> };
I've seen it in some projects and I agree it's ugly as heck, even though I understand the intention behind it. In Java the parser allows "extra" commas after the last element in some places like array initalizers and enum declarations. I'm not sure if this was an accidental omission or intentional but it's quite useful, e.g.:
Object[] arr = new Object[] {
obj1,
obj2,
obj3,
}
enum Test {
TEST1,
TEST2,
TEST3,
;
}
But it's not allowed in parameter lists, alas.