From: Surendra Singhi
Subject: using function names as variable names? Is it Justified?
Date: 
Message-ID: <cobcfl$j2l$3@news.asu.edu>
Taken from thread Re: passing parameters by reference

 >David Sletten wrote:
 > 1. Common Lisp has different namespaces for, inter alia, variables and
 > functions. What this means is that while the symbol LIST names a
 > built-in function, it can also be used independently as a variable >name
 > too: (defun add (list element) ...


I have seen a couple of discussions on this earlier, but don't you feel 
it is confusing and error prone to use such names as variables. 
Especially when someone is looking at a piece of code cursorily the 
variable may look like a function call, particularly with let expressions.
Example:
(defun add()
    (let ((var (list exp))
          (list (cons a b))
           .....
or some piece of line in a long function:
    (list list abc)

I agree that a careful look at the code will definitely reveal whether 
it is a function call or a variable name, but is it worth doing?
And as a principle of clean programming practice shouldn't it be 
discouraged?

-- 
Surendra Singhi

www.public.asu.edu/~sksinghi

From: Kaz Kylheku
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <cf333042.0411280919.7bea274d@posting.google.com>
Surendra Singhi <·········@netscape.net> wrote in message news:<············@news.asu.edu>...
> Taken from thread Re: passing parameters by reference
> 
>  >David Sletten wrote:
>  > 1. Common Lisp has different namespaces for, inter alia, variables and
>  > functions. What this means is that while the symbol LIST names a
>  > built-in function, it can also be used independently as a variable >name
>  > too: (defun add (list element) ...
> 
> 
> I have seen a couple of discussions on this earlier, but don't you feel 
> it is confusing and error prone to use such names as variables. 

Some of us think rather than feel. Yes, it can be confusing to have
the same symbol refer to different things in the same vicinity. That
isn't a good enough reason to drive it out of the language.

It's the very essence of a symbol that it can be overloaded with
contexts that give it a different meaning.

> Especially when someone is looking at a piece of code cursorily the 
> variable may look like a function call, particularly with let expressions.
> Example:
> (defun add()
>     (let ((var (list exp))
>           (list (cons a b))
>            .....
> or some piece of line in a long function:
>     (list list abc)

The confusion here could be only in the mind of someone who doesn't
understand the different meaning of the first position of an
expression.

> I agree that a careful look at the code will definitely reveal whether 
> it is a function call or a variable name, but is it worth doing?

A careful look? You mean, seeing whether the symbol appears in the
leftmost position of the expression? Boy, is that ever anally
retentive. Who has time to read code that deeply?
From: Surendra Singhi
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <codsqh$ef1$1@news.asu.edu>
Kaz Kylheku wrote:
> Surendra Singhi <·········@netscape.net> wrote in message news:<············@news.asu.edu>...
> 
>>Taken from thread Re: passing parameters by reference
>>
>> >David Sletten wrote:
>> > 1. Common Lisp has different namespaces for, inter alia, variables and
>> > functions. What this means is that while the symbol LIST names a
>> > built-in function, it can also be used independently as a variable >name
>> > too: (defun add (list element) ...
>>
>>
>>I have seen a couple of discussions on this earlier, but don't you feel 
>>it is confusing and error prone to use such names as variables. 
> 
> 
> Some of us think rather than feel. Yes, it can be confusing to have
> the same symbol refer to different things in the same vicinity. That
> isn't a good enough reason to drive it out of the language.
> 
> It's the very essence of a symbol that it can be overloaded with
> contexts that give it a different meaning.
> 
> 
>>Especially when someone is looking at a piece of code cursorily the 
>>variable may look like a function call, particularly with let expressions.
>>Example:
>>(defun add()
>>    (let ((var (list exp))
>>          (list (cons a b))
>>           .....
>>or some piece of line in a long function:
>>    (list list abc)
> 
> 
> The confusion here could be only in the mind of someone who doesn't
> understand the different meaning of the first position of an
> expression.
> 
Then you may as well say that syntax highlighting is not needed.

-- 
Surendra Singhi

www.public.asu.edu/~sksinghi
From: David Steuber
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <87fz2s66zn.fsf@david-steuber.com>
Surendra Singhi <·········@netscape.net> writes:

> Then you may as well say that syntax highlighting is not needed.

I do not use it.  I used to to help me with C so that I would know if
I misspelled the keyword 'default' in a switch block.  That was about
all it was good for.

Also, syntax highlighting gets quite bad when yellow on white is
produced.

-- 
An ideal world is left as an excercise to the reader.
   --- Paul Graham, On Lisp 8.1
From: Pascal Bourguignon
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <87llckd1ek.fsf@thalassa.informatimago.com>
Ingvar <······@hexapodia.net> writes:
> I, personally, find it more distracting than helpful. Especially with
> (some) programming languages, where existing highlighting methods
> (occasionallY) produce incorrectly-hightlighted code.
> 
> I always switch highlighting off, as soon as I figure out how to, in
> all editors I work with.

Well, one thing I find highlighting useful for is to let me know if I
typed a predefined symbol correctly.  It also helps to avoid naming
functions and variables with "reserved" symbols.

Granted, instead of color, the editor could upcase the predefined symbols...


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
The world will now reboot; don't bother saving your artefacts.
From: Harald Hanche-Olsen
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <pcopt1ygrfe.fsf@shuttle.math.ntnu.no>
+ Surendra Singhi <·········@netscape.net>:

|     (list list abc)
| 
| I agree that a careful look at the code will definitely reveal
| whether it is a function call or a variable name, but is it worth
| doing?

Yes.  After all, the most obvious name for a generic list is LIST, is
it not so?

| And as a principle of clean programming practice shouldn't it be
| discouraged?

I suggest you go have a look at older posts to this group.  Look for
posts by Kent Pitman containing the phrase "lisp-2" for quite a lot of
thoughtful discussion of these points.  Oldtimers on this list are
sort of tired of the discussion I think, so please read those old
posts and ponder a bit before coming back.  You may find relevant
reading at Kent's homepage <http://www.nhplace.com/kent/> too.  (Right
now I get connection refused there, but hopefully that is temporary.)

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
  than thinking does: but it deprives us of whatever chance there is
  of getting closer to the truth.  -- C.P. Snow
From: Surendra Singhi
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <corm59$4ac$1@news.asu.edu>
Harald Hanche-Olsen wrote:

> + Surendra Singhi <·········@netscape.net>:
> 
> |     (list list abc)
> | 
> | I agree that a careful look at the code will definitely reveal
> | whether it is a function call or a variable name, but is it worth
> | doing?
> 
> Yes.  After all, the most obvious name for a generic list is LIST, is
> it not so?
> 
> | And as a principle of clean programming practice shouldn't it be
> | discouraged?
> 
> I suggest you go have a look at older posts to this group.  Look for
> posts by Kent Pitman containing the phrase "lisp-2" for quite a lot of
> thoughtful discussion of these points.  Oldtimers on this list are
> sort of tired of the discussion I think, so please read those old
> posts and ponder a bit before coming back.  You may find relevant
> reading at Kent's homepage <http://www.nhplace.com/kent/> too.  (Right
> now I get connection refused there, but hopefully that is temporary.)
> 
I am still getting connection refused on his website. Any idea where it 
has moved?

-- 
Surendra Singhi

www.public.asu.edu/~sksinghi
From: Harald Hanche-Olsen
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <pcooehajnmv.fsf@shuttle.math.ntnu.no>
+ Surendra Singhi <·········@netscape.net>:

| Harald Hanche-Olsen wrote:
| > [...]  You may find relevant reading at Kent's homepage
| > <http://www.nhplace.com/kent/> too.  (Right now I get connection
| > refused there, but hopefully that is temporary.)
| >
| I am still getting connection refused on his website.

Indeed.

| Any idea where it has moved?

No reason to believe it has moved anywhere.  Kent himself is listed as
the administrative contact for the nhplace.com domain.  It's been a
very long time since he made an appearance on this newsgroup.
Hopefully, all this just means that he is too busy making money
writing Lisp programs to spend much time either here or in maintaining
his web server.  I am going to write him and ask about the web
server.  In the meantime, you can try the wayback machine.

  http://web.archive.org/   - or directly:
  http://web.archive.org/web/20040203154211/http://www.nhplace.com/kent/

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
  than thinking does: but it deprives us of whatever chance there is
  of getting closer to the truth.  -- C.P. Snow
From: Harald Hanche-Olsen
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <pco4qj19gfn.fsf@shuttle.math.ntnu.no>
+ Harald Hanche-Olsen <······@math.ntnu.no>:

| + Surendra Singhi <·········@netscape.net>:
| 
| | Harald Hanche-Olsen wrote:
| | > [...]  You may find relevant reading at Kent's homepage
| | > <http://www.nhplace.com/kent/> too.  (Right now I get connection
| | > refused there, but hopefully that is temporary.)
| | >
| | I am still getting connection refused on his website.
| 
| Indeed.

www.nhplace.com is now back online.  Kent had just been too busy to
notice it was down.

- Harald
From: Cameron MacKinnon
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <d5WdnfVfNaHdvDfcRVn-jw@golden.net>
Surendra Singhi wrote:
> I have seen a couple of discussions on this earlier, but don't you feel 
> it is confusing and error prone to use such names as variables. 
> Especially when someone is looking at a piece of code cursorily the 
> variable may look like a function call, particularly with let expressions.
> Example:
> (defun add()
>    (let ((var (list exp))
>          (list (cons a b))
>           .....
> or some piece of line in a long function:
>    (list list abc)
> 

> I agree that a careful look at the code will definitely reveal whether 
> it is a function call or a variable name, but is it worth doing?
> And as a principle of clean programming practice shouldn't it be 
> discouraged?

Conflating function names and variable names should be discouraged. Code 
  (especially published code) is written to be read by people as well as 
read by (read).

Nearly every human language (computer programming languages included) 
has extra features of punctuation, capitalization and spelling variation 
to disambiguate nouns from verbs and add type annotations. With more 
visual cues, parsing is quick, accurate and context insensitive.

Lisp programmers seem to take a perverse pleasure in removing all 
extraneous annotations - Punctuation and capitalization are avoided, and 
  function names are deliberately recycled, partially to differentiate 
Lisp coding style from Scheme's. Thus the reader of Lisp code must 
implement his very own little code walker in neurons, annotating each 
symbol with 'variable' or 'function', and taking into account Lisp's 
special forms.

Seasoned Lispers invariably report that the disambiguation becomes 
automatic. From this we can infer that either a) anyone can quickly grow 
their own neural Lisp-2 parser, or b) those that can't don't get far in 
the Lisp world.

I believe that, even though disambiguation becomes subconscious, it is 
likely that coders' performance when impaired (sleep deprived, 
intoxicants etc.) suffers more disambiguating list from list than $x 
from %x. It just stands to reason that tasks requiring more context 
require more brainpower at a higher level.


Luckily, implementing these code walkers in Lisp is easy, which presents
two opportunities: You can write a rewrite function that renames 
variables that clash with function names, or you can hack your editor 
(your editor IS hackable, right?) to vary the colour and font choices 
for Lisp's nouns and verbs.

Either of those will be a lot more productive than trying to change 
others' opinions on the topic - Lisp punners will continue to write and 
post code that puns with impunity, and to mock code that avoids punning 
as too Scheme-ish.
From: Pascal Bourguignon
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <87sm6teouv.fsf@thalassa.informatimago.com>
Cameron MacKinnon <··········@clearspot.net> writes:
> Conflating function names and variable names should be
> discouraged. Code (especially published code) is written to be read by
> people as well as read by (read).
> 
> Nearly every human language (computer programming languages included)
> has extra features of punctuation, capitalization and spelling
> variation to disambiguate nouns from verbs and add type
> annotations. With more visual cues, parsing is quick, accurate and
> context insensitive.

That's plainly wrong. 

drunk gets nine months in violin case
Iraqi head seeks arms
prostitutes appeal to pope
teacher strikes idle kids
squad helps dog bite victim
enraged cow injures farmer with ax
miners refuse to work after death
juvenile court to try shooting defendant
stolen painting found by tree
two Soviet ships collide, one dies
two sisters reunited after 18 years in checkout counter 

Natural language is context sensitive, and there's no reason why you
should ignore the context of a lisp symbol.  Your brain is designed
to handle context!


> Lisp programmers seem to take a perverse pleasure in removing all
> extraneous annotations - Punctuation and capitalization are avoided,
> and function names are deliberately recycled, partially to
> differentiate Lisp coding style from Scheme's. Thus the reader of Lisp
> code must implement his very own little code walker in neurons,
> annotating each symbol with 'variable' or 'function', and taking into
> account Lisp's special forms.

If you don't use your neurons, they die!

 
> Luckily, implementing these code walkers in Lisp is easy, which presents
> two opportunities: You can write a rewrite function that renames
> variables that clash with function names, or you can hack your editor
> (your editor IS hackable, right?) to vary the colour and font choices
> for Lisp's nouns and verbs.
> 
> Either of those will be a lot more productive than trying to change
> others' opinions on the topic - Lisp punners will continue to write
> and post code that puns with impunity, and to mock code that avoids
> punning as too Scheme-ish.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
The world will now reboot; don't bother saving your artefacts.
From: Cameron MacKinnon
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <gv-dnaKn2PCBLDfcRVn-3A@golden.net>
Pascal Bourguignon wrote:
> Cameron MacKinnon <··········@clearspot.net> writes:
> 
>>Nearly every human language (computer programming languages included)
>>has extra features of punctuation, capitalization and spelling
>>variation to disambiguate nouns from verbs and add type
>>annotations. With more visual cues, parsing is quick, accurate and
>>context insensitive.
> 
> 
> That's plainly wrong. 
> 
> drunk gets nine months in violin case
> Iraqi head seeks arms
...

These phrases have all been collected together precisely because they 
are bad, in the sense that they're either superficially ambiguous or 
ungrammatical split infinitives.

They were all created to entice people to read the articles they 
headlined, and the choice was between a clear phrase at 24pt. and an 
ambiguous parse at 36pt. That's advertising for you.


Consider instead a mathematician who begins a presentation with "Let x 
denote a number in the set of odd natural numbers. Now we also have a 
function x which determines whether its argument is prime. Don't worry; 
you'll always know whether I'm referring to the function or the number 
from its context..."  His peers would think him deliberately obtuse.


If one aspires to write code as elegant, in its own way, as the most 
beautiful mathematics or the finest literature, one will avoid puns, 
which are, after all, a low form of humour.
From: Kenny Tilton
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <UOzqd.20749$ld2.6317471@twister.nyc.rr.com>
Cameron MacKinnon wrote:
> If one aspires to write code as elegant, in its own way, as the most 
> beautiful mathematics or the finest literature, one will avoid puns, 
> which are, after all, a low form of humour.

"list" is not a pun, it is the Right Name for an argument to a generic 
list-manipulation function.

folks type "lst" instead of "list" just to avoid the name clash in a 
Lisp-1. They do not /really/ want to mangle the name, which mangling 
adds its own drag on readability.

Overall, it is a close call. Without real world code snippets to 
discuss, too close to argue fruitfully. My2.

kenny

-- 
Cells? Cello? Celtik?: http://www.common-lisp.net/project/cells/
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
From: Surendra Singhi
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <coenhd$rjq$1@news.asu.edu>
Kenny Tilton wrote:

> 
> 
> Cameron MacKinnon wrote:
> 
>> If one aspires to write code as elegant, in its own way, as the most 
>> beautiful mathematics or the finest literature, one will avoid puns, 
>> which are, after all, a low form of humour.
> 
> 
> "list" is not a pun, it is the Right Name for an argument to a generic 
> list-manipulation function.
> 
> folks type "lst" instead of "list" just to avoid the name clash in a 
> Lisp-1. They do not /really/ want to mangle the name, which mangling 
> adds its own drag on readability.
> 
> Overall, it is a close call. Without real world code snippets to 
> discuss, too close to argue fruitfully. My2.
> 
> kenny
> 
I think as a neat and clean programming practice name mangling should be 
discouraged(and definitely not advocated) for the sake of

 >>Cameron MacKinnon wrote:
 >> coders' performance when impaired (sleep deprived, intoxicants etc.)

and avoided in most of the code, and as you suggested

 >>Kenny Tilton wrote:
 >>Folks who code:
 >>(defun add (a b &aux (list (list a b)))
 >>   (apply '+ list))

 >>...um, should have used "addends" instead of "list".

should be preferred.

-- 
Surendra Singhi

www.public.asu.edu/~sksinghi
From: Cameron MacKinnon
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <TtmdnXjLDcB2SjfcRVn-hQ@golden.net>
Kenny Tilton wrote:
> "list" is not a pun, it is the Right Name for an argument to a generic 
> list-manipulation function.

The Right Name for a generic list is l. Just as math gave us x and 
Fortran begat i,j,k..., the Lisp idiom should have been l, following the 
principle that generic variable names should be as short as the language 
allows.

As l and 1 look uncomfortably alike in the monofont traditionally 
offered to coders, this usage has been taboo. If, in this age of 
bounteous character sets, fountains of fonts and excellent editors, we 
could allow ourselves the luxury of a prolate cycloid glyph for this 
symbol, the language would be made more beautiful at a stroke.
From: Gisle Sælensminde
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <slrncqlnba.57n.gisle@kaktus.ii.uib.no>
On 2004-11-29, Cameron MacKinnon <··········@clearspot.net> wrote:
> Kenny Tilton wrote:
>> "list" is not a pun, it is the Right Name for an argument to a generic 
>> list-manipulation function.
>
> The Right Name for a generic list is l. Just as math gave us x and 
> Fortran begat i,j,k..., the Lisp idiom should have been l, following the 
> principle that generic variable names should be as short as the language 
> allows.

What is s then? A string, a sequence or a stream? Personally I find code
using such tearseness to be less readable than code that is spelling things
more out, since such it often be ambigous.

To get enough symbols to make things unambigous, math is distinguishing
between upper and lowercase letters, and has introduced greek and hebrew 
letters as well as caligraphic letters and a lot of special symbols.  
You can't do that in Common Lisp.

In some frequent cases, like loop variables, it is a good things to use
short names like 'i', 'j' and 'k', and variable names like 
'inner-loop-index', is less readable. You need a balance, but one letter
variables is often providing too little information to the reader of the 
code.

-- 
Gisle S�lensminde, Phd student, Scientific programmer
Computational biology unit, University of Bergen, Norway
Email: ·····@cbu.uib.no | Complicated is easy, simple is hard.
From: Cameron MacKinnon
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <HJmdnQqa1LPrwzbcRVn-sQ@golden.net>
Marco Parrone wrote:
> Gisle S�lensminde on 29 Nov 2004 08:27:22 GMT writes:
> 
> 
>>>The Right Name for a generic list is l.
>>
>>What is s then? A string, a sequence or a stream? Personally I find code
>>using such tearseness to be less readable than code that is spelling things
>>more out, since such it often be ambigous.
> 
> Another problem with single-character variable names is that they are
> more difficult to find with automatic tools (like isearch-forward).

I don't advocate minimal naming for exotic datatypes or any symbol that 
is going to be used in such a large block that searching for it may be 
required. The coder who christens his variable 'list' (or rather, fails 
to) has already decided that he will illuminate nothing about it, save 
its type. If one is going to say nothing, one should be brief.

   If isearch-forward
   Are my blocks getting too big?
   Will symbols get lost?
From: Jock Cooper
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <m3is7nm8ru.fsf@jcooper02.sagepub.com>
Cameron MacKinnon <··········@clearspot.net> writes:

> Marco Parrone wrote:
> > Gisle S�lensminde on 29 Nov 2004 08:27:22 GMT writes:
> >
> >>>The Right Name for a generic list is l.
> >>
> >>What is s then? A string, a sequence or a stream? Personally I find code
> >>using such tearseness to be less readable than code that is spelling things
> >>more out, since such it often be ambigous.
> > Another problem with single-character variable names is that they are
> > more difficult to find with automatic tools (like isearch-forward).
> 
> I don't advocate minimal naming for exotic datatypes or any symbol
> that is going to be used in such a large block that searching for it
> may be required. The coder who christens his variable 'list' (or
> rather, fails to) has already decided that he will illuminate nothing
> about it, save its type. 

If I write a function whose purpose is to 'reverse a list', what do
you propose I name that variable?  Sometimes a list really is just a
list (within limited scopes).

I however do usually stay away from names like 'list' and use 'the-list' 
or 'list-to-sort' instead.   
From: Cameron MacKinnon
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <-P-dnVpfDdLC1DDcRVn-og@golden.net>
Jock Cooper wrote:
...
>>>>>The Right Name for a generic list is l.
...
> If I write a function whose purpose is to 'reverse a list', what do
> you propose I name that variable?  Sometimes a list really is just a
> list (within limited scopes).
> 
> I however do usually stay away from names like 'list' and use 'the-list' 
> or 'list-to-sort' instead.   

Why not list-which-i-will-not-otherwise-elaborate-upon?

That unattributed quote above? That was me. I've spelled the whole thing 
out in this thread. I've done everything but write the emacs code, as 
I'm no elisp hacker.

What I want is for standalone l and symbols like l<digit>* to display 
the l in a nice, cursive font. Others may want symbols of the form 
l-anything and anything-l to be so displayed. Pascal Bourguignon's code 
to display Greek letter names as their glyphs would make an excellent 
starting point:
http://groups.google.com/groups?hl=en&lr=&c2coff=1&selm=87y8q347jx.fsf%40thalassa.informatimago.com

You use emacs - do you write elisp? Care to give it a try?
From: Sashank Varma
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <none-FE81C0.11344202122004@news.vanderbilt.edu>
In article <······················@golden.net>,
 Cameron MacKinnon <··········@clearspot.net> wrote:

> Jock Cooper wrote:
> >
> > I however do usually stay away from names like 'list' and use 'the-list' 
> > or 'list-to-sort' instead.   
> 
> Why not list-which-i-will-not-otherwise-elaborate-upon?

the-variable-formally-known-as-\"-list-\"
From: Kenny Tilton
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <QOFqd.20756$ld2.6394441@twister.nyc.rr.com>
Cameron MacKinnon wrote:

> Kenny Tilton wrote:
> 
>> "list" is not a pun, it is the Right Name for an argument to a generic 
>> list-manipulation function.
> 
> 
> The Right Name for a generic list is l.
> Just as math gave us x and 
> Fortran begat i,j,k..., the Lisp idiom should have been l, following the 
> principle that generic variable names should be as short as the language 
> allows.
> 
> As l and 1 look uncomfortably alike in the monofont traditionally 
> offered to coders, this usage has been taboo. If, in this age of 
> bounteous character sets, fountains of fonts and excellent editors, we 
> could allow ourselves the luxury of a prolate cycloid glyph for this 
> symbol, the language would be made more beautiful at a stroke.

D, L d a l t a t l n w b.

I believe your language search should have stopped one letter in the 
alphabet sooner, at K. Now google /that/. (Don't worry, it is Turing 
complete.)

:)

kenny

-- 
Cells? Cello? Celtik?: http://www.common-lisp.net/project/cells/
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
From: Raffael Cavallaro
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <2004112919424116807%raffaelcavallaro@pasdespamsilvousplaitdotmaccom>
On 2004-11-29 03:03:54 -0500, Cameron MacKinnon 
<··········@clearspot.net> said:

> The Right Name for a generic list is l. Just as math gave us x and 
> Fortran begat i,j,k..., the Lisp idiom should have been l, following 
> the principle that generic variable names should be as short as the 
> language allows.


I would submit that the appropriate english-like differentiator between 
a verb (function or method) and noun (symbol name for a value) is to 
use an article (the, a, an), demonstrative pronoun (this, that, these, 
those), possessive-pronoun (my, your, his, her, their), or adjective 
(green, short, etc.).

Functions have no modifier:

list  <= denotes the standard common lisp function, list.

my-list  <= a variable name, signifying that the list belongs to the 
programmer.

your-list <= a variable name, signifying that the list belongs to the user.

that-list-way-over-yonder <= a variable name, signifying that the list 
belongs to neither the programmer nor the user, but some distant third 
party.

smelly-list <= a variable name, signifying that the list hasn't been 
laundered recently.

and so forth.

Thus, all such ambiguities would be avoided ;^)



Seriously, I find that I confuse myself by using the word 'list' as a 
variable name. I also dislike scheme's 'lst.' So, I often opt for:

some-list

the-list


but not:

a-list

because of the obvious potential confusion with the commonly used 
variable name for association lists.

my <$.02

Ralph
From: Steven E. Harris
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <jk48y8kz7wa.fsf@W003275.na.alarismed.com>
Kenny Tilton <·······@nyc.rr.com> writes:

> "list" is not a pun, it is the Right Name for an argument to a
> generic list-manipulation function.

Isn't the problem here really the function "list", which perhaps would
be better named "make-list"? Oh, wait, make-list does exist, and does
something different. Damn.

-- 
Steven E. Harris
From: Peter Seibel
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <m34qj89xbl.fsf@javamonkey.com>
"Steven E. Harris" <···@panix.com> writes:

> Kenny Tilton <·······@nyc.rr.com> writes:
>
>> "list" is not a pun, it is the Right Name for an argument to a
>> generic list-manipulation function.
>
> Isn't the problem here really the function "list", which perhaps
> would be better named "make-list"? Oh, wait, make-list does exist,
> and does something different. Damn.

Isn't the problem here really the word "list" which is both a verb and
a noun? How do English speaker ever deal with that ambiguity?

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Harald Hanche-Olsen
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <pco8y8k5omu.fsf@shuttle.math.ntnu.no>
+ Peter Seibel <·····@javamonkey.com>:

| Isn't the problem here really the word "list" which is both a verb
| and a noun? How do English speaker ever deal with that ambiguity?

When you get a list you really need to check if your load is shifting
or if you've sprung a leak.  Damn, looking up "list" in the dictionary
is downright intimidating.  Speak of ambiguity.  We'd better ban the
word from Lisp altogether.  You can never know for sure what it means.

Both a verb and a noun?  In the language in which every noun can be
verbed?  Hardly a problem.

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
  than thinking does: but it deprives us of whatever chance there is
  of getting closer to the truth.  -- C.P. Snow
From: Kenny Tilton
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <TOMqd.20780$ld2.6481438@twister.nyc.rr.com>
Steven E. Harris wrote:

> Kenny Tilton <·······@nyc.rr.com> writes:
> 
> 
>>"list" is not a pun, it is the Right Name for an argument to a
>>generic list-manipulation function.
> 
> 
> Isn't the problem here really the function "list", which perhaps would
> be better named "make-list"? Oh, wait, make-list does exist, and does
> something different. Damn.

Go ahead, list the alternatives...

:)

kt

-- 
Cells? Cello? Celtik?: http://www.common-lisp.net/project/cells/
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
From: Steven E. Harris
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <jk4mzx0xqcd.fsf@W003275.na.alarismed.com>
Kenny Tilton <·······@nyc.rr.com> writes:

> Go ahead, list the alternatives...

Let's see. How about "list-of", or "as-list"? But then we'd have to
work on "vector" as well, and I'm already bored with the non-problem.

-- 
Steven E. Harris
From: Barry Margolin
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <barmar-6683D0.15451529112004@comcast.dca.giganews.com>
In article <·······················@twister.nyc.rr.com>,
 Kenny Tilton <·······@nyc.rr.com> wrote:

> Cameron MacKinnon wrote:
> > If one aspires to write code as elegant, in its own way, as the most 
> > beautiful mathematics or the finest literature, one will avoid puns, 
> > which are, after all, a low form of humour.
> 
> "list" is not a pun, it is the Right Name for an argument to a generic 
> list-manipulation function.

And if you're writing a program for automobile applications, you should 
be able to use CAR as a variable name, despite the fact that it happens 
to be a homonym for a built-in function.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
From: Christopher C. Stacy
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <uact0ti2l.fsf@news.dtpq.com>
Barry Margolin <······@alum.mit.edu> writes:

> In article <·······················@twister.nyc.rr.com>,
>  Kenny Tilton <·······@nyc.rr.com> wrote:
> 
> > Cameron MacKinnon wrote:
> > > If one aspires to write code as elegant, in its own way, as the most 
> > > beautiful mathematics or the finest literature, one will avoid puns, 
> > > which are, after all, a low form of humour.
> > 
> > "list" is not a pun, it is the Right Name for an argument to a generic 
> > list-manipulation function.
> 
> And if you're writing a program for automobile applications, you should 
> be able to use CAR as a variable name, despite the fact that it happens 
> to be a homonym for a built-in function.

I had this (non) issue when working in telephony: Call Detail Records.
From: Harald Hanche-Olsen
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <pcod5xw5oyg.fsf@shuttle.math.ntnu.no>
+ Barry Margolin <······@alum.mit.edu>:

| And if you're writing a program for automobile applications, you
| should be able to use CAR as a variable name, despite the fact that
| it happens to be a homonym for a built-in function.

TIME is another obvious variable name, particularly since T is
unfortunately not available for the purpuse.

And I can easily imagine finding myself writing

(loop for (first second . rest) on list ...)

That's four examples in quick succession.

I have also found myself writing stuff like

(let ((cos (cos x))
      (sin (sin x)))
  ...)

for an expression using the same function values several times.
I find this very handy indeed:  The name helps me remember where the
value came from.

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
  than thinking does: but it deprives us of whatever chance there is
  of getting closer to the truth.  -- C.P. Snow
From: Alan Crowe
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <867jo3w4js.fsf@cawtech.freeserve.co.uk>
Kenny wrote:
> "list" is not a pun, it is the Right Name for an argument
> to a generic list-manipulation function.

> folks type "lst" instead of "list" just to avoid the name clash in a 
> Lisp-1.

I think of 1st, 2nd, 3rd,... as reasonable variable names,
so when I was reading Graham, his use of `lst' caused me
panic. How had he obtained the first element of the list? I
couldn't see a call on CAR anywhere.

Alan Crowe
From: Pascal Bourguignon
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <87fz2tdn73.fsf@thalassa.informatimago.com>
Cameron MacKinnon <··········@clearspot.net> writes:
> These phrases have all been collected together precisely because they
> are bad, in the sense that they're either superficially ambiguous or
> ungrammatical split infinitives.
> 
> They were all created to entice people to read the articles they
> headlined, and the choice was between a clear phrase at 24pt. and an
> ambiguous parse at 36pt. That's advertising for you.
> 
> 
> Consider instead a mathematician who begins a presentation with "Let x
> denote a number in the set of odd natural numbers. Now we also have a
> function x which determines whether its argument is prime. Don't
> worry; you'll always know whether I'm referring to the function or the
> number from its context..."  His peers would think him deliberately
> obtuse.
> 
> 
> If one aspires to write code as elegant, in its own way, as the most
> beautiful mathematics or the finest literature, one will avoid puns,
> which are, after all, a low form of humour.

Well, I feel that on the contrary, puns explicit something that's
fundamuntal and deep in our brains: the general inter-relationship of
everything. A symptom of the K-lines if you will.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
The world will now reboot; don't bother saving your artefacts.
From: Coby Beck
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <YVJqd.11958$cE3.10990@clgrps12>
"Cameron MacKinnon" <··········@clearspot.net> wrote in message 
···························@golden.net...
> Nearly every human language (computer programming languages included) has 
> extra features of punctuation, capitalization and spelling variation to 
> disambiguate nouns from verbs and add type annotations. With more visual 
> cues, parsing is quick, accurate and context insensitive.

I think this is just plain incorrect.  I don't know of any computer 
languages that have restrictions on variable names due to their type.  I 
don't know many languages, but they all have identically spelled words that 
can be a noun or a verb, disambiguated only by context.  English has tons, 
and in fact most nouns can become verbs simply by using them as one.

The original reply is very good advice, this has been hashed and rehashed 
and there are many thoughtful posts on both sides of the OP's issue.

> Lisp programmers seem to take a perverse pleasure in removing all 
> extraneous annotations - Punctuation and capitalization are avoided, and

Factually correct (re punctuation and capitalization) but a very cynical and 
AFAICT incorrect characterization.

>  function names are deliberately recycled, partially to differentiate Lisp 
> coding style from Scheme's.

Again, a very subjective assertion, and one I doubt you have real data to 
support.

> Thus the reader of Lisp code must implement his very own little code 
> walker in neurons, annotating each symbol with 'variable' or 'function', 
> and taking into account Lisp's special forms.

Now regardless of your style preference, which you have every right to chose 
on your own, I just can not believe that anyone without prejudice really has 
that much trouble internalizing the fundamental difference in CL between the 
first element of a list and the rest.  Aside from that there are a handful 
of operators that require functions in certain positions, if you use them 
you should be able to read them easily.

> Seasoned Lispers invariably report that the disambiguation becomes 
> automatic. From this we can infer that either a) anyone can quickly grow 
> their own neural Lisp-2 parser, or b) those that can't don't get far in 
> the Lisp world.

Both true.  But aren't the rules trivial?  Again your preference is your 
right, but do not try to claim it is hard.

> I believe that, even though disambiguation becomes subconscious, it is 
> likely that coders' performance when impaired (sleep deprived, intoxicants 
> etc.) suffers more disambiguating list from list than $x from %x.

Is there such a language that requires function identifiers to be preceeded 
by one char and variable identifiers another?

> It just stands to reason that tasks requiring more context require more 
> brainpower at a higher level.
>
>
> Luckily, implementing these code walkers in Lisp is easy, which presents
> two opportunities: You can write a rewrite function that renames variables 
> that clash with function names

Why do function names have priority? (just curious)

> Either of those will be a lot more productive than trying to change 
> others' opinions on the topic - Lisp punners will continue to write and 
> post code that puns with impunity, and to mock code that avoids punning as 
> too Scheme-ish.

I don't see very much mocking, do you?  It is often a good indication of a 
scheme background which helps to understand what may be troubling an 
inquiring newbie (like seeing a DEFUN inside a DEFUN).  As KMP always points 
out in these types of discussions, languages are communities as well as 
specifications and it is a service to a newbie to direct them towards those 
coding styles widely accepted and easily understood.

You also wrote in another post:

> Consider instead a mathematician who begins a presentation with "Let x 
> denote a number in the set of odd natural numbers. Now we also have a 
> function x which determines whether its argument is prime. Don't worry; 
> you'll always know whether I'm referring to the function or the number 
> from its context..."  His peers would think him deliberately obtuse.

This is a straw man argument because the real mistake is naming either thing 
'x'.  Replace 'x' with everyone's favorite example, 'list' and we are back 
to the reality of our own lisp-1 vs lisp-2 situation: some will like it, 
some won't, no one will have real difficulty understanding, a few will 
attribute malice to an innocent style choice and a few will take pleasure in 
others displeasure.

-- 
Coby Beck
(remove #\Space "coby 101 @ big pond . com")
From: Barry Margolin
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <barmar-6EE837.15471329112004@comcast.dca.giganews.com>
In article <·····················@clgrps12>,
 "Coby Beck" <·····@mercury.bc.ca> wrote:

> "Cameron MacKinnon" <··········@clearspot.net> wrote in message 
> ···························@golden.net...
> > Nearly every human language (computer programming languages included) has 
> > extra features of punctuation, capitalization and spelling variation to 
> > disambiguate nouns from verbs and add type annotations. With more visual 
> > cues, parsing is quick, accurate and context insensitive.
> 
> I think this is just plain incorrect.  I don't know of any computer 
> languages that have restrictions on variable names due to their type.

Apparently you forget the original FORTRAN, where the first letter of a 
variable name indicated its type -- if it started with I through N (I 
think) it was integer, otherwise it was real.  Explicit variable type 
declarations were a later addition (Fortran II or Fortran 90, maybe).

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
From: Christopher C. Stacy
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <u653oti1e.fsf@news.dtpq.com>
Barry Margolin <······@alum.mit.edu> writes:

> In article <·····················@clgrps12>,
>  "Coby Beck" <·····@mercury.bc.ca> wrote:
> 
> > "Cameron MacKinnon" <··········@clearspot.net> wrote in message 
> > ···························@golden.net...
> > > Nearly every human language (computer programming languages included) has 
> > > extra features of punctuation, capitalization and spelling variation to 
> > > disambiguate nouns from verbs and add type annotations. With more visual 
> > > cues, parsing is quick, accurate and context insensitive.
> > 
> > I think this is just plain incorrect.  I don't know of any computer 
> > languages that have restrictions on variable names due to their type.
> 
> Apparently you forget the original FORTRAN, where the first letter of a 
> variable name indicated its type -- if it started with I through N (I 
> think) it was integer, otherwise it was real.  Explicit variable type 
> declarations were a later addition (Fortran II or Fortran 90, maybe).

Yes, God is REAL.
Unless declared INTEGER.
From: Peter Seibel
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <m3llcka4be.fsf@javamonkey.com>
"Coby Beck" <·····@mercury.bc.ca> writes:

>> I believe that, even though disambiguation becomes subconscious, it is 
>> likely that coders' performance when impaired (sleep deprived, intoxicants 
>> etc.) suffers more disambiguating list from list than $x from %x.
>
> Is there such a language that requires function identifiers to be preceeded 
> by one char and variable identifiers another?

Perl. (Though function names are typically not marked while all other
variables are.) That's presumably where Perl gets its reputation as
programmable line-noise. Plus some built in variables that also have
one-character, non-alphanumeric-names, e.g. $_, @_, $/, etc.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Coby Beck
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <dU4rd.22604$VL6.2286@clgrps13>
"Peter Seibel" <·····@javamonkey.com> wrote in message 
···················@javamonkey.com...
> "Coby Beck" <·····@mercury.bc.ca> writes:
>>
>> Is there such a language that requires function identifiers to be 
>> preceeded
>> by one char and variable identifiers another?
>
> Perl. (Though function names are typically not marked while all other
> variables are.) That's presumably where Perl gets its reputation as
> programmable line-noise. Plus some built in variables that also have
> one-character, non-alphanumeric-names, e.g. $_, @_, $/, etc.

Thanks for the remedial education, Peter.  I guess this another example 
where ignorance really can be bliss!

-- 
Coby Beck
(remove #\Space "coby 101 @ big pond . com")
From: Thomas A. Russ
Subject: Re: using function names as variable names? Is it Justified?
Date: 
Message-ID: <ymifz2p7rj8.fsf@sevak.isi.edu>
Cameron MacKinnon <··········@clearspot.net> writes:

> Seasoned Lispers invariably report that the disambiguation becomes 
> automatic. From this we can infer that either a) anyone can quickly grow 
> their own neural Lisp-2 parser, or b) those that can't don't get far in 
> the Lisp world.

I'll choose a).

Basic rule:  The only place that function names can appear 
and be treated as functions is immediately following an
open parenthesis.

that makes 

  (list list a b c)
   ^^^^ ^^^^^^^^^^
   Func value ...

easy to parse.

I can't offhand think of any other standard places where a symbol is
interpreted as a function rather than a value, although perhaps symbol
macros may change that.  There are some macros or special forms which
don't evaluate arguments and for which this parsing rule doesn't apply,
for example DEFUN, WITH-OPEN-FILE, etc.

-- 
Thomas A. Russ,  USC/Information Sciences Institute