[Openmcl-devel] Error: The function PRINT is defined as something other than a generic function

Pascal J. Bourguignon pjb at informatimago.com
Wed Apr 6 15:56:34 PDT 2011


"Jason E. Aten" <j.e.aten at gmail.com> writes:

> I'm trying to define a print method for my class, and I'm getting
> "Error: The function PRINT is defined as something other than a
> generic function."
>
> Below shows the two commands that when issues, reproduce this on Linux
> x86_64.  What should I try instead?
>
> Apologies if this is obvious. I'm new to CLOS, and these classes are
> auto- generated by SWIG as wrappers for C++ classes.
>
> Jason
>
> jaten at afarm:~/dj/ldc2swig$ ccl -n
> Welcome to Clozure Common Lisp Version 1.7-dev-r14684M-trunk  (LinuxX8664)!
> ? (cl:defclass object()
>   ((ff-pointer :reader ff-pointer)))
>
> #<STANDARD-CLASS OBJECT>
> ? (cl:defmethod print ((self object))
>   (Object_dprint (ff-pointer self)))
>
>> Error: The function PRINT is defined as something other than a generic function.


You may want to define a method to PRINT-OBJECT instead.

PRINT-OBJECT is an internal (but public) generic function used to
parameterize PRINT.  

However, there are constraints on PRINT-OBJECT, while let me conclude
that you should not call it directly (explicitely forbidden), and that
you should not use it as a way to write application formated data, but
only as a tool to print debugging information (or to work at the REPL).

If you need to generate data in a specific format, you would be better
served by defining your own serialization or formating methods.

    (defmethod generate-swig-code ((self object))
      (Object_dprint (ff-pointer self)))




-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.




More information about the Openmcl-devel mailing list