unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Luc Teirlinck <teirllm@dms.auburn.edu>
Cc: emacs-devel@gnu.org
Subject: Re: defconst in lao.el
Date: Tue, 16 Nov 2004 21:01:46 -0600 (CST)	[thread overview]
Message-ID: <200411170301.iAH31kc20206@raven.dms.auburn.edu> (raw)
In-Reply-To: <200411170141.KAA24828@etlken.m17n.org> (message from Kenichi Handa on Wed, 17 Nov 2004 10:41:48 +0900 (JST))

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5607 bytes --]

Kenichi Handa wrote:

   I used "defconst" for them because they have to be set back
   to nil when lao.el is re-loaded.  They are setup in the
   following (let ...) form to correct values.  If we change
   them to "defvar", they are anyway set to nil in that (let
   ...) form.  And, conceptually, they are "constant".  So I
   think "defconst" is better.

Yes, but I believe that the defconst is misleading.  When I see:

(defconst var value)

I get the impression that VAR is set for ever after to VALUE.

   It's possible that a user provide different initial value
   for this variable in his .emacs.  In that sense, defvar may
   be better.  On the other hand, modifying this value after
   lao.el is loaded doesn't work.  In that sense, it seems that
   defconst is better.

Yes, but the code can be changed so that modifying the value after
lao.el is loaded _does_ work.

What about the following patch?  It avoids the misleading defconst's,
the compiler warnings, and allows the sophisticated user to set
`lao-key-alist' to a different value in his .emacs, even if lao.el is
already loaded.

===File ~/lao-diff==========================================
*** lao.el	01 Sep 2003 16:08:19 -0500	1.8
--- lao.el	16 Nov 2004 20:40:48 -0600	
***************
*** 2,7 ****
--- 2,8 ----
  
  ;; Copyright (C) 1997 Electrotechnical Laboratory, JAPAN.
  ;; Licensed to the Free Software Foundation.
+ ;; Copyright (C) 2004 Free Software Foundation.
  
  ;; Keywords: multilingual, input method, Lao
  
***************
*** 42,48 ****
  	  (compose-string (quail-lookup-map-and-concat quail-current-key))))
    control-flag)
  
! (defconst lao-key-alist
    '(("!" . "1")
      ("\"" . "=")
      ("#" . "3")
--- 43,52 ----
  	  (compose-string (quail-lookup-map-and-concat quail-current-key))))
    control-flag)
  
! ;; If you change the value of this variable, be sure to do
! ;; `(lao-initialize-alists)' afterwards.  Otherwise, the related
! ;; alists will not be properly updated.
! (defvar lao-key-alist
    '(("!" . "1")
      ("\"" . "=")
      ("#" . "3")
***************
*** 148,183 ****
      ("\\9" . "໙")
      ))
  
! (defconst lao-consonant-key-alist nil)
! (defconst lao-semivowel-key-alist nil)
! (defconst lao-vowel-key-alist nil)
! (defconst lao-voweltone-key-alist nil)
! (defconst lao-tone-key-alist nil)
! (defconst lao-other-key-alist nil)
! 
! (let ((tail lao-key-alist)
!       elt phonetic-type)
!   (while tail
!     (setq elt (car tail) tail (cdr tail))
!     (if (stringp (cdr elt))
! 	(setq phonetic-type (get-char-code-property (aref (cdr elt) 0)
  						    'phonetic-type))
!       (setq phonetic-type (get-char-code-property (aref (aref (cdr elt) 0) 0)
! 						  'phonetic-type))
!       (aset (cdr elt) 0 (compose-string (aref (cdr elt) 0))))
!     (cond ((eq phonetic-type 'consonant)
! 	   (setq lao-consonant-key-alist (cons elt lao-consonant-key-alist)))
! 	  ((memq phonetic-type '(vowel-upper vowel-lower))
! 	   (if (stringp (cdr elt))
! 	       (setq lao-vowel-key-alist (cons elt lao-vowel-key-alist))
! 	     (setq lao-voweltone-key-alist
! 		   (cons elt lao-voweltone-key-alist))))
! 	  ((eq  phonetic-type 'tone)
! 	   (setq lao-tone-key-alist (cons elt lao-tone-key-alist)))
! 	  ((eq phonetic-type 'semivowel-lower)
! 	   (setq lao-semivowel-key-alist (cons elt lao-semivowel-key-alist)))
! 	  (t
! 	   (setq lao-other-key-alist (cons elt lao-other-key-alist))))))
  
  (quail-define-package
   "lao" "Lao" "ລ" t
--- 152,200 ----
      ("\\9" . "໙")
      ))
  
! (defvar lao-consonant-key-alist nil)
! (defvar lao-semivowel-key-alist nil)
! (defvar lao-vowel-key-alist nil)
! (defvar lao-voweltone-key-alist nil)
! (defvar lao-tone-key-alist nil)
! (defvar lao-other-key-alist nil)
! 
! ;;; autoload
! (defun lao-initialize-alists ()
!   "Properly initialize the lao alists.
! If you change `lao-key-alist', you have to call this function to
! make sure that all related lao alists are properly updated."
!   (setq lao-consonant-key-alist nil
! 	lao-semivowel-key-alist nil
! 	lao-vowel-key-alist nil
! 	lao-voweltone-key-alist nil
! 	lao-tone-key-alist nil
! 	lao-other-key-alist nil)
!   (let ((tail lao-key-alist)
! 	elt phonetic-type)
!     (while tail
!       (setq elt (car tail) tail (cdr tail))
!       (if (stringp (cdr elt))
! 	  (setq phonetic-type (get-char-code-property (aref (cdr elt) 0)
! 						      'phonetic-type))
! 	(setq phonetic-type (get-char-code-property (aref (aref (cdr elt) 0) 0)
  						    'phonetic-type))
! 	(aset (cdr elt) 0 (compose-string (aref (cdr elt) 0))))
!       (cond ((eq phonetic-type 'consonant)
! 	     (setq lao-consonant-key-alist (cons elt lao-consonant-key-alist)))
! 	    ((memq phonetic-type '(vowel-upper vowel-lower))
! 	     (if (stringp (cdr elt))
! 		 (setq lao-vowel-key-alist (cons elt lao-vowel-key-alist))
! 	       (setq lao-voweltone-key-alist
! 		     (cons elt lao-voweltone-key-alist))))
! 	    ((eq  phonetic-type 'tone)
! 	     (setq lao-tone-key-alist (cons elt lao-tone-key-alist)))
! 	    ((eq phonetic-type 'semivowel-lower)
! 	     (setq lao-semivowel-key-alist (cons elt lao-semivowel-key-alist)))
! 	    (t
! 	     (setq lao-other-key-alist (cons elt lao-other-key-alist)))))))
! 
! (unless (featurep 'lao) (lao-initialize-alists))
  
  (quail-define-package
   "lao" "Lao" "ລ" t
***************
*** 197,201 ****
--- 214,220 ----
      (v-state (lao-vowel-key-alist . t-state))
      (t-state lao-tone-key-alist))))
  
+ (provide 'lao)
+ 
  ;;; arch-tag: 23863a30-a8bf-402c-b7ce-c517a7aa8570
  ;;; lao.el ends here
============================================================

  reply	other threads:[~2004-11-17  3:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-14 18:56 defconst in lao.el Luc Teirlinck
2004-11-14 21:06 ` Stefan Monnier
2004-11-14 21:47   ` Luc Teirlinck
2004-11-15 14:00 ` Richard Stallman
2004-11-17  1:41 ` Kenichi Handa
2004-11-17  3:01   ` Luc Teirlinck [this message]
2004-11-17  6:39     ` Stephan Stahl
2004-11-17 14:26       ` Luc Teirlinck
2004-11-17 22:05         ` Luc Teirlinck
2004-11-17  3:07   ` Luc Teirlinck
2004-11-17  3:57   ` Luc Teirlinck
2004-11-17 14:17   ` Stefan Monnier
2004-11-17 18:35     ` Luc Teirlinck
2004-11-17 19:03       ` Stefan Monnier
2004-12-04  2:49       ` Kenichi Handa
2004-12-04  3:43         ` Luc Teirlinck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200411170301.iAH31kc20206@raven.dms.auburn.edu \
    --to=teirllm@dms.auburn.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).