[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-patch-tracker] [patch #8417] Consolidate large conditional type
From: |
David Spies |
Subject: |
[Octave-patch-tracker] [patch #8417] Consolidate large conditional type decisions |
Date: |
Mon, 24 Mar 2014 02:55:03 +0000 |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0 |
URL:
<http://savannah.gnu.org/patch/?8417>
Summary: Consolidate large conditional type decisions
Project: GNU Octave
Submitted by: dspyz
Submitted on: Mon 24 Mar 2014 02:55:01 AM GMT
Category: None
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
While working on the "find" function, I was annoyed by the large "if-else-if"
list of conditionals which all do exactly the same thing (check if the input
matrix is a particular type and then call the "real" find function with the
proper template type). I had to go down the list of calls and add a fourth
parameter to each and every one. There should be utility "dispatcher"
functions which take a functor template template and an octave_value_list of
arguments and call the functor with the proper template argument. Then calls
such as the long conditional statement in "find" can be consolidated into one
place rather than having to have them for every single function which can take
multiple types. And if a function call needs to be changed, it only needs to
be changed in one place.
I've attached an example for how to do this with find (this also includes my
changes from https://savannah.gnu.org/patch/?8386 sans the fourth parameter).
Now any other function which takes the same matrix types as "find" as an
argument can call the same "dispatch_all" function to call the functor with
the proper template argument.
For functions which take multiple arguments with variable types, this can be
done by nesting the functors (kind of like currying. If you'd like I can give
an example).
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Mon 24 Mar 2014 02:55:02 AM GMT Name: consolidate_dispatcher.diff
Size: 24kB By: dspyz
<http://savannah.gnu.org/patch/download.php?file_id=31016>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/patch/?8417>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Octave-patch-tracker] [patch #8417] Consolidate large conditional type decisions,
David Spies <=