On 18 Sep 2014, at 02:47, buynnnm...@yahoo.co.jp wrote:

> Dear Alexander Konovalov,
> 
> Thank you very much for  your description with some execution examples!
> 
> I tried to run Copy and paste the example of you.It's very interesting.
> 
> I have not read the document you taught me yet, but I understand the point.
> I think that is similar to polymorphism of object-oriented programming 
> languages.

Yes, precisely! This is dynamic polymorphism. The method selected depends on 
types of all arguments, and objects may change their type during their lifetime.

For example, if there is a faster algorithm for a group for which it is known 
that is has some attribute X, you may install a generic method for IsGroup and
a specific for IsGroup and HasX. Then for a group without X a generic method 
will be called, while for the group for which X is known a specific method will
be called. This will not automatically enforce the calculation of X which may 
be expensive. 

This may be seen in the method that implements the Feit–Thompson theorem from
my mail yesterday:

InstallImmediateMethod( IsSolvableGroup, IsGroup and HasSize, 10,
   function( G )
   G:= Size( G );
   if IsInt( G ) and G mod 2 = 1 then
     return true;
   fi;
   TryNextMethod();
   end );

- it will be applied (automatically, since it is *immediate*) only if the Size
is already known, what is checked with HasSize.

You might be interested in the following paper which describes this in more 
details:

@inproceedings{Breuer:1998:GTS:281508.281540,
 author = {Breuer, Thomas and Linton, Steve},
 title = {The GAP 4 Type System: Organising Algebraic Algorithms},
 booktitle = {Proceedings of the 1998 International Symposium on Symbolic and 
Algebraic Computation},
 series = {ISSAC '98},
 year = {1998},
 isbn = {1-58113-002-3},
 location = {Rostock, Germany},
 pages = {38--45},
 numpages = {8},
 url = {http://doi.acm.org/10.1145/281508.281540},
 doi = {10.1145/281508.281540},
 acmid = {281540},
 publisher = {ACM},
 address = {New York, NY, USA},
} 

Best wishes
Alexander
_______________________________________________
Forum mailing list
Forum@mail.gap-system.org
http://mail.gap-system.org/mailman/listinfo/forum

Reply via email to