#] #] ********************* #] loaddefs link d_Qndfs 'type_check.ndf' - Routines for implementing checking of data types www.BillHowell.ca ?date initial?, reformated 09Feb2021 f_typeCheck := 'type_check.ndf' ; loaddefs_start f_typeCheck ; #**************************** # List of operators, generated with : # $ cat "$d_Qndfs""type_check.ndf" | grep "^#]" | sed 's/^#\]/ /' # #*********** # default type_checking is FALSE global_typecheck := o ; # Standard types global_object_types := [ "boolean "isboolean, "char "ischar, "fault "isfault, "int "isinteger, "list "islist, "phrase "isphrase, "real "isreal, "solitary "issolitary, "string "isstring ] # what is a list? Here its assume that a list is a 1 dimensional array of atomic data - which is NOT the full definition of a list in Nial! IF flag_debug THEN write 'loading islist' ; ENDIF ; #] islist IS OP data { IF tally TWIG shape data = 1 THEN l ELSE o ENDIF } - islist IS OP data { IF tally TWIG shape data = 1 THEN l ELSE o ENDIF } IF flag_debug THEN write 'loading type_check' ; ENDIF ; #] type_check IS OP object_type data - type_check IS OP object_type data { type_tests := object_types|[FIND object_type first object_types, 1] ; IF AND (AND = EACH shape type_tests data) (AND (type_tests TWIG apply data)) THEN l ELSE o ENDIF } #Examples IF global_typecheck THEN type_check_result := EACH type_check ["int net_model, "int out_model, "int out_linear, "int n_inputs, "int n_hidden1, "int n_hidden2, "int n_outputs, "int executable, "int zero] ; IF NOT AND type_check_result THEN return 'LayerNet type error' typecheck_result ; ENDIF; ENDIF; loaddefs_ended f_typeCheck ; # enddoc