Lisp HUG Maillist Archive

Replacing make-char

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

Since I’m still getting back up to speed with Lisp, it’s not immediately straight forward to me as to how to replace this usage, but I’m wondering if, for operators that have been removed from Lispworks, if there is usually some documentation on what they should be replaced with.  In this case, `make-char`.  :)

Thanks!
Steve

Re: Replacing make-char

Unable to parse email body. Email id is 14939

Re: Replacing make-char

You’ve not described make-char. It was never in the standard Common-Lisp. You should locate the specification of this old function, and  reimplement it in CL. 

Sent from my iPad

On 20 Apr 2019, at 03:48, Steven Githens <steve@githens.org> 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

Since I’m still getting back up to speed with Lisp, it’s not immediately straight forward to me as to how to replace this usage, but I’m wondering if, for operators that have been removed from Lispworks, if there is usually some documentation on what they should be replaced with.  In this case, `make-char`.  :)

Thanks!
Steve

Re: Replacing make-char

Unable to parse email body. Email id is 14941

Re: Replacing make-char

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.

Try (apropos "make-char") to see whether it is in some package and just 
not visible in cl-user

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Re: Replacing make-char

As mentioned, it's not in the standard. It is described in the prior 
Common Lisp: the Language, 2nd Edition

https://www.cs.cmu.edu/Groups/AI/html/cltl/cltl2.html

https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node138.html

which is essentially the description someone else gave.

On 4/19/19 8:48 PM, 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
>
> Since I’m still getting back up to speed with Lisp, it’s not 
> immediately straight forward to me as to how to replace this usage, 
> but I’m wondering if, for operators that have been removed from 
> Lispworks, if there is usually some documentation on what they should 
> be replaced with.  In this case, `make-char`.  :)
>
> Thanks!
> Steve

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Re: Replacing make-char



On 20 Apr 2019, at 07:27, Karsten Poeck <Karsten.Poeck@gmail.com> wrote:

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

-- 
__Pascal J. Bourguignon__




Re: Replacing make-char

Hi,

make-char and related were part of the early Common Lisp. It was provided to support existing uses of characters which had additional information like font infos - like on the Lisp Machine OS.

For the ANSI Common Lisp standard the idea of char-bits and char-fonts were removed. So the CLHS is new and differs from CLtL1. CLtL2 described the old standard AND the removal. The progression was CLtL1 -> CLtL2 -> ANSI CL standard.

This is explained here:  Issue Character Proposal
http://www.lispworks.com/documentation/lw71/CLHS/Issues/iss026_w.htm

Thus ANSI CL standard conforming implementations removed these operators then, too.

There is basically nothing directly useful functionality to replace MAKE-CHAR with. If you have old code you want to adapt:

* either remove MAKE-CHAR and just use the character directly or provide a MAKE-CHAR which will do nothing but returning the character

* you might need to be able to deal with fonts and other things. But that depends on what your prior code did. If you have questions about it, you might need to post some code with example usage. Then one could see what exactly the old code did with MAKE-CHAR.

Regards

Rainer Joswig



Am 20.04.2019 um 03:48 schrieb Steven Githens <steve@githens.org>:

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

Since I’m still getting back up to speed with Lisp, it’s not immediately straight forward to me as to how to replace this usage, but I’m wondering if, for operators that have been removed from Lispworks, if there is usually some documentation on what they should be replaced with.  In this case, `make-char`.  :)

Thanks!
Steve

Updated at: 2020-12-10 08:29 UTC