Maple für Professional
Maple für Akademiker
Maple für Studenten
Maple Personal Edition
Maple Player
Maple Player für iPad
MapleSim für Professional
MapleSim für Akademiker
Maple T.A. - Testen & beurteilen
Maple T.A. MAA Placement Test Suite
Möbius - Online-Courseware
Machine Design / Industrial Automation
Luft- und Raumfahrt
Fahrzeugtechnik
Robotics
Energiebranche
System Simulation and Analysis
Model development for HIL
Anlagenmodelle für den Regelungsentwurf
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematikausbildung
Technik
Allgemein- und berufsbildende Schulen
Testen und beurteilen
Studierende
Finanzmodelle
Betriebsforschung
Hochleistungsrechnen
Physik
Live-Webinare
Aufgezeichnete Webinare
Geplante Veranstaltungen
MaplePrimes
Maplesoft-Blog
Maplesoft-Mitgliedschaft
Maple Ambassador Program
MapleCloud
Technische Whitepapers
E-Mail Newsletters
Maple-Bücher
Math Matters
Anwendungs-Center
MapleSim Modell-Galerie
Anwenderberichte
Exploring Engineering Fundamentals
Lehrkonzepte mit Maple
Maplesoft Welcome-Center
Resource-Center für Lehrer
Help-Center für Studierende
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