[Issue 3699] Feature Request: while-else

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 12 10:42:10 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3699



--- Comment #2 from ibrahim YANIKLAR <yanikibo at gmail.com> 2010-01-12 10:42:09 PST ---
> What should this do?
> 
> if (c1)
>     while (c2)
>         stmt1
>     else
>         stmt2
> 


if (c1)
{
    while (c2)
        stmt1
    else
        stmt2
}

It should do that of course.

> And in particular, how would you reconcile existing code with the new feature?

In such situations the compiler can warn the developer, perhaps it can be bound
to -w switch. 

General the developers uses this form:

if (c1)
{
    while (c2)
        stmt1
}
else
    stmt2

instead of:

if (c1)
    while (c2)
        stmt1
else
    stmt2

D2 is in alpha status, isn't it. I see some changes on D2 that breaks code.
You should decide whether the new feature is important and necessary enough to
accept the risk of code breaks or not. 

I usually feel the need for that feature.

an example on fetching rows from db:

while (row = query.nextRow())
    writeln(row);
else
    writeln("no row");

It's really a nice feature. I think D should collect all the nice features
itself.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list