<commit_before>! Copyright (C) 2006, 2008 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors words kernel sequences namespaces assocs
hashtables definitions kernel.private classes classes.private
classes.algebra quotations arrays vocabs effects combinators
sets ;
IN: generic

! Method combination protocol
GENERIC: perform-combination ( word combination -- )

GENERIC: make-default-method ( generic combination -- method )

PREDICATE: generic < word
    "combination" word-prop >boolean ;

M: generic definition drop f ;

: make-generic ( word -- )
    [ { "unannotated-def" } reset-props ]
    [ dup "combination" word-prop perform-combination ]
    bi ;

: method ( class generic -- method/f )
    "methods" word-prop at ;

PREDICATE: method-spec < pair
    first2 generic? swap class? and ;

: order ( generic -- seq )
    "methods" word-prop keys sort-classes ;

: specific-method ( class generic -- method/f )
    tuck order min-class dup [ swap method ] [ 2drop f ] if ;

GENERIC: effective-method ( generic -- method )

: next-method-class ( class generic -- class/f )
    order [ class<= ] with filter reverse dup length 1 =
    [ drop f ] [ second ] if ;

: next-method ( class generic -- class/f )
    [ next-method-class ] keep method ;

GENERIC: next-method-quot* ( class generic combination -- quot )

: next-method-quot ( class generic -- quot )
    dup "combination" word-prop next-method-quot* ;

: (call-next-method) ( class generic -- )
    next-method-quot call ;

TUPLE: check-method class generic ;

: check-method ( class generic -- class generic )
    over class? over generic? and [<commit_msg>Fix typo<commit_after>! Copyright (C) 2006, 2008 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors words kernel sequences namespaces assocs
hashtables definitions kernel.private classes classes.private
classes.algebra quotations arrays vocabs effects combinators
sets ;
IN: generic

! Method combination protocol
GENERIC: perform-combination ( word combination -- )

GENERIC: make-default-method ( generic combination -- method )

PREDICATE: generic < word
    "combination" word-prop >boolean ;

M: generic definition drop f ;

: make-generic ( word -- )
    [ { "unannotated-def" } reset-props ]
    [ dup "combination" word-prop perform-combination ]
    bi ;

: method ( class generic -- method/f )
    "methods" word-prop at ;

PREDICATE: method-spec < pair
    first2 generic? swap class? and ;

: order ( generic -- seq )
    "methods" word-prop keys sort-classes ;

: specific-method ( class generic -- method/f )
    tuck order min-class dup [ swap method ] [ 2drop f ] if ;

GENERIC: effective-method ( generic -- method )

: next-method-class ( class generic -- class/f )
    order [ class<= ] with filter reverse dup length 1 =
    [ drop f ] [ second ] if ;

: next-method ( class generic -- method/f )
    [ next-method-class ] keep method ;

GENERIC: next-method-quot* ( class generic combination -- quot )

: next-method-quot ( class generic -- quot )
    dup "combination" word-prop next-method-quot* ;

: (call-next-method) ( class generic -- )
    next-method-quot call ;

TUPLE: check-method class generic ;

: check-method ( class generic -- class generic )
    over class? over generic? and [
{'fraction_non_alphanumeric': 0.11468446601941748, 'fraction_numerical': 0.006674757281553398, 'mean_word_length': 3.2161125319693094, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5688889', 'n_tokens_mistral': 991, 'n_tokens_neox': 963, 'n_words': 319}