Feature request: extending comma operator's functionality
monarch_dodra
monarchdodra at gmail.com
Thu Oct 4 14:23:44 PDT 2012
On Thursday, 4 October 2012 at 21:17:51 UTC, Tommi wrote:
> Could you change it so that expressions, that are separated by
> commas and inside an if-clause, would have visibility to the
> variable defined in the first expression? Easier to show than
> to explain:
> [SNIP]
A language change sounds excessive for something that simple
blocks could fix:
int getInt()
{
return 11;
}
void main()
{
{
int n = getInt();
if (n > 10) // OK
{
//...
}
}
{
int n = getInt(); ++n;
if (n > 10) // OK
{
//...
}
}
{
int n = getInt();
if (getInt() > 10) // OK
{
//...
}
}
}
Been doing this in C++ for a while actually.
More information about the Digitalmars-d
mailing list