On 20.04.19 03:48, Steven Githens wrote:
Hi all,
This is probably a basic question, but as I’m new to both lispworks, and mostly common-lisp, I could use a little guidance.
I’m upgrading an application that uses lispworks, and hasn’t been recompiled in like 5 years.
I’ve run across `make-char` in the code, which I see has been removed:
http://www.lispworks.com/documentation/lw71/CLHS/Body/27_ac.htm
From my old Lispworks
Documentation for (DEFUN MAKE-CHAR):
Arguments: (CC &OPTIONAL (BITS 0) (FONT 0))
CC must be a character, BITS and FONT must be non-negative
integers; the last two are optional with default values of 0.
Returns a character object which is the same as CC but with the
attributes given, or NIL if this is not possible.
So the following should be a valid implementation:
(defun make-char (cc &optional (bits 0) (font 0))
"CC must be a character, BITS and FONT must be non-negative
integers; the last two are optional with default values of 0.
Returns a character object which is the same as CC but with the
attributes given, or NIL if this is not possible."
(if (and (zerop bits) (zerop font))
cc
nil))
Notice that in CL, there remains only char-int that can return a value that would depend on the implementation specific character attributes such as bits and font, if any. But there’s no standard function to inspect those attributes.
So, here you see a typical problem of having an application written in an implementation specific way: when the implementation evolves, it breaks the application.
Instead of making the application evolve toward a more recent implementation specific lispworks language, I would advise to make it evolve toward the eternal Common Lisp standard language. If the application was written in Conforming Common Lisp Code, it would be guaranteed to work in any future Lispwork version that is a Conforming Implementation of Common Lisp, and as a bonus, it would also work in any other Conforming Implementation of Common Lisp.
So here, your choice is between adding this make-char definition somewhere in your application, or grepping for all occurences of make-char, and remove it. Since make-char already takes a character, it’s useless (without attributes).
On the other hand, if the application requires the management of character attributes (fonts, and modifier bits), then you might need a more complex change, implementing your own application specific attributed characters. This would involve a deeper refactoring, since one can assume that the attributed characters are stored in strings (not CL strings, you will need attirbuted strings), and used from input to display using standard CL function, or lispwork functions, that will need to be interfaced with. For example, if you define:
(defstruct (attributed-char
(:constructor make-attributed-char)
(:constructor make-char (character &optional (bits 0) (font 0))))
character
(bits 0)
(font 0))
(progn
(defconstant +shift+ #b00000001)
(defconstant +control+ #b00000010)
(defconstant +meta+ #b00000100)
(defconstant +hyper+ #b00001000)
(defconstant +super+ #b00010000)
(defconstant +alt+ #b00100000)
(defconstant +command+ #b01000000)
(defconstant +greek+ #b10000000)
(defconstant +helvetica+ 1)
(defconstant +times+ 2)
(defconstant +courier+ 3))
(list (make-char #\a (logior +shift+ +control+))
(make-char #\a 0 +times+))
—> (#S(attributed-char :character #\a :bits 3 :font 0)
#S(attributed-char :character #\a :bits 0 :font 2))
then you will have to define attributed strings, and now to do I/O with them, etc, in conforming lisp, since the implementations won't support such attributed characters and strings. But this is expected, for an application that wants to deal with fonts and modifiers (or other bit attributes of characters).
Try (apropos "make-char") to see whether it is in some package and just not visible in cl-user