From: Nicolas N. <Nic...@iw...> - 2003-11-19 08:55:54
|
William Harold Newman <wil...@ai...> writes: > > I think for gfs a combination of types would be the most reasonable type > > declaration, e.g. (or (function (string) fixnum) (function (list) fixnum)). > > To be practically usable, this should probably adapt dynamically to new > > method definitions... > > If you are suggesting keeping the FTYPE definition as narrow as > the OR of all DEFMETHODs seen so far, I don't think that's going > to work correctly. > > file1.lisp: > (DEFGENERIC FOO (X)) > (DEFMETHOD FOO ((X INTEGER)) ...) > ;; so here FTYPE FOO would be (OR (FUNCTION (INTEGER) *))? > > file2.lisp: > (DEFUN FROB (X) > (ETYPECASE X > (INTEGER (FOO X)) > (REAL (LIST (FOO X) (EST-PRECISION X))) ;should not compile to type error > ...)) > > file3.lisp: > (DEFMETHOD FOO ((X SINGLE-FLOAT)) ...) > (DEFMETHOD FOO ((X DOUBLE-FLOAT)) ...) > ;; Now FTYPE FOO has become > ;; (OR (FUNCTION (INTEGER) *) > ;; (FUNCTION (SINGLE-FLOAT) *) > ;; (FUNCTION (DOUBLE-FLOAT) *)) > ;; but it's too late to avoid compile-time errors in DEFUN FROB. Such type declarations should probably only be used (when compiling FROB) if the generic function has been declared sealed. BTW[1], were Gerd Moellmann's PCL improvements ported to SBCL? Nicolas. [1] I am on sbcl-help/devel only since about one week and do not use SBCL yet. |