Reflection/List methods: Difference between revisions

added Factor
(added Factor)
Line 89:
o.myMethod2[1]
o.$mytest'MyClass
</pre>
 
=={{header|Factor}}==
In Factor, methods are contained in generic words rather than objects, while methods specialize on a class. Therefore, the programmer must decide whether they want the list of methods in a generic word, or the list of methods that specialize on a class. Luckily, the <tt>methods</tt> word can do either depending on what type you give it (a word or a class). The returned sequence contains first-class word values suitable for executing.
<lang factor>USING: io math prettyprint see ;
 
"The list of methods contained in the generic word + :" print
\ + methods . nl
 
"The list of methods specializing on the fixnum class:" print
fixnum methods .</lang>
{{out}}
<pre>
The list of methods contained in the generic word + :
{ M\ bignum + M\ complex + M\ fixnum + M\ float + M\ ratio + }
 
The list of methods specializing on the fixnum class:
{
M\ fixnum '
M\ fixnum (bit-count)
M\ fixnum (eql?)
M\ fixnum (log2)
M\ fixnum (positive>dec)
M\ fixnum (random-integer)
M\ fixnum *
M\ fixnum +
M\ fixnum -
M\ fixnum /f
M\ fixnum /i
M\ fixnum /mod
M\ fixnum <
M\ fixnum <=
M\ fixnum >
M\ fixnum >=
M\ fixnum >bignum
M\ fixnum >fixnum
M\ fixnum >float
M\ fixnum >integer
M\ fixnum ^n
M\ fixnum bit?
M\ fixnum bitand
M\ fixnum bitnot
M\ fixnum bitor
M\ fixnum bitxor
M\ fixnum eql?
M\ fixnum equal?
M\ fixnum hashcode*
M\ fixnum integer>fixnum
M\ fixnum integer>fixnum-strict
M\ fixnum max
M\ fixnum min
M\ fixnum mod
M\ fixnum number=
M\ fixnum real<=>
M\ fixnum shift
M\ fixnum u<
M\ fixnum u<=
M\ fixnum u>
M\ fixnum u>=
}
</pre>
 
1,808

edits