unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* defconst in life.el
@ 2004-11-14 18:40 Luc Teirlinck
  2004-11-14 21:02 ` Stefan Monnier
  2004-11-15 14:00 ` Richard Stallman
  0 siblings, 2 replies; 11+ messages in thread
From: Luc Teirlinck @ 2004-11-14 18:40 UTC (permalink / raw)


I believe all uses of defconst in life.el are wrong.  Most are changed
in functions in life.el itself and produce compiler warnings.  Unless
there are objections, I will install the following patch.  My previous
message to the author could not be delivered, which probably means
that the file is no longer maintained.

===File ~/life.el-diff======================================
*** life.el	02 Sep 2003 07:51:42 -0500	1.20
--- life.el	14 Nov 2004 10:24:04 -0600	
***************
*** 1,6 ****
  ;;; life.el --- John Horton Conway's `Life' game for GNU Emacs
  
! ;; Copyright (C) 1988, 2001 Free Software Foundation, Inc.
  
  ;; Author: Kyle Jones <kyleuunet.uu.net>
  ;; Keywords: games
--- 1,6 ----
  ;;; life.el --- John Horton Conway's `Life' game for GNU Emacs
  
! ;; Copyright (C) 1988, 2001, 2004 Free Software Foundation, Inc.
  
  ;; Author: Kyle Jones <kyleuunet.uu.net>
  ;; Keywords: games
***************
*** 30,36 ****
  
  ;;; Code:
  
! (defconst life-patterns
    [("@@@" " @@" "@@@")
     ("@@@ @@@" "@@  @@ " "@@@ @@@")
     ("@@@ @@@" "@@   @@" "@@@ @@@")
--- 30,36 ----
  
  ;;; Code:
  
! (defvar life-patterns
    [("@@@" " @@" "@@@")
     ("@@@ @@@" "@@  @@ " "@@@ @@@")
     ("@@@ @@@" "@@   @@" "@@@ @@@")
***************
*** 80,95 ****
  
  ;; list of numbers that tell how many characters to move to get to
  ;; each of a cell's eight neighbors.
! (defconst life-neighbor-deltas nil)
  
  ;; window display always starts here.  Easier to deal with than
  ;; (scroll-up) and (scroll-down) when trying to center the display.
! (defconst life-window-start nil)
  
  ;; For mode line
! (defconst life-current-generation nil)
  ;; Sadly, mode-line-format won't display numbers.
! (defconst life-generation-string nil)
  
  (defvar life-initialized nil
    "Non-nil if `life' has been run at least once.")
--- 80,95 ----
  
  ;; list of numbers that tell how many characters to move to get to
  ;; each of a cell's eight neighbors.
! (defvar life-neighbor-deltas nil)
  
  ;; window display always starts here.  Easier to deal with than
  ;; (scroll-up) and (scroll-down) when trying to center the display.
! (defvar life-window-start nil)
  
  ;; For mode line
! (defvar life-current-generation nil)
  ;; Sadly, mode-line-format won't display numbers.
! (defvar life-generation-string nil)
  
  (defvar life-initialized nil
    "Non-nil if `life' has been run at least once.")
============================================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: defconst in life.el
  2004-11-14 18:40 defconst in life.el Luc Teirlinck
@ 2004-11-14 21:02 ` Stefan Monnier
  2004-11-14 21:39   ` Luc Teirlinck
  2004-11-15 14:00 ` Richard Stallman
  1 sibling, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2004-11-14 21:02 UTC (permalink / raw)
  Cc: emacs-devel


> @@ -30,7 +30,7 @@
>  
>  ;;; Code:
>  
> -(defconst life-patterns
> +(defvar life-patterns
>    [("@@@" " @@" "@@@")
>     ("@@@ @@@" "@@  @@ " "@@@ @@@")
>     ("@@@ @@@" "@@   @@" "@@@ @@@")

This looks wrong.  The variable is indeed treated like a constant,
as far as I can tell.


        Stefan

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: defconst in life.el
  2004-11-14 21:02 ` Stefan Monnier
@ 2004-11-14 21:39   ` Luc Teirlinck
  2004-11-14 21:42     ` Luc Teirlinck
  2004-11-14 22:32     ` Thien-Thi Nguyen
  0 siblings, 2 replies; 11+ messages in thread
From: Luc Teirlinck @ 2004-11-14 21:39 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier wrote:

   This looks wrong.  The variable is indeed treated like a constant,
   as far as I can tell.

This is difficult to tell.  It at first glance looks like something a
knowledgeble user might want to change and play around with.
(Something that might even be a defcustom.)  But I will _keep_ this
particular defconst to err on the conservative side in terms of making
changes, especially since I am not really familiar with the file.
This particular defconst definitely produces no compiler warnings.

Maybe somebody who uses life.el could give a more definitive answer.
(But maybe you use it.)

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: defconst in life.el
  2004-11-14 21:39   ` Luc Teirlinck
@ 2004-11-14 21:42     ` Luc Teirlinck
  2004-11-14 22:32     ` Thien-Thi Nguyen
  1 sibling, 0 replies; 11+ messages in thread
From: Luc Teirlinck @ 2004-11-14 21:42 UTC (permalink / raw)
  Cc: monnier, emacs-devel

>From my previous message:

   Stefan Monnier wrote:

      This looks wrong.  The variable is indeed treated like a constant,
      as far as I can tell.

   This is difficult to tell.  It at first glance looks like something a
   knowledgeble user might want to change and play around with.
   (Something that might even be a defcustom.)  But I will _keep_ this
   particular defconst to err on the conservative side in terms of making
   changes, especially since I am not really familiar with the file.
   This particular defconst definitely produces no compiler warnings.

   Maybe somebody who uses life.el could give a more definitive answer.
   (But maybe you use it.)

I forgot to say that we were talking about life-patterns.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: defconst in life.el
  2004-11-14 21:39   ` Luc Teirlinck
  2004-11-14 21:42     ` Luc Teirlinck
@ 2004-11-14 22:32     ` Thien-Thi Nguyen
  2004-11-14 22:51       ` Luc Teirlinck
  2004-11-19 17:52       ` Juri Linkov
  1 sibling, 2 replies; 11+ messages in thread
From: Thien-Thi Nguyen @ 2004-11-14 22:32 UTC (permalink / raw)


Luc Teirlinck <teirllm@dms.auburn.edu> writes:

   Maybe somebody who uses life.el could give a more definitive answer.

the docstring gives a hint: "some".  this var is meant to be used
experimentally (value modified, augmented, etc), so defvar is more
suitable than defconst.

e.g.:
(defun random-life () (interactive)
  (let* ((w (+ 10 (random (- (frame-width) 10))))
         (h (+ 5 (random (- (frame-height) 5))))
         ;; a pleasant propensity to delightful density
         (n (random (round (/ (* w h) 2))))
         (r (mapcar (lambda (x) (make-string w 32))
                    (number-sequence 1 h))))
    (while (< 0 n)
      (aset (nth (random h) r) (random w) ?@)
      (setq n (1- n)))
    (let ((life-patterns (vector r)))
      (life 0))))

thi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: defconst in life.el
  2004-11-14 22:32     ` Thien-Thi Nguyen
@ 2004-11-14 22:51       ` Luc Teirlinck
  2004-11-17  1:48         ` Kenichi Handa
  2004-11-19 17:52       ` Juri Linkov
  1 sibling, 1 reply; 11+ messages in thread
From: Luc Teirlinck @ 2004-11-14 22:51 UTC (permalink / raw)
  Cc: emacs-devel

Thien-Thi Nguyen wrote:

   the docstring gives a hint: "some".  this var is meant to be used
   experimentally (value modified, augmented, etc), so defvar is more
   suitable than defconst.

   e.g.:

Thanks.  I will stick with my original patch and convert the defconst
for `life-patterns' into a defvar, unless there are other objections.

On the other hand, I still plan to keep the defconst for `lao-key-alist'.
I still have the impression that this one should be a defvar too, but
unless a user of lao.el, or somebody familiar with it, confirms this,
I will err on the side of making too few rather than too many changes.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: defconst in life.el
  2004-11-14 18:40 defconst in life.el Luc Teirlinck
  2004-11-14 21:02 ` Stefan Monnier
@ 2004-11-15 14:00 ` Richard Stallman
  1 sibling, 0 replies; 11+ messages in thread
From: Richard Stallman @ 2004-11-15 14:00 UTC (permalink / raw)
  Cc: emacs-devel

    I believe all uses of defconst in life.el are wrong.  Most are changed
    in functions in life.el itself and produce compiler warnings.  Unless
    there are objections, I will install the following patch.  My previous
    message to the author could not be delivered, which probably means
    that the file is no longer maintained.

I am pretty he would no longer want to help anyway.  Thanks for fixing
these; would you please install your patch?

Also please add ;; Maintainer: FSF to indicate that it isn't
maintained by the author any more.

It would also be useful to verify that the code initializes
these variables when it should.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: defconst in life.el
  2004-11-14 22:51       ` Luc Teirlinck
@ 2004-11-17  1:48         ` Kenichi Handa
  2004-11-23  2:34           ` Luc Teirlinck
  0 siblings, 1 reply; 11+ messages in thread
From: Kenichi Handa @ 2004-11-17  1:48 UTC (permalink / raw)
  Cc: ttn, emacs-devel

In article <200411142251.iAEMpfG27635@raven.dms.auburn.edu>, Luc Teirlinck <teirllm@dms.auburn.edu> writes:
> On the other hand, I still plan to keep the defconst for
> `lao-key-alist'.  I still have the impression that this
> one should be a defvar too, but unless a user of lao.el,
> or somebody familiar with it, confirms this,

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.

---
Ken'ichi HANDA
handa@m17n.org

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: defconst in life.el
  2004-11-14 22:32     ` Thien-Thi Nguyen
  2004-11-14 22:51       ` Luc Teirlinck
@ 2004-11-19 17:52       ` Juri Linkov
  2004-11-19 18:47         ` Thien-Thi Nguyen
  1 sibling, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2004-11-19 17:52 UTC (permalink / raw)
  Cc: emacs-devel

Thien-Thi Nguyen <ttn@glug.org> writes:
> Luc Teirlinck <teirllm@dms.auburn.edu> writes:
>>    Maybe somebody who uses life.el could give a more definitive answer.
>
> the docstring gives a hint: "some".  this var is meant to be used
> experimentally (value modified, augmented, etc), so defvar is more
> suitable than defconst.
>
> e.g.:
> (defun random-life () (interactive)
>   (let* ((w (+ 10 (random (- (frame-width) 10))))
>          (h (+ 5 (random (- (frame-height) 5))))
>          ;; a pleasant propensity to delightful density
>          (n (random (round (/ (* w h) 2))))
>          (r (mapcar (lambda (x) (make-string w 32))
>                     (number-sequence 1 h))))
>     (while (< 0 n)
>       (aset (nth (random h) r) (random w) ?@)
>       (setq n (1- n)))
>     (let ((life-patterns (vector r)))
>       (life 0))))

Why don't you install your fun?  Filling the matrix with random values
is one of the most amusing aspects of life.

As I see in life.el, Luc already changed the life-pattern type from
defconst to defvar so it's good to install it now.  But please rename
`random-life' to `life-random' to satisfy the package prefix.  Thanks.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: defconst in life.el
  2004-11-19 17:52       ` Juri Linkov
@ 2004-11-19 18:47         ` Thien-Thi Nguyen
  0 siblings, 0 replies; 11+ messages in thread
From: Thien-Thi Nguyen @ 2004-11-19 18:47 UTC (permalink / raw)
  Cc: emacs-devel

Juri Linkov <juri@jurta.org> writes:

   Why don't you install your fun?  Filling the matrix with random
   values is one of the most amusing aspects of life.

because (as some math-head once drilled into me), one can find
infinity not only in randomness, but in the randomness of randomness.
somehow i feel it is not my place to impose this small suggestion on
the discovery process of others, pleasant as i may find it personally.
granted, i am half a bottle of wine from my senses; i hope semantics
of this spew equal the syntax in correctness.  (syntax is the last
to fall, meaningless the leaning wall, one vast flood awaits beyond,
where sound and sense mix on and on and on and on...)

thi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: defconst in life.el
  2004-11-17  1:48         ` Kenichi Handa
@ 2004-11-23  2:34           ` Luc Teirlinck
  0 siblings, 0 replies; 11+ messages in thread
From: Luc Teirlinck @ 2004-11-23  2:34 UTC (permalink / raw)
  Cc: ttn, emacs-devel

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

Does the following version of my patch look OK?  If nobody ever would
want to change `lao-key-alist', one could use something more along the
lines of what Stefan suggested.  However, the current defconst's are
misleading and generate compiler warnings, so _some_ kind of change
seems necessary.

===File ~/lao-latest-diff===================================
*** lao.el	01 Sep 2003 16:08:19 -0500	1.8
--- lao.el	22 Nov 2004 19:48:41 -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,51 ----
  	  (compose-string (quail-lookup-map-and-concat quail-current-key))))
    control-flag)
  
! ;; If you change the value of this variable while lao is already loaded,
! ;; you need to re-load it to properly re-initialize related alists.
! (defvar lao-key-alist
    '(("!" . "1")
      ("\"" . "=")
      ("#" . "3")
***************
*** 148,159 ****
      ("\\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)
--- 151,170 ----
      ("\\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)
! 
! ;; These need to be re-initialized if lao is re-loaded.
! (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)
***************
*** 197,201 ****
--- 208,214 ----
      (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
============================================================
 LocalWords:  diff

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-11-23  2:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-14 18:40 defconst in life.el Luc Teirlinck
2004-11-14 21:02 ` Stefan Monnier
2004-11-14 21:39   ` Luc Teirlinck
2004-11-14 21:42     ` Luc Teirlinck
2004-11-14 22:32     ` Thien-Thi Nguyen
2004-11-14 22:51       ` Luc Teirlinck
2004-11-17  1:48         ` Kenichi Handa
2004-11-23  2:34           ` Luc Teirlinck
2004-11-19 17:52       ` Juri Linkov
2004-11-19 18:47         ` Thien-Thi Nguyen
2004-11-15 14:00 ` Richard Stallman

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).