-bool
-type_check_assignment (SCM val, SCM sym, SCM type_symbol)
-{
- bool ok = true;
- SCM type_p = SCM_EOL;
- SCM errport = scm_current_error_port ();
-
- if (gh_symbol_p(sym))
- type_p = scm_object_property (sym, type_symbol);
-
- if (type_p != SCM_EOL && !gh_procedure_p (type_p))
- {
- /* warning () ? */
- scm_puts (_f ("Can't find property type-check for `%s'. Perhaps you made a typing error?",
- ly_symbol2string (sym).ch_C ()).ch_C (),
- errport);
- scm_puts ("\n", errport);
- }
- else
- {
- if (val != SCM_EOL
- && gh_procedure_p (type_p)
- && gh_call1 (type_p, val) == SCM_BOOL_F)
- {
- ok = false;
- scm_puts (_("Failed typecheck for `").ch_C (),errport);
- scm_display (sym,errport);
- scm_puts ( _("', value `").ch_C (), errport);
- scm_write (val, errport);
- scm_puts (_("' must be of type ").ch_C (), errport);
- SCM typefunc = scm_eval2 (ly_symbol2scm ("type-name"), SCM_EOL);
- scm_display (gh_call1 (typefunc, type_p), errport);
- scm_puts ("\n", errport);
-#if 0
- ok = false;
- SCM typefunc = scm_eval2 (ly_symbol2scm ("type-name"), SCM_EOL);
- SCM type_name = gh_call1 (typefunc, type_p);
- /* warning () ? */
-
- scm_puts (_f ("Failed typecheck for `%s', value `%s' must be of type `%s'",
- ly_symbol2string (sym).ch_C (),
- ly_symbol2string (val).ch_C (),
- ly_scm2string (ly_write2scm (val)).ch_C (),
- ly_symbol2string (type_name).ch_C ()).ch_C (),
- errport);
- scm_puts ("\n", errport);
-#endif
-
- }
- }
- return ok;
-}