From: Blake D
Subject: symbol synonyms question
Date: 
Message-ID: <0YdTb.15093$QJ3.9598@fed1read04>
Hi,
How can I create other names that I can use to invoke pre-existing
functions, macros, and special forms?

To clarify further, I would like the new names to be synonyms for the
originals, not a replacement.

The reason I would like to do this is because  I use dictation software to
program by voice. Lisp is the easiest language for dictation that I have
found because of its simple syntax. Still, things like setf and aref are
much more difficult to dictate than english words like car, array, and
equal.

Thank you,
Blake

From: Artie Gold
Subject: Re: symbol synonyms question
Date: 
Message-ID: <bvjs6v$s3shc$1@ID-219787.news.uni-berlin.de>
Blake D wrote:
> Hi,
> How can I create other names that I can use to invoke pre-existing
> functions, macros, and special forms?
> 
> To clarify further, I would like the new names to be synonyms for the
> originals, not a replacement.
> 
> The reason I would like to do this is because  I use dictation software to
> program by voice. Lisp is the easiest language for dictation that I have
> found because of its simple syntax. Still, things like setf and aref are
> much more difficult to dictate than english words like car, array, and
> equal.
> 

If I correctly understand what you're looking for, define-synbol-macro 
is likely what you want. See the Hyperspec.

HTH,
--ag
-- 
Artie Gold -- Austin, Texas
From: Matthew Danish
Subject: Re: symbol synonyms question
Date: 
Message-ID: <20040201215418.GJ8667@mapcar.org>
On Sun, Feb 01, 2004 at 02:12:02PM -0700, Blake D wrote:
> Hi,
> How can I create other names that I can use to invoke pre-existing
> functions, macros, and special forms?
> 
> To clarify further, I would like the new names to be synonyms for the
> originals, not a replacement.
> 
> The reason I would like to do this is because  I use dictation software to
> program by voice. Lisp is the easiest language for dictation that I have
> found because of its simple syntax. Still, things like setf and aref are
> much more difficult to dictate than english words like car, array, and
> equal.

;; Example usage:
;; (define-alternative-name aref array-reference)
;; (define-alternative-name setf set-form)
;; (define-alternative-name (setf aref) (set-form array-reference))

(defmacro define-alternative-name (old-name new-name)
  (cond ((listp old-name)
         (when (and (eq 'cl:setf (first old-name))
                    (listp new-name)
                    (not (null (rest new-name))))
           ;; (SETF name)
           `(define-setf-expander ,(second new-name) (&rest args)
             (get-setf-expansion `(,',(second old-name) ,@args)))))
        ((or (macro-function old-name)
             (special-operator-p old-name))
         ;; macros and special operators
         `(defmacro ,new-name (&rest args)
           `(,',old-name ,@args)))
        (t
         ;; functions
         `(progn
           (declaim (inline ,new-name))
           (defun ,new-name (&rest args)
             (apply ',old-name args))
           (define-compiler-macro ,new-name (&rest args)
             `(,',old-name ,@args))))))


There are a few caveats: SPECIAL-OPERATOR-P will not return T for the
new names you make.  I'm not sure that #'(SET-FORM FOO) is guaranteed to
work even when #'(SETF FOO) does work (is it subject to the
macro-expander?).  This will probably destroy your IDE's ability to look
up lambda-lists and documentation on the fly, however.  There are
probably ways to save even that, but it would be much more involved.

-- 
; Matthew Danish <·······@andrew.cmu.edu>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."
From: Steven M. Haflich
Subject: Re: symbol synonyms question
Date: 
Message-ID: <f0mTb.8773$UW.1115@newssvr29.news.prodigy.com>
I think the responses on this thread so far have gone entirely in the
wrong direction.

Blake D wrote:

> How can I create other names that I can use to invoke pre-existing
> functions, macros, and special forms?

First, this is the wrong question.  Symbols in Cl are used to name many
things in addition to functions, macros, and special forms.  These three
are collectively called `operators' which are one of the namespaced in CL,
but there are a bunch of other namespaces.  Some of these are:

  - package names
  - variable names (lexical, special, and symbol macro)
  - block names
  - go tag names
  - type names (including class names and condition names)
  - restart names
  - setf names (not really distinct from operator names)

> To clarify further, I would like the new names to be synonyms for the
> originals, not a replacement.

Now, there is no mechanism in CL that makes one symbol an alias for another.
The package system allows you to make a given name resolve to the same (eq)
symbol in multiple packages, but there is no way to make symbols with
different names resolve to the same symbol object.  The Lisp machine had a
mechanism sthat did approximately this (using, IIRC, forwarding pointer) but
the machinery cannot be implemented without runtime cost unless it has
hardware support, and the facility would not have been judged important
enough to be included in the language if it had serious cost.

You can write macros or other code walkers that will traverse your input
forms and rewrite operator names and names in all these other name spaces.
but it is clearly a lot of work because each of the namespaces needs
individual treatment.  Further, no code walker will be able to transforms
your alternate words when they appear in a comment.

Further, I would imagine you want to enter your code by voice and then have
a recognizable spoken word like "quidditch" be transfored to a Lisp word
like "cddr".  But you would want this to happen at text entry time, not at
compile time, if you want anyone else to be able to read your source files.
That tells me that you really want to do through the effort of telling you
speech-to-text input program how to do these transforms at input time.  You
are only asking for trouble and personal marginalization to do it any later.
If your input program isn';t up to the task, then you might want a program
(in Lisp, of course) that does the job as a postprocessor, but before the
sourse goes to the lisp system.

> The reason I would like to do this is because  I use dictation software to
> program by voice. Lisp is the easiest language for dictation that I have
> found because of its simple syntax. Still, things like setf and aref are
> much more difficult to dictate than english words like car, array, and
> equal.
From: Christophe Rhodes
Subject: Re: symbol synonyms question
Date: 
Message-ID: <sqy8rlhofu.fsf@lambda.dyndns.org>
"Blake D" <············@yahoo.com> writes:

> The reason I would like to do this is because  I use dictation software to
> program by voice. Lisp is the easiest language for dictation that I have
> found because of its simple syntax. Still, things like setf and aref are
> much more difficult to dictate than english words like car, array, and
> equal.

On the assumption that the "voice" part of this is not an absolute
necessity, have you looked at Dasher[*]?  After training on a corpus
of lisp, it's fairly easy to output reasonable (even
properly-indented!) code.

Christophe

[*] One-sentence summary: predictive arithmetic-coding input system
which can be driven by input devices from mice to eye-trackers.
-- 
http://www-jcsu.jesus.cam.ac.uk/~csr21/       +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%")    (pprint #36rJesusCollegeCambridge)
From: Kaz Kylheku
Subject: Re: symbol synonyms question
Date: 
Message-ID: <cf333042.0402021151.1e22552d@posting.google.com>
"Blake D" <············@yahoo.com> wrote in message news:<····················@fed1read04>...
> Hi,
> How can I create other names that I can use to invoke pre-existing
> functions, macros, and special forms?
> 
> To clarify further, I would like the new names to be synonyms for the
> originals, not a replacement.
> 
> The reason I would like to do this is because  I use dictation software to
> program by voice.

... and because of that preference, everyone who reads your code
should be aware of some synonyms for otherwise standard functions or
operators?

The substitution filter belongs in the dictation pipeline, not in the
program, so that you can utter ``foo'', and have the characters
``bar'' appear in your editor.

If the dictation sofware itself can't do it, then maybe your text
editor can. Even vi, considered braindamaged and underpowered by some,
has an abbreviation feature.

  :ab foo bar

Now type ``foo'' followed by whitespace, and it's replaced by ``bar''.