Boost logo

Boost :

Subject: Re: [boost] [Boost.Breakable] Any interest in a Boost Breakable library?
From: Pierre Morcello (pmorcell-cppfrance_at_[hidden])
Date: 2009-09-07 02:14:41


Thanks Michael, I did not think sooner to the 'else if'. But there is one problem with the 'else if' : you can not do calculations between the tests.

When I work often my code looks like :

// retrieve meshes from prototype
Breakable
{
    // find loaded meshes
    std::set<Mesh*> lLoadedMeshes;
    {
       // some calculations that fill lLoadedMeshes
    }

    if(lLoadedMeshes.empty())
    {
       break;
    }

    // find loadable scenes that uses the already loaded meshes
    std::set<Scene*> lLoadableScenes;
    {
       // some calculations that fill lLoadableScenes
       // it uses the result of lLoadedMeshes
    }

    // and so on..
}

In that case, the 'breakable' is justified in my opinion, whereas in the example you gave, the 'else if ' seems even simplier.

--- En date de : Dim 6.9.09, Michael Caisse <boost_at_[hidden]> a écrit :

De: Michael Caisse <boost_at_[hidden]>
Objet: Re: [boost] [Boost.Breakable] Any interest in a Boost Breakable library?
À: boost_at_[hidden]
Date: Dimanche 6 Septembre 2009, 22h43

Pierre Morcello wrote:
> Breakable
> {
>   if(!filestream.bad())
>   {
>       log("error at opening file");
>       break;
>   }
>
>   if(!filestream.good())
>   {
>      log("error inside the file (eof)");
>      break;
>   }
>
>   if(!xmlLoadFrom(filestream))
>   {
>      log("the file is no xml document.");
>      break;      }
>     // and so on, to test if the xml is valid, etc...
> }
>
>   

And why not just add the else?

 if(!filestream.bad())
 {
    log("error at opening file");
 }
 else if(!filestream.good())
 {
    log("error inside the file (eof)");
 }
 else if(!xmlLoadFrom(filestream))
 {
    log("the file is no xml document.");
 }

-- 
----------------------------------
Michael Caisse
Object Modeling Designs
www.objectmodelingdesigns.com
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk