math-combination - Factor Documentation

math-combination


Vocabulary
generic .math

Inputs
None

Outputs
None

Word description
Generates a double-dispatching word definition. Only methods defined on numerical classes and object take effect in the math combination. Methods defined on numerical classes are guaranteed to have their two inputs upgraded to the highest priority type of the two.

The math method combination is used for binary operators such as + and * .

A method can only be added to a generic word using the math combination if the method specializes on one of the below classes, or a union defined over one or more of the below classes:
fixnum bignum ratio float complex object

The math combination performs numerical upgrading as described in Number protocol .

Definition
IN: generic.math

SINGLETON: math-combination


Methods
USING: generic generic.math kernel ;

M: math-combination make-default-method
drop default-math-method ;


USING: generic generic.math generic.math.private kernel
namespaces words ;

M: math-combination perform-combination
drop dup generic-word [
dup
[ over ] [
dup math-class?
[ [ dup ] [ math-method ] 2with math-dispatch-step ]
[ drop object-method ] if
] with math-dispatch-step fixnum-optimization define
] with-variable ;

AltStyle によって変換されたページ (->オリジナル) /