Hi, I wrote a line-parsing library, that creates an instance of an object by determining which class to instantiate using pattern matching.
I have a metaclass called parser-class that is the metaclass of all the classes that get instantiated. This metaclass has a slot called parseinfo, that holds the patterns to match against. So the parser basically starts with the metaclass object that is the root superclass of all classes that can be parsed to, and the line to parse. If the line matches the patterns in the class, that class is held as the current 'best class' and the whole thing is tried again against the class-direct-subclasses, until either no subclass has patterns that match or there are no subclasses. (it's slightly more complicated than this, the subclasses don't match against the same line as the best class, they match against the value of a variable bound when the last best class was found, but that's handled by the format of the parse info which isn't really relevant to my question) I also build lines in the other direction, by taking the values of slots in an instantiated class and finding the 'best' pattern to fill an unfilled slot, then repeating on the class-direct-superclasses until i hit the root, at which point I have a fully formatted line. This works really well in ACL, but I need it to also work in CMUCL, and I'm running into trouble with validate-superclass and figuring out exactly how to define the parser-class metaclass. I figured I'd kick a mail out to cmucl-help and see if somone can hit me over the head with something that will make it less confusing. :) I've read http://www.cons.org/cmucl/doc/pcl-mop-hints.html, and tried a few things, but I'm still not quite sure I understand how to get PCL to do what I want. My main confusion revolves around how to correctly define the metaclass. I'm assuming something like (defclass parser-class (pcl::standard-class) ((parseinfo :accessor parseinfo :initarg :parseinfo :initform nil))) is what I want, with a validate-superclass method that will return T. Beyond that, I'm assuming I need to use pcl::find-class (from the wording of the above hints url) and wondering if I need to use pcl::class-of instead of just class-of to get this stuff to work. The definition that works in ACL is just (defclass parser-class (standard-class) ((parseinfo :accessor parseinfo :initarg :parseinfo :initform nil))) and from there I use ACL's builtin mop:class-direct-superclasses and mop:class-direct-subclasses for the parsing and formatting routines respectively. The end goal is to have this work in both ACL and CMUCL. I'd probably figure it out eventually without asking but I figure people on the list might be able to point me in the right direction ... I figure it doesn't hurt to ask. Thanks in advance for any help, Wendall Marvel __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/
