Discussion:
About &aux
Daniel Weinreb
2011-06-12 14:00:45 UTC
Permalink
Content preview: I, myself, really dislike &aux. It has been so long since
I have seen it that I have forgotten that it even exists. We never use it;
and I should add that to our style guide. I don't even like (let (a b c)
...) [...]

Content analysis details: (-99.0 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-100 USER_IN_WHITELIST From: address is in the user's white-list
-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low
trust
[206.46.173.17 listed in list.dnswl.org]
1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail)
Archived-At: <http://permalink.gmane.org/gmane.lisp.cl-pro/429>

I, myself, really dislike &aux. It has been so long
since I have seen it that I have forgotten that
it even exists. We never use it; and I should
add that to our style guide.

I don't even like

(let (a b c) ...)

since I prefer to think of "let" in the Scheme sense
of "I am naming the result of a computation." In
fact, I added a macro to our library that is like
"let" but does not allow the variable to be modified.
(It's not portable; it uses a CCL-specific feature.)

Unfortunately, we do not use it in practice, since
it's so important for code style to be consistent
and it would be very hard to change all our
sources to do this, since it's hard to know from
looking at code whether the "let" variable
ever changes, and we have like 700MLOC
of code in QRes. I wish Common Lisp had
always had such a feature.

I'm not saying there's no place for let followed
by side effects. It's just not the way I usually
think of it.

Also, putting things in the parameter list that aren't
parameters just feels weird.

I do not think my own opinions are by any
means "right". These are just my biases
and preferences.

-- Dan
Faré
2011-06-12 15:08:50 UTC
Permalink
I, myself, really dislike &aux.  It has been so long
since I have seen it that I have forgotten that
it even exists.  We never use it; and I should
add that to our style guide.
&aux has its uses. Sometimes it can be clearer than adding a let.
I don't even like
(let (a b c) ...)
Same thing. If you're going to do side effects (sometimes you have to)
in particular when you need the binding to be visible in a scope
that starts before you have a useful value to initialize it with,
then it's clearer to say let (a) and make it clear
it's conceptually uninitialized than say let ((a nil))
where nil is bogus and not even an admissible value for the
variable's intended type. See especially unwind-protect forms.
since I prefer to think of "let" in the Scheme sense
of "I am naming the result of a computation."
Call that something else than let if you want, it's a useful idiom.

Also, binding forms are annoying in that they are verbose
and move the body to the right as you nest them.
Instead of any ad-hoc do-it-all binding macro,
I like this macro from Marco Baringer that does nesting for you:

(defmacro with-nesting ((&key) &rest things)
(reduce #'(lambda (outer inner) (append outer (list inner)))
things :from-end t))
 In
fact, I added a macro to our library that is like
"let" but does not allow the variable to be modified.
(It's not portable; it uses a CCL-specific feature.)
Yet Pascal just offered a portable implementation!

Here's mine.

(defmacro read-only (value name)
(declare (ignore name))
value)
(define-setf-expander read-only (value name &environment env)
(declare (ignore value env))
(error "Thou shall not attempt to modify read-only variable ~S" name))

(defmacro let-1-constant ((var val) &body body)
(let ((s (gensym)))
`(let ((,s ,val))
(symbol-macrolet ((,var (read-only ,s ,var)))
Unfortunately, we do not use it in practice, since
it's so important for code style to be consistent
and it would be very hard to change all our
sources to do this, since it's hard to know from
looking at code whether the "let" variable
ever changes, and we have like 700MLOC
of code in QRes.  I wish Common Lisp had
always had such a feature.
That's a bogus reason not to enact a style guide for *future* code.
You've even done it before.
Also, putting things in the parameter list that aren't
parameters just feels weird.
See Hofstadter's "Le ton beau de Marot" about warts.
I do not think my own opinions are by any
means "right".  These are just my biases
and preferences.
If you were sincere in this statement, then why share them?

—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org
Multiple instances of a same hacker with different context in his mental
cache count as multiple hackers wrt documentation and testing needs.
Steve Haflich
2011-06-12 19:22:58 UTC
Permalink
What I dislike about &aux is that it encourages scoping a lexical variable
around the entire lambda body. I prefer whenever possible to scope a local
variable over the smallest region in which it is referenced. While this adds
more let forms to the code, it makes the code easier to read. One knows the
scope over which a variable may be used and need not eyeball the entirerty
of a long function body ro be sure the variable isn't referenced somewhere
distant.

&aux always reminds me of 40-year-old FORTRAN code where all variables were
declared at the head of a function body, and were scoped over the entire
body. A lot of more-recent C code is still like this, although modern
interactive highlighting editors mitigate the unreadability somewhat.
Post by Faré
Post by Daniel Weinreb
I, myself, really dislike &aux. It has been so long
since I have seen it that I have forgotten that
it even exists. We never use it; and I should
add that to our style guide.
&aux has its uses. Sometimes it can be clearer than adding a let.
Post by Daniel Weinreb
I don't even like
(let (a b c) ...)
Same thing. If you're going to do side effects (sometimes you have to)
in particular when you need the binding to be visible in a scope
that starts before you have a useful value to initialize it with,
then it's clearer to say let (a) and make it clear
it's conceptually uninitialized than say let ((a nil))
where nil is bogus and not even an admissible value for the
variable's intended type. See especially unwind-protect forms.
Post by Daniel Weinreb
since I prefer to think of "let" in the Scheme sense
of "I am naming the result of a computation."
Call that something else than let if you want, it's a useful idiom.
Also, binding forms are annoying in that they are verbose
and move the body to the right as you nest them.
Instead of any ad-hoc do-it-all binding macro,
(defmacro with-nesting ((&key) &rest things)
(reduce #'(lambda (outer inner) (append outer (list inner)))
things :from-end t))
Post by Daniel Weinreb
In
fact, I added a macro to our library that is like
"let" but does not allow the variable to be modified.
(It's not portable; it uses a CCL-specific feature.)
Yet Pascal just offered a portable implementation!
Here's mine.
(defmacro read-only (value name)
(declare (ignore name))
value)
(define-setf-expander read-only (value name &environment env)
(declare (ignore value env))
(error "Thou shall not attempt to modify read-only variable ~S" name))
(defmacro let-1-constant ((var val) &body body)
(let ((s (gensym)))
`(let ((,s ,val))
(symbol-macrolet ((,var (read-only ,s ,var)))
Post by Daniel Weinreb
Unfortunately, we do not use it in practice, since
it's so important for code style to be consistent
and it would be very hard to change all our
sources to do this, since it's hard to know from
looking at code whether the "let" variable
ever changes, and we have like 700MLOC
of code in QRes. I wish Common Lisp had
always had such a feature.
That's a bogus reason not to enact a style guide for *future* code.
You've even done it before.
Post by Daniel Weinreb
Also, putting things in the parameter list that aren't
parameters just feels weird.
See Hofstadter's "Le ton beau de Marot" about warts.
Post by Daniel Weinreb
I do not think my own opinions are by any
means "right". These are just my biases
and preferences.
If you were sincere in this statement, then why share them?
—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics•
http://fare.tunes.org
Post by Faré
Multiple instances of a same hacker with different context in his mental
cache count as multiple hackers wrt documentation and testing needs.
_______________________________________________
pro mailing list
http://lists.common-lisp.net/cgi-bin/mailman/listinfo/pro
Scott L. Burson
2011-06-12 19:56:54 UTC
Permalink
Content preview: On Sun, Jun 12, 2011 at 7:00 AM, Daniel Weinreb <dlw-FrUbXkNCsVf2fBVCVOL8/***@public.gmane.org>
wrote: > I, myself, really dislike &aux. > > I don't even like > > (let (a
b c) ...) Agreed on both counts. &aux is just gross. Like LOOP :-) <ducks>
[...]

Content analysis details: (-100.7 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low
trust
[209.85.161.179 listed in list.dnswl.org]
-100 USER_IN_WHITELIST From: address is in the user's white-list
-0.0 SPF_PASS SPF: sender matches SPF record
Archived-At: <http://permalink.gmane.org/gmane.lisp.cl-pro/432>
Post by Daniel Weinreb
I, myself, really dislike &aux.
I don't even like
(let (a b c) ...)
Agreed on both counts. &aux is just gross. Like LOOP :-) <ducks>

As for read-only variables -- yes, it would have been nice if Lisp had
used ML-style references(*) from the beginning. I understand many
Scheme compilers have to perform this transformation anyway --
locating local variables subject to assignment, and consing heap cells
to hold their values -- in order for continuation capture to work
correctly in the presence of assignment.

(* But I don't like "reference" as a term for this concept; "cell" is better.)
Post by Daniel Weinreb
Also, binding forms are annoying in that they are verbose
and move the body to the right as you nest them.
Instead of any ad-hoc do-it-all binding macro,
I use multiple values far too much to tolerate typing
MULTIPLE-VALUE-BIND all the time. So I am very much a fan of my
binding macro, which I protest is not ad hoc at all -- it generalizes
LET, LET*, and MULTIPLE-VALUE-BIND in any combination, less verbosely
and with less moving of the body to the right. It's also upward
compatible with CL:LET.

In case anyone's interested, it's at
http://common-lisp.net/project/misc-extensions/

It doesn't do destructuring, though, so I suppose it's not quite
"do-it-all". Maybe someday I will integrate fare-matcher.
Post by Daniel Weinreb
Yet Pascal just offered a portable implementation [of read-only variables]!
Here's mine.
[snip]
Very cute. I might start using this.

-- Scott
Scott L. Burson
2011-06-12 23:27:46 UTC
Permalink
Content preview: On Sun, Jun 12, 2011 at 1:17 PM, Gary King <gwking-KFOG0ziCLXtWk0Htik3J/***@public.gmane.org>
wrote: > In the spirit of tooting my own horn, you might also want to see
metabang-bind (http://common-lisp.net/project/metabang-bind). [...]

Content analysis details: (-100.7 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-100 USER_IN_WHITELIST From: address is in the user's white-list
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low
trust
[209.85.218.51 listed in list.dnswl.org]
-0.0 SPF_PASS SPF: sender matches SPF record
Archived-At: <http://permalink.gmane.org/gmane.lisp.cl-pro/433>
In the spirit of tooting my own horn, you might also want to see metabang-bind (http://common-lisp.net/project/metabang-bind).
I'm aware of it, thanks. I'm afraid I'm quite attached to my own LET
macro, of which I wrote the first version in Zetalisp in 1980. -- I
wish I had made more noise about it at the time. The multiple value
binding syntax, at least, could have become part of CL:

(let ((val1 val2 val3 (form))) ...)

BIND's considerably greater functionality is bought at the price of
greater verbosity in the multiple-value case, which for me is by far
the most common.

-- Scott
Gary King
2011-06-12 20:17:47 UTC
Permalink
Content preview: Hi Scott, > In case anyone's interested, it's at > http://common-lisp.net/project/misc-extensions/
Post by Scott L. Burson
In the spirit of tooting my own horn, you might also want to see metabang-bind
(http://common-lisp.net/project/metabang-bind). [...]

Content analysis details: (-100.0 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low
trust
[216.119.134.130 listed in list.dnswl.org]
-100 USER_IN_WHITELIST From: address is in the user's white-list
Archived-At: <http://permalink.gmane.org/gmane.lisp.cl-pro/434>

Hi Scott,
Post by Scott L. Burson
In case anyone's interested, it's at
http://common-lisp.net/project/misc-extensions/
In the spirit of tooting my own horn, you might also want to see metabang-bind (http://common-lisp.net/project/metabang-bind).


--
Gary Warren King, metabang.com
Cell: (413) 559 8738
Fax: (206) 338-4052
gwkkwg on Skype * garethsan on AIM * gwking on twitter
Ala'a Mohammad
2011-06-13 06:49:31 UTC
Permalink
Content preview: On Sun, Jun 12, 2011 at 7:08 PM, Faré wrote: > Also, binding
forms are annoying in that they are verbose > and move the body to the right
as you nest them. > Instead of any ad-hoc do-it-all binding macro, > I like
this macro from Marco Baringer that does nesting for you: > > (defmacro with-nesting
((&key) &rest things) > (reduce #'(lambda (outer inner) (append outer (list
inner))) > things :from-end t)) [...]

Content analysis details: (-0.7 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
0.0 FREEMAIL_FROM Sender email is freemail (amalawi[at]gmail.com)
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low
trust
[209.85.220.179 listed in list.dnswl.org]
-0.0 SPF_PASS SPF: sender matches SPF record
0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain
0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid
X-BeenThere: pro-***@public.gmane.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: Common Lisp Professionals <pro.common-lisp.net>
List-Unsubscribe: <http://lists.common-lisp.net/cgi-bin/mailman/options/pro>,
<mailto:pro-request-***@public.gmane.org?subject=unsubscribe>
List-Archive: <http://lists.common-lisp.net/pipermail/pro>
List-Post: <mailto:pro-***@public.gmane.org>
List-Help: <mailto:pro-request-***@public.gmane.org?subject=help>
List-Subscribe: <http://lists.common-lisp.net/cgi-bin/mailman/listinfo/pro>,
<mailto:pro-request-***@public.gmane.org?subject=subscribe>
Errors-To: pro-bounces-***@public.gmane.org
X-Spam-Score: -0.7 (/)
X-Spam-Report: Spam detection software, running on the system "common-lisp.net", has
identified this incoming email as possible spam. The original message
has been attached to this so you can view it (if it isn't spam) or label
similar future email. If you have any questions, see
the administrator of that system for details.

Content preview: On Sun, Jun 12, 2011 at 7:08 PM, Faré wrote: > Also, binding
forms are annoying in that they are verbose > and move the body to the right
as you nest them. > Instead of any ad-hoc do-it-all binding macro, > I like
this macro from Marco Baringer that does nesting for you: > > (defmacro with-nesting
((&key) &rest things) > (reduce #'(lambda (outer inner) (append outer (list
inner))) > things :from-end t)) [...]

Content analysis details: (-0.7 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low
trust
[209.85.220.179 listed in list.dnswl.org]
0.0 FREEMAIL_FROM Sender email is freemail (amalawi[at]gmail.com)
-0.0 SPF_PASS SPF: sender matches SPF record
0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain
0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid
Archived-At: <http://permalink.gmane.org/gmane.lisp.cl-pro/435>
Post by Faré
Also, binding forms are annoying in that they are verbose
and move the body to the right as you nest them.
Instead of any ad-hoc do-it-all binding macro,
(defmacro with-nesting ((&key) &rest things)
 (reduce #'(lambda (outer inner) (append outer (list inner)))
         things :from-end t))
Is there anything that with-nesting can do, where let* or 'proper
abstraction' outside the binding form (with defun, macros, labels,
flet, etc) can not do? It would be helpful/educational if an example
was provided.

Regards,

- Ala'a
Jean-Philippe Paradis
2011-06-13 11:34:50 UTC
Permalink
Content preview: [ Sorry for double-post Ala'a, I forgot to reply-all :( ]
WITH-NESTING reduces the nesting cost of an arbitrary number of consecutive
binding forms to one level, with a highly regular and simple syntax almost
inherently readable to anyone without prior exposure (I think?). It may not
be the most concise syntax of all, but it has the benefit of simplicity and
most importantly, sanity. [...]

Content analysis details: (-0.7 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low
trust
[209.85.214.179 listed in list.dnswl.org]
0.0 FREEMAIL_FROM Sender email is freemail (hexstream[at]gmail.com)
-0.0 SPF_PASS SPF: sender matches SPF record
0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain
0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid
0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL
Archived-At: <http://permalink.gmane.org/gmane.lisp.cl-pro/436>

[ Sorry for double-post Ala'a, I forgot to reply-all :( ]

WITH-NESTING reduces the nesting cost of an arbitrary number of
consecutive binding forms to one level, with a highly regular and
simple syntax almost inherently readable to anyone without prior
exposure (I think?). It may not be the most concise syntax of all, but
it has the benefit of simplicity and most importantly, sanity.

The only reason I'm not actually using it is that I don't often
encounter scenarios complex enough where using it would significantly
improve the situation (and I'd consider it bad style to use it if it
doesn't significantly improve the situation. Usually a simple
refactoring will obviate the "need" for it). As circumstantial
evidence, I had to make a synthetic example to show it in a scenario
where it would help...

(with-nesting ()
(let ((a 'a)))
(destructuring-bind (b c) '(b c))
(multiple-value-bind (d e) (values 'd 'e))
(let* ((f 'f)
(g (list f 'g))))
(destructuring-bind (h i j) (cons f g))
(progn 'HUGE-body
(values a b c d e f g h i j)))
=> A, B, C, D, E, F, (F G), F, F, G

VS

(let ((a 'a))
(destructuring-bind (b c) '(b c)
(multiple-value-bind (d e) (values 'd 'e)
(let* ((f 'f)
(g (list f 'g)))
(destructuring-bind (h i j) (cons f g)
(progn 'HUGE-body
(values a b c d e f g h i j)))))))
Tamas K Papp
2011-06-13 12:36:09 UTC
Permalink
I, myself, really dislike &aux. It has been so long since I have seen >
it that I have forgotten that it even exists. We never use it; and I > should
add that to our style guide. [...]

Content analysis details: (-2.3 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium
trust
[80.91.229.12 listed in list.dnswl.org]
0.0 FREEMAIL_FROM Sender email is freemail (tkpapp[at]gmail.com)
-0.0 SPF_HELO_PASS SPF: HELO matches SPF record
-0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay
domain
-0.0 SPF_PASS SPF: sender matches SPF record
0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL
Archived-At: <http://permalink.gmane.org/gmane.lisp.cl-pro/437>
I, myself, really dislike &aux. It has been so long since I have seen
it that I have forgotten that it even exists. We never use it; and I
should add that to our style guide.
I was wondering about the use of &aux a while ago, so I asked on c.l.l:

http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/586ca399d6b7e0b4/ad1bfb5a629597cb

The examples convinced me that it is occasionally useful. However, as
the previous thread shows, it is still not part of my "active" CL
vocabulary, so sometimes I don't think of it as a solution. Maybe
that will change and I will remember it the next time I need it.
I don't even like
(let (a b c) ...)
I find (let (a b c) ...) very useful occasionally. I am curious how
you would write this without it:

(defun map-as-rows (function vector)
"Map elements of vector, collect into a matrix."
(let ((vector-length (length vector))
result
result-length)
(dotimes (index vector-length)
(let ((result-row (funcall function (aref vector index))))
(if (zerop index)
(setf result-length (length result-row)
result (make-array (list vector-length result-length)))
(assert (= (length result-row) result-length) ()
"Incompatible length of results."))
(replace (make-array result-length
:displaced-to result
:displaced-index-offset (* index result-length))
result-row)))
result))

(map-as-rows (lambda (x) (vector x (expt x 2))) #(1 2 3 4))

#2A((1 1)
(2 4)
(3 9)
(4 16))

The only way I see is traversing the results one more time to form the matrix.

Best,

Tamas
Ken Tilton
2011-06-13 13:28:06 UTC
Permalink
Content preview: On 6/12/2011 10:00 AM, Daniel Weinreb wrote: > I, myself,
really dislike &aux. It has been so long > since I have seen it that I have
forgotten that > it even exists. We never use it; and I should > add that
to our style guide. I hate (a) typing a let and (b) giving up a level of
indentation if I just need one local variable. [...]

Content analysis details: (-100.7 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low
trust
[209.85.218.51 listed in list.dnswl.org]
-100 USER_IN_WHITELIST From: address is in the user's white-list
0.0 FREEMAIL_FROM Sender email is freemail (kentilton[at]gmail.com)
-0.0 SPF_PASS SPF: sender matches SPF record
0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain
0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid
0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL
Archived-At: <http://permalink.gmane.org/gmane.lisp.cl-pro/438>
Post by Daniel Weinreb
I, myself, really dislike &aux. It has been so long
since I have seen it that I have forgotten that
it even exists. We never use it; and I should
add that to our style guide.
I hate (a) typing a let and (b) giving up a level of indentation if I
just need one local variable.

But I do not use &aux much. My b-if and b-when macros establish most of
my local variables, and I strive anyway for a functional style.
Post by Daniel Weinreb
I don't even like
(let (a b c) ...)
Yikes. With values to be named at a later line of code? A finite state
machine, perhaps?

kt
Ken Tilton
2011-06-13 14:23:32 UTC
Permalink
Content preview: On 6/12/2011 10:00 AM, Daniel Weinreb wrote: > I, myself,
really dislike &aux. It has been so long > since I have seen it that I have
forgotten that > it even exists. We never use it; and I should > add that
to our style guide. [...]

Content analysis details: (-100.7 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low
trust
[209.85.218.51 listed in list.dnswl.org]
-100 USER_IN_WHITELIST From: address is in the user's white-list
0.0 FREEMAIL_FROM Sender email is freemail (kentilton[at]gmail.com)
-0.0 SPF_PASS SPF: sender matches SPF record
0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain
0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid
0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL
Archived-At: <http://permalink.gmane.org/gmane.lisp.cl-pro/439>
Post by Daniel Weinreb
I, myself, really dislike &aux. It has been so long
since I have seen it that I have forgotten that
it even exists. We never use it; and I should
add that to our style guide.
I forgot to mention another reason I like &aux -- nostalgia. It is like
using rplacd instead of (setf cdr), or the way some pitchers in baseball
wear the old-fashioned leggings. Having come to Lisp late in the game, I
like the punch card feel I get from the archaic forms, the sense of
being there at the beginning.

kt

Loading...