From: ···········@gmail.com
Subject: what do you think of this macros and functions?
Date: 
Message-ID: <1190816919.217393.120730@50g2000hsm.googlegroups.com>
(defmacro s[ (s i)
  `(char ,s ,i))

(defmacro s[! (s i v)
  `(setf (char ,s ,i) ,v))

(defun s= (s1 s2)
  (string-equal s1 s2))


(defmacro a0 (a i &rest op)
  `(setq ,a (make-array ,i ,@op)))

(defmacro a[ (a i)
  `(aref ,a ,i))

(defmacro a[! (a i v)
  `(setf (aref ,a ,i) ,v))

(defmacro h[ (h k)
 `(gethash ,k ,h))


(defmacro h[! (h k v)
  `(setf (gethash ,k ,h) ,v))



(defmacro h0(h &rest op)
  `(setq ,h (make-hash-table ,@op)))


(defun  l-1(l)
  (rest l))

(defun l-(l n)
 (nthcdr n l))

(defun l+ (l m)
  (append l m))

(defmacro l+! (l m)
  `(setq ,l (append ,l ,m)))

(defun +l (e l)
  (cons e l))

(defun +l! (e l)
  (push e l))


(defun l[ (l n)
  (nth l n))

(defun l[! (l n v)
  (setf (nth n l) v))

From: Ken Tilton
Subject: Re: what do you think of this macros and functions?
Date: 
Message-ID: <FxxKi.51$T4.7@newsfe12.lga>
···········@gmail.com wrote:
> (defmacro s[ (s i)
>   `(char ,s ,i))
> 
> (defmacro s[! (s i v)
>   `(setf (char ,s ,i) ,v))
> 
> (defun s= (s1 s2)
>   (string-equal s1 s2))
> 
> 
> (defmacro a0 (a i &rest op)
>   `(setq ,a (make-array ,i ,@op)))
> 
> (defmacro a[ (a i)
>   `(aref ,a ,i))
> 
> (defmacro a[! (a i v)
>   `(setf (aref ,a ,i) ,v))
> 
> (defmacro h[ (h k)
>  `(gethash ,k ,h))
> 
> 
> (defmacro h[! (h k v)
>   `(setf (gethash ,k ,h) ,v))
> 
> 
> 
> (defmacro h0(h &rest op)
>   `(setq ,h (make-hash-table ,@op)))
> 
> 
> (defun  l-1(l)
>   (rest l))
> 
> (defun l-(l n)
>  (nthcdr n l))
> 
> (defun l+ (l m)
>   (append l m))
> 
> (defmacro l+! (l m)
>   `(setq ,l (append ,l ,m)))
> 
> (defun +l (e l)
>   (cons e l))
> 
> (defun +l! (e l)
>   (push e l))
> 
> 
> (defun l[ (l n)
>   (nth l n))
> 
> (defun l[! (l n v)
>   (setf (nth n l) v))
> 

Stop it and get back to work. Or go help PG with Arc. True Lispers take 
turns bragging about their carpal tunnel states of disrepair.

kenny

-- 
http://www.theoryyalgebra.com/

"We are what we pretend to be." -Kurt Vonnegut
From: Thomas A. Russ
Subject: Re: what do you think of this macros and functions?
Date: 
Message-ID: <ymiy7et3ujj.fsf@blackcat.isi.edu>
···········@gmail.com writes:

> (defun l-(l n)
>  (nthcdr n l))
> 
> (defun l+ (l m)
>   (append l m))

Well, these are REALLY bad ideas, since they are visually so close to
the built-in function 1- and 1+, even if they do take different numbers
of arguments.

I'll also note that the series using single square brackets like

> (defun l[ (l n)
>   (nth l n))

will cause havoc with editors (like Emacs) that like to match up
corresponding braces.


-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Rainer Joswig
Subject: Re: what do you think of this macros and functions?
Date: 
Message-ID: <joswig-F76474.16373326092007@news-europe.giganews.com>
In article <························@50g2000hsm.googlegroups.com>,
 ···········@gmail.com wrote:

> (defmacro s[ (s i)
>   `(char ,s ,i))
> 
> (defmacro s[! (s i v)
>   `(setf (char ,s ,i) ,v))
> 
> (defun s= (s1 s2)
>   (string-equal s1 s2))
> 
> 
> (defmacro a0 (a i &rest op)
>   `(setq ,a (make-array ,i ,@op)))
> 
> (defmacro a[ (a i)
>   `(aref ,a ,i))
> 
> (defmacro a[! (a i v)
>   `(setf (aref ,a ,i) ,v))
> 
> (defmacro h[ (h k)
>  `(gethash ,k ,h))
> 
> 
> (defmacro h[! (h k v)
>   `(setf (gethash ,k ,h) ,v))
> 
> 
> 
> (defmacro h0(h &rest op)
>   `(setq ,h (make-hash-table ,@op)))
> 
> 
> (defun  l-1(l)
>   (rest l))
> 
> (defun l-(l n)
>  (nthcdr n l))
> 
> (defun l+ (l m)
>   (append l m))
> 
> (defmacro l+! (l m)
>   `(setq ,l (append ,l ,m)))
> 
> (defun +l (e l)
>   (cons e l))
> 
> (defun +l! (e l)
>   (push e l))
> 
> 
> (defun l[ (l n)
>   (nth l n))
> 
> (defun l[! (l n v)
>   (setf (nth n l) v))

looks ugly

-- 
http://lispm.dyndns.org
From: Kent M Pitman
Subject: Re: what do you think of this macros and functions?
Date: 
Message-ID: <uk5qdayxi.fsf@nhplace.com>
···········@gmail.com writes:

> (defmacro s[ (s i)
>   `(char ,s ,i))
> 
> (defmacro s[! (s i v)
>   `(setf (char ,s ,i) ,v))
> 
> (defun s= (s1 s2)
>   (string-equal s1 s2))

It's a common desire for a new programmer to try to terraform Lisp to
be some other programming language, but you should resist the urge.
I'm guessing you've just come from some other language and are looking
for crutches to make you feel like you're still in that other
language.  That's what these macros look like.  But one major reason
not to do this is that Lisp semantics will differ in subtle ways even
for things that seem superficially similar, and if you're still
thinking of it like "I've made it work like that other language" you
will fail to think about it in the Lispy way.

For example, there are reasons we spell things out in CL.
 (char s i)
is used instead of
 (s[ s i)
in part because it tells you that you're obtaining a character of
something, rather than an arbitrary object, which you might get instead
with aref or svref... and yet you'd have to overload your s[ to do all 
of those things, and to what end?

All you're doing by writing these macros is sacrificing readability
for the sake of a few characters fewer typing.  You may even think
this adds readability, but I think most Lisp programmers would
disagree.
From: Alan Crowe
Subject: Re: what do you think of this macros and functions?
Date: 
Message-ID: <86hclhwdug.fsf@cawtech.freeserve.co.uk>
···········@gmail.com writes:
>
> (defmacro l+! (l m)
>   `(setq ,l (append ,l ,m)))

You use SETQ instead of SETF, which restricts L to be a
symbol not a general place. That is wise. Since L is
duplicated in the macroexpansion you might otherwise get
double evaluation bugs.

Have a look at DEFINE-MODIFY-MACRO. It is intended for
creating these kinds of macros and does the fancy stuff with
GET-SETF-EXPANSION for you.

CL-USER> (defparameter *x* '(this and that))
*X*

CL-USER> (define-modify-macro appendf (extra) append)
APPENDF

CL-USER> (appendf *x* '(some more stuff))
(THIS AND THAT SOME MORE STUFF)

CL-USER> *x*
(THIS AND THAT SOME MORE STUFF)

I think your entire enterprise is misguided. There is a long
history

1)Toggle in bits on the front panel switches

2)key punch octal or hexadecimal

3)assembler: 
    LOAD X 17;
    JUMP CARRY SET 23

4)Symbolic assembler: 
    LOAD X VOLTAGE; 
    JUMP CARRY SET AQUISITION-LOOP

5a)Macro assembler

5b)Low level: language C or PASCAL

6)Medium level language, Lisp, Prolog

In the early stages notational improvements paid large
dividends, but that seam is all mined out. Common Lisp is a
perfectly adequate general purpose language and the
temptation to try to improve it with minor syntax tweaks is
a whirlpool that will send you round in circles before
dragging you down. 

Most optimisation problems have a minimum shaped like x^2,
so there is little to be gained once you are close. My image
of syntax tweaking is that the minimum is shaped like x^4,
which explains the ferocious energy of disputants in syntax
brawls, made angry by an elusive derivative.

> (defmacro s[ (s i)
>   `(char ,s ,i))
> 
> (defmacro s[! (s i v)
>   `(setf (char ,s ,i) ,v))

CL-USER> (get-setf-expansion '(char s i))
(#:G1593 #:G1592)
(S I)
(#:G1591)
(LISP::%CHARSET #:G1593 #:G1592 #:G1591)
(CHAR #:G1593 #:G1592)

Every Common Lisp has its own version of s[! built-in and
hidden behind the SETF macro because some-one thought that
was an improvement over using a setter function directly.

A popular criticism of CL points to

Function SET-MACRO-CHARACTER, GET-MACRO-CHARACTER 

and laughs. How irregular! GET-MACRO-CHARACTER ought to be
an accessor. There ought not to be a function
SET-MACRO-CHARACTER, programmers should SETF
GET-MACRO-CHARACTER.

Well yes. But there is not that much in it. acaradesapo
prefers a direct call of a setter function. He may even be
right but I am confident that in twenty years time a
disciple will rebel and improve Acaralisp by defining a setf
expansion for s[ so that he can drop s[! from the language :-)

I cling to what I call the chatbot test.
> 
> (defun s= (s1 s2)
>   (string-equal s1 s2))
> 
Is my chatbot stupid because I foolishly chose to program in
a language that forces me to write string-equal instead of
s= ? No. The problem lies else where, closer to home.

Alan Crowe
Edinburgh
Scotland