Code sprint: pkg.m: Difference between revisions

1,025 bytes added ,  20 November 2012
Line 35: Line 35:
== Dispatching ==
== Dispatching ==


Each action has its own set of valid modifiers and behaves accordingly. Therefore the rôle of the main function ''pkg''
Each action has its own set of valid modifiers and behaves accordingly. Therefore the rôle of the main function ''pkg'' is to call the right action once general sanity checks have been performed.
The particular implementation of this dispatch behavior was source of some discussion.
* Using structure
: One way of implementing the dispatch is using structures with fieldnames equal to the action and containing a function handle. [http://agora.octave.org/snippet/5UUz/ Here is an example].
: Some people do not like this because they consider it a weird use of a structure.
* Using feval
: Another way of doing it (and the implemented as of revision 2c16a852bae9 in carandraug's repository) is building a string of the function to call and use feval. [http://agora.octave.org/snippet/ozym/ Here the example]
* Using objects
: Where we have an ''action'' class with fields valid_modifiers and method parse_modfiers. All ''_pkg'' actions inherit the general valid_modifiers and extend them with their own, as well as overloading the parser_modifier method. This gives the maximum flexibility, but since is too much of a change we haven't code it.


= Desired features =
= Desired features =
657

edits