URL:
  <http://gna.org/patch/?4558>

                 Summary: [RFC] Help generator: generalize
unit_type_fulfills_requirement()
                 Project: Freeciv
            Submitted by: sveinung
            Submitted on: Fri 28 Feb 2014 04:08:51 PM UTC
                Category: client
                Priority: 5 - Normal
                  Status: Need Info
                 Privacy: Public
             Assigned to: sveinung
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 2.6.0

    _______________________________________________________

Details:

I would like to generalize generalize unit_type_fulfills_requirement() by
splitting out the utype specific checks so I can reuse it for other universal
kinds. My current design is to define two helper functions that is used by
unit_type_fulfills_requirement(). The first helper function is a parameter to
the second. Is this the preferred way to do this in C or is something else
(like macros) preferred?

Reasons why I ask:
* I didn't find a way to send the utype to the utype specific code (like
partial application <http://en.wikipedia.org/wiki/Partial_application> or a
closure <http://en.wikipedia.org/wiki/Closure_%28computer_science%29>) in
unit_type_fulfills_requirement(). This makes me suspect C isn't meant to be
used this way. (I don't mind passing the parameter to the first helper
function in the second helper function. I just wonder if this is a hint)
* I don't know the details of the performance characteristics for gcc compiled
C code. I therefore don't know if this approach will make things slow or not.
* I don't know if other C developers reading the code easily will recognize
this pattern. I see call back functions used in the gui code of the clients
but for all I know it could be specific to GUI programming.




    _______________________________________________________

Reply to this item at:

  <http://gna.org/patch/?4558>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to