Hi,
it is c-style *switch* replacement, to simplify statements like this:

transport       = &if (&eq('@cycle@', '1'), '@btl_openib@' ,\
                     &if (&eq('@cycle@', '2'), '@btl_openib@',\
                       &if (&eq('@cycle@', '3'), '@btl_eth10g@',\
                         &if (&eq('@cycle@', '4'), '@btl_eth10g@',\
                           &if (&eq('@cycle@', '3a'), '@btl_eth10g@ -x
custom_noswitchconnect=1',\
                             &if (&eq('@cycle@', '4a'), '@btl_eth10g@ -x
custom_noswitchconnect=1',\
                               &if (&eq('@cycle@', '5'), '@btl_eth10g@',\
                                 &if (&eq('@cycle@', '6'), '@btl_eth10g@',\
                                   &if (&eq('@cycle@', '7'), '@btl_eth10g@
',\
                                     &if (&eq('@cycle@', '8'), '@btl_eth10g@
',\
                                       &if (&eq('@cycle@', '11'),
'@btl_eth10g@',\
                                         &if (&eq('@cycle@', '12'),
'@btl_eth10g@',\
                                           '@btl_rdmaoe@'\
                                         )\
                                       )\
                                     )\
                                   )\
                                 )\
                               )\
                             )\
                           )\
                         )\
                       )\
                    )\
                  )

which can be rewritten as:

transport = mtt_switch(@cycle@, 1, @btl_openib@, 2, @btl_eth10g@, ...)

Will update wiki as well.


Regards



On Mon, Jan 3, 2011 at 2:54 PM, Jeff Squyres <jsquy...@cisco.com> wrote:

> Mike --
>
> Can you explain this one a little?  I don't understand the example you gave
> in the comment.
>
> Also, are you adding all the new funclets to the wiki documentation?
>
>
>
> On Dec 29, 2010, at 3:52 AM, mi...@osl.iu.edu wrote:
>
> > Author: miked
> > Date: 2010-12-29 03:52:24 EST (Wed, 29 Dec 2010)
> > New Revision: 1377
> > URL: https://svn.open-mpi.org/trac/mtt/changeset/1377
> >
> > Log:
> > added mtt_switch to simplify if-then-else cases in ini files
> >
> > Text files modified:
> >   trunk/lib/MTT/Values/Functions.pm |    21 +++++++++++++++++++++
> >   1 files changed, 21 insertions(+), 0 deletions(-)
> >
> > Modified: trunk/lib/MTT/Values/Functions.pm
> >
> ==============================================================================
> > --- trunk/lib/MTT/Values/Functions.pm (original)
> > +++ trunk/lib/MTT/Values/Functions.pm 2010-12-29 03:52:24 EST (Wed, 29
> Dec 2010)
> > @@ -3163,4 +3163,25 @@
> >       return $x->{result_stdout};
> > }
> >
> > +#
> > +# Poor man switch statement
> > +# Example: mtt_switch(@np@, 9, "return1", 100, return2", "default", 0);
> > +#
> > +
> > +sub mtt_switch
> > +{
> > +    my ($var, %cases) = @_;
> > +
> > +    if ($cases{$var}) {
> > +        return $cases{$var};
> > +    }
> > +
> > +    if ($cases{'default'}) {
> > +        return $cases{'default'};
> > +    }
> > +
> > +    Debug("ERROR: Not found case for $var\n");
> > +}
> > +
> > +
> > 1;
> > _______________________________________________
> > mtt-svn mailing list
> > mtt-...@open-mpi.org
> > http://www.open-mpi.org/mailman/listinfo.cgi/mtt-svn
>
>
> --
> Jeff Squyres
> jsquy...@cisco.com
> For corporate legal information go to:
> http://www.cisco.com/web/about/doing_business/legal/cri/
>
>

Reply via email to