• [^] # Re: Python pour scripter, C/C++ sous la capot.

    Posté par . En réponse au journal Un Python qui rivalise avec du C++. Évalué à 5. Dernière modification le 31 août 2017 à 06:26.

    Ce que tu veux (si je comprend bien) date de fortran 90. Par contre cela te force à faire le méthode à la main la ou c++, il me semble, permet des trucs plus automatique.

    En gros cela se résume à faire un module, un type, les méthodes associées suivant tes type en entrée, définir l'interface nommé ou tu mets juste le nom des méthodes.

    3.3.3 Generic procedures

    Modules allow arguments of derived type and hence generic procedures with derived types:

    MODULE genswap
    IMPLICIT NONE

    TYPE point
    REAL :: x, y
    END TYPE point

    INTERFACE swap
    MODULE PROCEDURE swapreal, swapint, swaplog, swappoint
    END INTERFACE

    CONTAINS

    SUBROUTINE swappoint (a,b)
    IMPLICIT NONE
    TYPE (point), INTENT(INOUT) :: a, b
    TYPE (point) :: temp
    temp = a
    a = b
    b = temp
    END SUBROUTINE swappoint

    SUBROUTINE swapreal (a, b)
    IMPLICIT NONE
    REAL, INTENT(INOUT) :: a,b
    REAL :: temp
    temp=a
    a=b
    b=temp
    END SUBROUTINE swapreal

    !similar subroutines for swapint and swaplog

    ...
    END MODULE genswap