Maple Professionel
Maple Académique
Maple Edition Étudiant
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professionel
MapleSim Académique
Maple T.A. - Suite d'examens de classement
Maple T.A. MAA Placement Test Suite
Möbius - Didacticiels de mathématiques en ligne
Machine Design / Industrial Automation
Aéronautique
Ingénierie des véhicules
Robotics
Energie
System Simulation and Analysis
Model development for HIL
Modélisation du procédé pour la conception de systèmes de contrôle
Robotics/Motion Control/Mechatronics
Other Application Areas
Enseignement des mathématiques
Enseignement de l’ingénierie
Enseignement secondaire et supérieur (CPGE, BTS)
Tests et évaluations
Etudiants
Modélisation financière
Recherche opérationnelle
Calcul haute performance
Physique
Webinaires en direct
Webinaires enregistrés
Agenda des évènements
Forum MaplePrimes
Blog Maplesoft
Membres Maplesoft
Maple Ambassador Program
MapleCloud
Livres blancs techniques
Bulletin électronique
Livres Maple
Math Matters
Portail des applications
Galerie de modèles MapleSim
Cas d'Etudes Utilisateur
Exploring Engineering Fundamentals
Concepts d’enseignement avec Maple
Centre d’accueil utilisateur Maplesoft
Centre de ressources pour enseignants
Centre d’assistance aux étudiants
ModuleType - オブジェクトとタイプとして使用する場合にタイプチェックを調整
使い方
module() export ModuleType, ...; ... end module;
説明
モジュールは、type のコールの型指定、または :: 式で渡されます。デフォルトでは、モジュールは他のモジュールと同じモジュール条件を共有する場合にのみ、他のモジュールのタイプを考慮します。これは、同じクラスのすべての オブジェクト についてあてはまります。ModuleType メソッドは、モジュールがタイプとして与えられた場合にモジュールのタイプチェックを調整します。
ModuleType プロシージャを定義するモジュールがタイプとして与えられた場合は、与えられた式はそのタイプと一致するモジュールです。ModuleType プロシージャはタイプチェックをさらに調整するために呼び出される場合があります。
ModuleType プロシージャの呼び出しシーケンスは以下のとおりです。
export ModuleType::static := proc( M, typ, arg1, ... )
M : はタイプ typ と一致する場合に検証されるモジュール
typ : は ModuleType プロシージャが呼び出されたタイプ
arg1, ...: タイプ typ(arg1, ... で指定する追加引数)
ModuleType ルーチンは、含んでいるモジュールをタイプとして使用してタイプチェックを行いません。これは無限再帰になる可能性があります。
オブジェクトは type の無効化を実装可能で、複数タイプと一致するかどうかを判断できます。詳細は、object,builtin ヘルプページを参照してください。
互換性
ModuleType コマンドは Maple 16 で導入されました。
Maple 16 における変更点についての詳細は、Maple 16 の新機能 を参照してください。
例
module MyInt() option object; local value; export set::static := proc( obj::MyInt, v::integer ) obj:-value := v; end; export ModuleType::static := proc( obj, typ, arg ) if( _npassed = 2 ) then true; elif ( arg = 'prime' ) then :-type( obj:-value, 'prime' ); elif ( arg = 'odd' ) then :-type( obj:-value, 'odd' ); elif ( arg = 'even' ) then :-type( obj:-value, 'even' ); end; end; export ModuleApply::static := proc( ) Object( MyInt, _passed ); end; export ModuleCopy::static := proc( self::MyInt, proto::MyInt, v::integer, $ ) if ( _npassed = 2 ) then self:-value := 0; else self:-value := v; end; end; end: i2 := MyInt( 2 ): i5 := MyInt( 5 ): i9 := MyInt( 9 ):
type( i2, MyInt );
type( i2, 'MyInt'( prime ) );
type( i2, 'MyInt'( even ) );
type( i2, 'MyInt'( odd ) );
type( i5, MyInt );
type( i5, 'MyInt'( prime ) );
type( i5, 'MyInt'( even ) );
type( i5, 'MyInt'( odd ) );
type( i9, MyInt );
type( i9, 'MyInt'( prime ) );
type( i9, 'MyInt'( even ) );
type( i9, 'MyInt'( odd ) );
関連項目
::、module、ModuleApply、ModuleCopy、ModuleDeconstruct、ModuleIterator、ModuleLoad、ModulePrint、ModuleType、ModuleUnload、Object、Object,builtin、Object,overview、procedure, type
Download Help Document