From: Miss Elaine Eos
Subject: N00b question on let
Date: 
Message-ID: <Misc-EE3714.09022726112006@coml.de>
Fist, is this the appropriate group for lisp noob questions?  If not, 
please redirect me to the appropriate forum.  As background, I'm a 30+ 
developer with strong C/C++ & Java skills (among others), learning lisp 
as my 1st functional language (I think I took a stab at it ~20 yrs ago 
and bailed after a week), following along in Paul Graham's _Ansi Common 
Lisp_

Ok, my question:

What is the purpose of the 2nd level of parentheses around the variable 
and its assignment?

For example:

(defun foo()
   (let ((val 12))
      val))

compiles & executes just like I'd expect, but

(defun foo()
   (let (val 12)
      val))

Gives
> Error in process listener(1): While compiling FOO :
>                               12 is not a symbol.

Ok, so I understand the rule that you have to have that extra layer of 
parens -- but what is the meta-reason?  What is their actual function?  
Are there exceptions when I would NOT need them?  Are there special 
cases where I'd need TWO extra layers?  Etc.

Thanks!

-- 
Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.

From: DanM
Subject: Re: N00b question on let
Date: 
Message-ID: <1164562523.668878.20150@l39g2000cwd.googlegroups.com>
Miss Elaine Eos wrote:
> Fist, is this the appropriate group for lisp noob questions?

Such questions are perfectly appropriate here.

> What is the purpose of the 2nd level of parentheses around the variable
> and its assignment?

Short answer: Because that's what the spec says.
http://www.lisp.org/HyperSpec/Body/speope_letcm_letst.html#let

Longer answer: Because you can bind multiple symbols in a single LET
form, and the init-form for each symbol is optional.

(let ((a 1) (b 2) c)
  ...)

The list starting after the LET symbol encompasses the entire list of
bindings, setting it off from the expressions of the body. In this
example, c has no init-form, and so is bound to NIL.

>
> (defun foo()
>    (let (val 12)
>       val))
>
> Gives
> > Error in process listener(1): While compiling FOO :
> >                               12 is not a symbol.
>

This would be interpreted as binding VAL to NIL, and then binding 12 to
NIL -- but you can't bind a value, only a symbol, so this is invalid.
From: jkc
Subject: Re: N00b question on let
Date: 
Message-ID: <pan.2006.11.26.17.36.04.959343@makewavs.com>
On Sun, 26 Nov 2006 09:02:27 -0800, Miss Elaine Eos wrote:

> 
> Fist, is this the appropriate group for lisp noob questions?  If not, 
> please redirect me to the appropriate forum.  As background, I'm a 30+ 
> developer with strong C/C++ & Java skills (among others), learning lisp 
> as my 1st functional language (I think I took a stab at it ~20 yrs ago 
> and bailed after a week), following along in Paul Graham's _Ansi Common 
> Lisp_
> 
> Ok, my question:
> 
> What is the purpose of the 2nd level of parentheses around the variable 
> and its assignment?
> 

Its so you can bind multiple symbols at once:

(let ((a "value")
      (b 12)
      (c (somefunction)))
  (print a)
  (print b)
  (print c))

--Jeff
From: Pascal Bourguignon
Subject: Re: N00b question on let
Date: 
Message-ID: <87k61ids4a.fsf@thalassa.informatimago.com>
Miss Elaine Eos <····@*your-pants*PlayNaked.com> writes:

> Fist, is this the appropriate group for lisp noob questions?  If not, 
> please redirect me to the appropriate forum.  

Yes, it's ok.

> As background, I'm a 30+ 
> developer with strong C/C++ & Java skills (among others), learning lisp 
> as my 1st functional language (I think I took a stab at it ~20 yrs ago 
> and bailed after a week), following along in Paul Graham's _Ansi Common 
> Lisp_
>
> Ok, my question:
>
> What is the purpose of the 2nd level of parentheses around the variable 
> and its assignment?

First, it's not an "assignment".  It's a _binding_.  Just naming a
subexpression.  The compiler might even not allocate any space and no
modify any explicit memory cell (eg. it could just substitute the
expression where it's used, if it was used only once).


> For example:
>
> (defun foo()
>    (let ((val 12))
>       val))
>
> compiles & executes just like I'd expect, but
>
> (defun foo()
>    (let (val 12)
>       val))
>
> Gives
>> Error in process listener(1): While compiling FOO :
>>                               12 is not a symbol.
>
> Ok, so I understand the rule that you have to have that extra layer of 
> parens -- but what is the meta-reason?  What is their actual function?  
> Are there exceptions when I would NOT need them?  Are there special 
> cases where I'd need TWO extra layers?  Etc.

LET expects a LIST of bindings.

   (LET (binding binding binding ...) expression expression expression ...)


Each binding can be either:

- a simple symbol, naming a variable that will be bound initially to NIL, or

- a list containing a  simple symbol, naming a variable  followed by an expression,
  which is evaluated and whose result is bound to the variable.


   (LET (variable
         (variable expression) 
         variable
         (variable expression)
         ...) 
     expression
     ...)


So, you can define variables (and have them bound to NIL with:

 (let (var1 var2 var3)
   (setf var1 1
         var2 2
         var3 3)
   (list var1 var2 var3))


Or you can have LET bind them to some expression:

 (let ((var1 1) (var2 2) (var3 3))
   (list var1 var2 var3))


Read closely the "Syntax:" section of the specification:

  http://www.lispworks.com/documentation/HyperSpec/Body/s_let_l.htm#let




Of course, if you have only one variable to bind, this may look too verbose:

 (let ((var 1))
    (list var))


If you write a lot of such one-variable LET, you could invent a new
control structure:

  (LET1 var expression
     body...)


 (defmacro let1 (var expression &body body)
     `(let ((,var ,expression)) ,@body))

  (let1 a 1 (list a))

But this LET1 has the same problem as we get in C, where the syntax of
if, while, for, do expect one statement; when you want to add more
statements in the branches or loop bodies, you have to _add_
parentheses.  Here with LET1, if you want to bind additionnal
variables, you need to change the operator and _add_ parentheses.


Imagine the work to go from:

  (let1 a 1 (list a))

to:

  (let ((a 1) (b 2)) (list a b))


Compared to the work to go from:

  (let ((a 1)) (list a))

to:

  (let ((a 1) (b 2)) (list a b))


Finally have a look at:
http://groups.google.com/group/comp.lang.lisp/msg/3050088218d355e5

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"Specifications are for the weak and timid!"
From: Miss Elaine Eos
Subject: Re: N00b question on let
Date: 
Message-ID: <Misc-BE4AFB.09574526112006@coml.de>
In article <··············@thalassa.informatimago.com>,
 Pascal Bourguignon <···@informatimago.com> wrote:

> First, it's not an "assignment".  It's a _binding_.

Ah, I'm afraid I'm not advanced enough in my lisp to understand the 
difference.  I'm sure that'll come, soon.

So, my understanding is that it's:

   (let (set of var/bindings))

and a var/binding can look like:

   var
or
   (var binding)

Which is why, in a single var-binding pair, there LOOKS to be an "extra 
set" of parens, but it's really:

   (let
      (     ; set of var/bindings follows
         (v1 b1)
            ; optional: (v2 b2) (v3 b3)...
      )     ; end of var/bindings
            ; optional, but it's silly not to have them...
            ; expressions go here.
   )        ; end of "let-expression" (it probably has a better name)

Right?

-- 
Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.
From: ········@tochka.ru
Subject: Re: N00b question on let
Date: 
Message-ID: <1164599259.109613.125260@l39g2000cwd.googlegroups.com>
Miss Elaine Eos wrote:
> In article <··············@thalassa.informatimago.com>,
>  Pascal Bourguignon <···@informatimago.com> wrote:
>
> > First, it's not an "assignment".  It's a _binding_.
>
> Ah, I'm afraid I'm not advanced enough in my lisp to understand the
> difference.

Assignment changes the value of an existing variable; binding creates a
new variable
[and assigns an initial value to it]. Compare to C:

(let ((x 1)) ...) <=> { int x=1; ... }
(setq x 1) <=> x=1;

The difference is that in Lisp variable creation is combined with an
assignment,
while in C it is combined with a type description.
From: Harald Hanche-Olsen
Subject: Re: N00b question on let
Date: 
Message-ID: <pcoirh23tp7.fsf@shuttle.math.ntnu.no>
+ Miss Elaine Eos <····@*your-pants*PlayNaked.com>:

| In article <··············@thalassa.informatimago.com>,
|  Pascal Bourguignon <···@informatimago.com> wrote:
|
|> First, it's not an "assignment".  It's a _binding_.
|
| Ah, I'm afraid I'm not advanced enough in my lisp to understand the
| difference.  I'm sure that'll come, soon.

A binding assigns a meaning to a variable name.  You may think of it
as a memory location, where values can be stored.  There may be many
bindings for a variable name simultaneously, but only one is visible
at any point in the program.  Example:

cl-user> (let ((a 5))
	   (flet ((outer-a () a))
	     (let ((a 42))
	       (list a (outer-a)))))
(42 5)

You may not know flet yet, but it declares a local function (outer-a
in this case) which simply returns the value of a, according to that
functions view of the world.  Inside, I create another binding for a
and gives it a separate value.  When I evaluate a in the inner part,
the inner binding is visible, so the result is 5.  But when I call
outer-a, that function can only see the outer binding for a, so it
returns the corresponding value.  As you can see, that value has not
been changed by the inner binding.

(You seem to have got the reason for the "extra" parentheses in a let
form right.)

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
  when there is no ground whatsoever for supposing it is true.
  -- Bertrand Russell
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <xorah.1724$tp6.1377@newsfe10.lga>
Miss Elaine Eos wrote:
> In article <··············@thalassa.informatimago.com>,
>  Pascal Bourguignon <···@informatimago.com> wrote:
> 
> 
>>First, it's not an "assignment".  It's a _binding_.
> 
> 
> Ah, I'm afraid I'm not advanced enough in my lisp to understand the 
> difference.  I'm sure that'll come, soon.
> 
> So, my understanding is that it's:
> 
>    (let (set of var/bindings))
> 
> and a var/binding can look like:
> 
>    var
> or
>    (var binding)
> 
> Which is why, in a single var-binding pair, there LOOKS to be an "extra 
> set" of parens, but it's really:
> 
>    (let
>       (     ; set of var/bindings follows
>          (v1 b1)
>             ; optional: (v2 b2) (v3 b3)...
>       )     ; end of var/bindings
>             ; optional, but it's silly not to have them...
>             ; expressions go here.
>    )        ; end of "let-expression" (it probably has a better name)
> 
> Right?
> 

Yeah, but this crowd gets downright ugly if you put parens on their own 
line, let alone name them "end-let" or anything else (it is the editor's 
job to blink the match and, if that is off-screen, ideally indicate in a 
status line the opening bit of the form closed by a closing parens), so:

    (let ((v1 b1)
          (v2 b2))
       <yada-yada>)

kt


-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Miss Elaine Eos
Subject: Re: N00b question on let
Date: 
Message-ID: <Misc-5E759A.19244726112006@coml.de>
In article <···················@newsfe10.lga>,
 Ken Tilton <·········@gmail.com> wrote:

> > Which is why, in a single var-binding pair, there LOOKS to be an "extra 
> > set" of parens, but it's really:
> > 
> >    (let
> >       (     ; set of var/bindings follows
> >          (v1 b1)
> >             ; optional: (v2 b2) (v3 b3)...
> >       )     ; end of var/bindings
> >             ; optional, but it's silly not to have them...
> >             ; expressions go here.
> >    )        ; end of "let-expression" (it probably has a better name)
> > 
> > Right?

> Yeah, but this crowd gets downright ugly if you put parens on their own 
> line, let alone name them "end-let" or anything else (it is the editor's 

Oh, sure -- I'd never code Lisp like that, I just did it to 
"graphically" show what I understood to be going on.

I think the only non-standard thing I still do with parens is to try to 
close all the "code" on its own line, and all the "close everything 
else" on a separate line.  I'll probably go to hell for it, but my old 
"what if you want to add something, later" habits are showing through, 
there.

In C, this is why it's important to use { } on if statements, even if 
what follows is only 1 line -- because if you add something later, and 
forget to add the { }, you can totally hose yourself.  In my lisp 
programs, this ends up looking like this:

(defun our-member (obj lst)
   (if (null lst)
      nil
      (if (eql (car lst) obj)
         lst
         (our-member obj (cdr lst))
      )))

Whereas I understand that "normal" lisp indentation would look like this:

(defun our-member (obj lst)
   (if (null lst)
      nil
      (if (eql (car lst) obj)
         lst
         (our-member obj (cdr lst)))))

Maybe I'll only have to go to purgatory -- doesn't seem to terrible to 
me <G>.

Another n00b question coming up in just a sec...

-- 
Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.
From: Zach Beane
Subject: Re: N00b question on let
Date: 
Message-ID: <m3zmadd03p.fsf@unnamed.xach.com>
Miss Elaine Eos <····@*your-pants*PlayNaked.com> writes:

> Maybe I'll only have to go to purgatory -- doesn't seem to terrible to 
> me <G>.

You'll just have trouble convincing people to read your code and help
you with it.

A nice editor will let you advance to the right point in the )))) list
for adding new lines to the right forms. Take advantage of that and
use it to allow yourself to write code with conventional
formatting. People who want to help you will thank you for it.

Zach
From: Miss Elaine Eos
Subject: Re: N00b question on let
Date: 
Message-ID: <Misc-14947B.20381426112006@coml.de>
In article <··············@unnamed.xach.com>,
 Zach Beane <····@xach.com> wrote:

> A nice editor will let you advance to the right point in the )))) list
> for adding new lines to the right forms. Take advantage of that and
> use it to allow yourself to write code with conventional
> formatting. People who want to help you will thank you for it.

Yeah, ok.  Iv'e been using simple text-editor.  Will get on board with a 
good code editor...

(No, not emacs -- a *GOOD* one! ;)

-- 
Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.
From: Geoff Wozniak
Subject: Re: N00b question on let
Date: 
Message-ID: <1164633436.231912.77040@f16g2000cwb.googlegroups.com>
On Nov 26, 11:38 pm, Miss Elaine Eos <····@*your-pants*PlayNaked.com>
wrote:
>
> (No, not emacs -- a *GOOD* one! ;)
>

I used Emacs for a long time and eventually got annoyed with it.  I
moved away from it for a while and when I started working with Lisp, I
tried to avoid using it.  Long story short, I'm using Emacs with Slime.
 It really is the best combination that I've tried, especially if you
want to use multiple Lisps.

If you restrict your usage of Emacs to working with Lisp via Slime, you
may find it very comfortable.

-- 
Geoff
From: Miss Elaine Eos
Subject: Re: N00b question on let
Date: 
Message-ID: <Misc-6BE165.20433727112006@coml.de>
In article <·······················@f16g2000cwb.googlegroups.com>,
 "Geoff Wozniak" <·············@gmail.com> wrote:

> On Nov 26, 11:38 pm, Miss Elaine Eos <····@*your-pants*PlayNaked.com>
> wrote:
> > (No, not emacs -- a *GOOD* one! ;)

> I used Emacs for a long time and eventually got annoyed with it.

Oh, mostly I was just teasing, as I know emacs is a popular lisp editor.  
Maybe once I'm good at lisp, I'll use it but, for now, it just looks 
arcane & complicated.

Misc "one arcane & complicated new thing at a time...!"

-- 
Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.
From: David Douthitt
Subject: Re: N00b question on let
Date: 
Message-ID: <4585bb0c$0$81356$ae4e5890@news.nationwide.net>
Geoff Wozniak wrote:
> I used Emacs for a long time and eventually got annoyed with it.  I
> moved away from it for a while and when I started working with Lisp, I
> tried to avoid using it.  Long story short, I'm using Emacs with Slime.
>  It really is the best combination that I've tried, especially if you
> want to use multiple Lisps.
> 
> If you restrict your usage of Emacs to working with Lisp via Slime, you
> may find it very comfortable.

If you like vi or vim, and are used to it, try using Emacs and SLIME 
with viper-mode.  It works surprisingly well, and is designed to 
emulate vi as much as possible while leaving Emacs capabilities 
available.  vip-mode is designed to help vi users switch to Emacs; 
it's nice but viper-mode is better....

I agree that the best LISP editing seems to be Emacs+SLIME ...and 
certainly nothing graphical can really match the power of Emacs or vim 
(though BBEdit - for the Mac - could be close).
From: Espen Vestre
Subject: Re: N00b question on let
Date: 
Message-ID: <m1y7pxfj9q.fsf@gazonk.vestre.net>
Miss Elaine Eos <····@*your-pants*PlayNaked.com> writes:

> (No, not emacs -- a *GOOD* one! ;)

There hasn't been any really hardcore lisp editors since SEdit died
almost two decades ago, so I'm afraid you have to stick with something
deliberately resembling emacs...
-- 
  (espen)
From: Harald Hanche-Olsen
Subject: Re: N00b question on let
Date: 
Message-ID: <pcod579tiro.fsf@shuttle.math.ntnu.no>
+ Espen Vestre <·····@vestre.net>:

| Miss Elaine Eos <····@*your-pants*PlayNaked.com> writes:
|
|> (No, not emacs -- a *GOOD* one! ;)
|
| There hasn't been any really hardcore lisp editors since SEdit died
| almost two decades ago, so I'm afraid you have to stick with something
| deliberately resembling emacs...

It is rumoured that vim has a reasonable lisp mode.
But of course, the crowd that likes vim is probably quite a bit
thinner than the one that prefers emacs.
(I use both, but emacs most - and I never tried to use vim for lisp.)

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
  when there is no ground whatsoever for supposing it is true.
  -- Bertrand Russell
From: Rob Warnock
Subject: Re: N00b question on let
Date: 
Message-ID: <GL6dndHQB-2dWvfYnZ2dnUVZ_sednZ2d@speakeasy.net>
Harald Hanche-Olsen  <······@math.ntnu.no> wrote:
+---------------
| It is rumoured that vim has a reasonable lisp mode.
| But of course, the crowd that likes vim is probably quite a bit
| thinner than the one that prefers emacs.
| (I use both, but emacs most - and I never tried to use vim for lisp.)
+---------------

I have made several serious tries over the years to get on-board
with Emacs, all unsucessful.[1]  And while it is true that "vim
has a reasonable lisp mode", I've actually been quite happy with
plain ol' Vi (well, nvi-1.79, the last Bostic release). It has
paren-matched[2] flashing/motion/yanking/deleting/shifting[3],
which is all I need for editing Lisp. But YMMV...


-Rob

[1] Something about too many years using editors (TECO, Bravo, "ed",
    Vi, etc.) with separate "input mode" & "command mode", so most
    editing commands are single-letter keypresses, and also having
    hands that don't "chord" well [on a keyboard -- pianos are fine!].

[2] It also matches {}, [], & <>. For some reason, "vim" doesn't
    want to match <>. Go figure.

[3] I find it useful to ":set shiftwidth=1", whereupon placing the
    cursor on a paren and typing "<%" shifts the entire S-expr left
    one space, while ">%..." shifts the S-expr right 4 spaces, etc.

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Larry Clapp
Subject: Re: N00b question on let
Date: 
Message-ID: <slrnemm3rr.k43.larry@theclapp.ddts.net>
On 2006-11-27, Rob Warnock <····@rpw3.org> wrote:
> Harald Hanche-Olsen  <······@math.ntnu.no> wrote:
> +---------------
>| It is rumoured that vim has a reasonable lisp mode.
>| But of course, the crowd that likes vim is probably quite a bit
>| thinner than the one that prefers emacs.
>| (I use both, but emacs most - and I never tried to use vim for
>| lisp.)
> +---------------
>
> I have made several serious tries over the years to get on-board
> with Emacs, all unsucessful.[1]  And while it is true that "vim has
> a reasonable lisp mode", I've actually been quite happy with plain
> ol' Vi (well, nvi-1.79, the last Bostic release). It has
> paren-matched[2] flashing/motion/yanking/deleting/shifting[3], which
> is all I need for editing Lisp. But YMMV...
>
> -Rob
>
> [1] Something about too many years using editors (TECO, Bravo, "ed",
>     Vi, etc.) with separate "input mode" & "command mode", so most
>     editing commands are single-letter keypresses, and also having
>     hands that don't "chord" well [on a keyboard -- pianos are fine!].
>
> [2] It also matches {}, [], & <>. For some reason, "vim" doesn't
>     want to match <>. Go figure.

Vim will match <> if you tell it to:

:help matchpairs
:set matchpairs+=<:>

see also :help matchit-install

-- L
From: Rob Warnock
Subject: Re: N00b question on let
Date: 
Message-ID: <zO6dnVeS6cR5h_HYnZ2dnUVZ_qidnZ2d@speakeasy.net>
Larry Clapp <·····@theclapp.org> wrote:
+---------------
| Rob Warnock <····@rpw3.org> wrote:
| > [Vi] also matches {}, [], & <>. For some reason, "vim" doesn't
| >     want to match <>. Go figure.
| 
| Vim will match <> if you tell it to:
| :help matchpairs
| :set matchpairs+=<:>
+---------------

Wow, thanks!!! This is great. One less bit of constant frustration.
[I have to use "vim" at work, you see... ;-} ]

You learn something useful every day on c.l.l.


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Miss Elaine Eos
Subject: Re: N00b question on let
Date: 
Message-ID: <Misc-5A51AE.20451727112006@coml.de>
In article <································@speakeasy.net>,
 ····@rpw3.org (Rob Warnock) wrote:

> Harald Hanche-Olsen  <······@math.ntnu.no> wrote:
> +---------------
> | It is rumoured that vim has a reasonable lisp mode.
> | But of course, the crowd that likes vim is probably quite a bit
> | thinner than the one that prefers emacs.
> | (I use both, but emacs most - and I never tried to use vim for lisp.)
> +---------------
> 
> I have made several serious tries over the years to get on-board
> with Emacs, all unsucessful.[1]  And while it is true that "vim
> has a reasonable lisp mode", I've actually been quite happy with
> plain ol' Vi (well, nvi-1.79, the last Bostic release). It has
> paren-matched[2] flashing/motion/yanking/deleting/shifting[3],
> which is all I need for editing Lisp. But YMMV...
> 
> 
> -Rob
> 
> [1] Something about too many years using editors (TECO, Bravo, "ed",
>     Vi, etc.) with separate "input mode" & "command mode", so most
>     editing commands are single-letter keypresses, and also having
>     hands that don't "chord" well [on a keyboard -- pianos are fine!].
> 
> [2] It also matches {}, [], & <>. For some reason, "vim" doesn't
>     want to match <>. Go figure.
> 
> [3] I find it useful to ":set shiftwidth=1", whereupon placing the
>     cursor on a paren and typing "<%" shifts the entire S-expr left
>     one space, while ">%..." shifts the S-expr right 4 spaces, etc.

So, y'all REALLY hate graphical editors (Code Warrior, XCode, BBEDit, et 
al), eh?

No matter -- I'll use the one I like until I'm comfortable enough with 
the language that I feel the need to find a "better" editor for it.

Thanks! :)

-- 
Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.
From: Rob Thorpe
Subject: Re: N00b question on let
Date: 
Message-ID: <1164718041.981947.103170@l39g2000cwd.googlegroups.com>
Miss Elaine Eos wrote:
> In article <································@speakeasy.net>,
>  ····@rpw3.org (Rob Warnock) wrote:
>
> > Harald Hanche-Olsen  <······@math.ntnu.no> wrote:
> > +---------------
> > | It is rumoured that vim has a reasonable lisp mode.
> > | But of course, the crowd that likes vim is probably quite a bit
> > | thinner than the one that prefers emacs.
> > | (I use both, but emacs most - and I never tried to use vim for lisp.)
> > +---------------
> >
> > I have made several serious tries over the years to get on-board
> > with Emacs, all unsucessful.[1]  And while it is true that "vim
> > has a reasonable lisp mode", I've actually been quite happy with
> > plain ol' Vi (well, nvi-1.79, the last Bostic release). It has
> > paren-matched[2] flashing/motion/yanking/deleting/shifting[3],
> > which is all I need for editing Lisp. But YMMV...
> >
> >
> > -Rob
> >
> > [1] Something about too many years using editors (TECO, Bravo, "ed",
> >     Vi, etc.) with separate "input mode" & "command mode", so most
> >     editing commands are single-letter keypresses, and also having
> >     hands that don't "chord" well [on a keyboard -- pianos are fine!].
> >
> > [2] It also matches {}, [], & <>. For some reason, "vim" doesn't
> >     want to match <>. Go figure.
> >
> > [3] I find it useful to ":set shiftwidth=1", whereupon placing the
> >     cursor on a paren and typing "<%" shifts the entire S-expr left
> >     one space, while ">%..." shifts the S-expr right 4 spaces, etc.
>
> So, y'all REALLY hate graphical editors (Code Warrior, XCode, BBEDit, et
> al), eh?
>
> No matter -- I'll use the one I like until I'm comfortable enough with
> the language that I feel the need to find a "better" editor for it.

Well, I use Emacs and many other Lisp people do too.  I consider it a
graphical editor really.  It does work in a console box, but I don't
use it that way, and I don't think many do.

> Please take off your pants or I won't read your e-mail.

That's a great spam blocking system!
From: Rob Warnock
Subject: Re: N00b question on let
Date: 
Message-ID: <zO6dnVaS6cRVhvHYnZ2dnUVZ_qidnZ2d@speakeasy.net>
Miss Elaine Eos  <····@*your-pants*PlayNaked.com> wrote:
+---------------
| ····@rpw3.org (Rob Warnock) wrote:
| > I've actually been quite happy with plain ol' Vi .... It has
| > paren-matched[2] flashing/motion/yanking/deleting/shifting[3],
| > which is all I need for editing Lisp. But YMMV...
...
| So, y'all REALLY hate graphical editors (Code Warrior, XCode,
| BBEDit, et al), eh?
+---------------

What are those? Do they run on FreeBSD? Or Linux?
[I can run Linux binaries under FreeBSD...]


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Harald Hanche-Olsen
Subject: Re: N00b question on let
Date: 
Message-ID: <pcou00jczsq.fsf@shuttle.math.ntnu.no>
+ ····@rpw3.org (Rob Warnock):

| Miss Elaine Eos  <····@*your-pants*PlayNaked.com> wrote:
| +---------------
| | ····@rpw3.org (Rob Warnock) wrote:
| | > I've actually been quite happy with plain ol' Vi .... It has
| | > paren-matched[2] flashing/motion/yanking/deleting/shifting[3],
| | > which is all I need for editing Lisp. But YMMV...
| ...
| | So, y'all REALLY hate graphical editors (Code Warrior, XCode,
| | BBEDit, et al), eh?
| +---------------
|
| What are those? Do they run on FreeBSD? Or Linux?

They sound mac-ish to me.  XCode is the IDE on macosx.  I seem to
remember bbedit from my old Mac days.  I used the free version of it
until I came across alpha, which was actually a quite nice editor.  It
used (and still uses, I see) tcl as its extension language.
Codewarrior is an IDE that runs on several systems including the mac.

http://en.wikipedia.org/wiki/BBEdit
http://en.wikipedia.org/wiki/CodeWarrior

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
  when there is no ground whatsoever for supposing it is true.
  -- Bertrand Russell
From: Harald Hanche-Olsen
Subject: Re: N00b question on let
Date: 
Message-ID: <pco64d0hvio.fsf@shuttle.math.ntnu.no>
+ Miss Elaine Eos <····@*your-pants*PlayNaked.com>:

| So, y'all REALLY hate graphical editors (Code Warrior, XCode,
| BBEDit, et al), eh?

Nah.  Personally, I get along sufficiently well with emacs (and vi or
vim sometimes) that I find looking for other editors a waste of my
time.  There is little enough of it as it is.  But, for that very
reason, I would never look twice at an alternative editor for Lisp
editing if it won't do indenting and paren matching.

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
  when there is no ground whatsoever for supposing it is true.
  -- Bertrand Russell
From: Damien Kick
Subject: The Right Editor for writing let (and other things) (was Re: N00b question on let)
Date: 
Message-ID: <i6Qah.4016$sf5.3469@newsread4.news.pas.earthlink.net>
Espen Vestre wrote:
> Miss Elaine Eos <····@*your-pants*PlayNaked.com> writes:
> 
>> (No, not emacs -- a *GOOD* one! ;)
> 
> There hasn't been any really hardcore lisp editors since SEdit died
> almost two decades ago, so I'm afraid you have to stick with something
> deliberately resembling emacs...

Google helped me find an old Lemonodor blog <http://tinyurl.com/yf5u5g> 
which mentioned a video which shows SEdit in use 
<http://tinyurl.com/yds4rv> but the link seems to have gone stale.  I 
think I found another URL for the same movie 
<http://tinyurl.com/yb5fjl>, though.  A lot of what is shown on this 
video seems to be available in Emacs with paredit, but I've got a 
feeling that I'm probably missing quite a bit of what made (makes?) 
SEdit so cool.

I'm curious about one thing, in particular.  In the video, the user does 
what looks like selecting a restart for defining the undefined TAK 
function and the system starts SEdit.  When he's finished, he closes the 
window and the function has a definition.  If there is anyone familiar 
with that system, did the function definition get saved to a file 
somewhere?  Or did that IDE work more like a Smalltalk, saving such 
things in image(s)?

The integration of SEDit with the listener did look pretty cool, though. 
  I've installed the Personal edition of LispWorks at home.  I haven't 
really done too much with it yet <cough/> but it does seem like the IDE 
is nice.  I know that Edi Weitz has coded some customizations of the IDE 
<http://tinyurl.com/lq7ja>, too, so apparently it is extensible and 
self-documenting.  I did just notice that attempting to call an 
undefined function from the LispWorks listener does present an ":ed" 
restart, but I only get an error "The source of ERROR cannot be 
located".  I'm probably doing something wrong.  Are there no existing 
lisp implementations which have something as powerful as the legend of 
SEdit?  I tend to use SLIME, myself.

I am hoping that Climacs <http://common-lisp.net/project/climacs/> 
starts building steam <pause/> or continues to build steam <pause/> or 
does something steamy, though.  It seems like it would be very powerful 
to have the same meta-circularity of having ones editor of lisp 
implemented in lisp as one finds from having the object system of lisp 
being implemented in lisp.  An Emacs users, I don't want Climacs so that 
I can use CL from my editor (require :cl) but rather so that I can use 
editor from CL.    There is a lot of (or much (or some)) functionality 
in elisp code I wish I had from my CL implementation.  Unfortunately, I 
tried to install Climacs and I haven't yet had much luck with McClim 
<http://tinyurl.com/ybp2hg>.  CLX seems to be working for me, but not 
one of the example applications shipped with McClim.
From: Robert Strandh
Subject: Re: The Right Editor for writing let (and other things) (was Re: N00b question on let)
Date: 
Message-ID: <6wirh0je7d.fsf@serveur5.labri.fr>
Damien Kick <·····@earthlink.net> writes:

> Unfortunately, I tried to install Climacs and I haven't yet had much
> luck with McClim <http://tinyurl.com/ybp2hg>.  CLX seems to be working
> for me, but not one of the example applications shipped with McClim.

I am sure the developers of McCLIM and Climacs would like to hear
about your problems.  May I ask you to send a slightly more detailed
descriptions of them to the respective mailing lists?

-- 
Robert Strandh
From: Tim Bradshaw
Subject: Re: The Right Editor for writing let (and other things) (was Re: N00b   question on let)
Date: 
Message-ID: <ekgoif$2u0$1$830fa17d@news.demon.co.uk>
On 2006-11-28 05:50:06 +0000, Damien Kick <·····@earthlink.net> said:

> Google helped me find an old Lemonodor blog <http://tinyurl.com/yf5u5g> 
> which mentioned a video which shows SEdit in use 
> <http://tinyurl.com/yds4rv> but the link seems to have gone stale.  I 
> think I found another URL for the same movie 
> <http://tinyurl.com/yb5fjl>, though.  A lot of what is shown on this 
> video seems to be available in Emacs with paredit, but I've got a 
> feeling that I'm probably missing quite a bit of what made (makes?) 
> SEdit so cool.

What made it cool was that it wasn't a text editor at all: it was a 
structure editor, so what it's editing was the list structure of the 
definition, directly.  And unlike a previous attempt at this (DEdit?) 
it made this work fairly well.

> 
> I'm curious about one thing, in particular.  In the video, the user 
> does what looks like selecting a restart for defining the undefined TAK 
> function and the system starts SEdit.  When he's finished, he closes 
> the window and the function has a definition.  If there is anyone 
> familiar with that system, did the function definition get saved to a 
> file somewhere?  Or did that IDE work more like a Smalltalk, saving 
> such things in image(s)?

It was a resident system, and you could save images (`sysouts'), but it 
also kept track of definitions, and you could associate them with 
files, which could then be saved.

--tim
From: Espen Vestre
Subject: Re: The Right Editor for writing let (and other things) (was Re: N00b question on let)
Date: 
Message-ID: <m1slg4f1gx.fsf@gazonk.vestre.net>
Damien Kick <·····@earthlink.net> writes:

> <http://tinyurl.com/yb5fjl>, though.  A lot of what is shown on this
> video seems to be available in Emacs with paredit, but I've got a
> feeling that I'm probably missing quite a bit of what made (makes?)
> SEdit so cool.

I haven't used paredit, but it was made to mimic Sedit, wasn't it?

> I'm curious about one thing, in particular.  In the video, the user
> does what looks like selecting a restart for defining the undefined
> TAK function and the system starts SEdit.  When he's finished, he
> closes the window and the function has a definition.  If there is
> anyone familiar with that system, did the function definition get
> saved to a file somewhere?  Or did that IDE work more like a
> Smalltalk, saving such things in image(s)?

AFAIR functions were associated with files, but not flat files.
I think I had to do some kind of export to get flat files that I
could use on other file systems.

> apparently it is extensible and self-documenting.  I did just notice
> that attempting to call an undefined function from the LispWorks
> listener does present an ":ed" restart, but I only get an error "The
> source of ERROR cannot be located".  

That's just because error was the function of the current frame.
Try using :n and :p to move up and down the stack, or use the
bug button to enter the graphical debugger.

> It seems like it would be very powerful to have the same
> meta-circularity of having ones editor of lisp implemented in lisp
> as one finds from having the object system of lisp being implemented
> in lisp.

Indeed. This is quite OK in LispWorks, but I think FRED (of MCL) is
a better example of a Common Lisp-programmable editor.
-- 
  (espen)
From: ······@corporate-world.lisp.de
Subject: Re: The Right Editor for writing let (and other things) (was Re: N00b question on let)
Date: 
Message-ID: <1166396285.974349.93680@80g2000cwy.googlegroups.com>
On 28 Nov., 06:50, Damien Kick <····@earthlink.net> wrote:
> Espen Vestre wrote:
> > Miss Elaine Eos <····@*your-pants*PlayNaked.com> writes:
>
> >> (No, not emacs -- a *GOOD* one! ;)
>
> > There hasn't been any really hardcore lisp editors since SEdit died
> > almost two decades ago, so I'm afraid you have to stick with something
> > deliberately resembling emacs...Google helped me find an old Lemonodor blog <http://tinyurl.com/yf5u5g>
> which mentioned a video which shows SEdit in use
> <http://tinyurl.com/yds4rv> but the link seems to have gone stale.  I
> think I found another URL for the same movie
> <http://tinyurl.com/yb5fjl>, though.  A lot of what is shown on this
> video seems to be available in Emacs with paredit, but I've got a
> feeling that I'm probably missing quite a bit of what made (makes?)
> SEdit so cool.
>
> I'm curious about one thing, in particular.  In the video, the user does
> what looks like selecting a restart for defining the undefined TAK
> function and the system starts SEdit.  When he's finished, he closes the
> window and the function has a definition.  If there is anyone familiar
> with that system, did the function definition get saved to a file
> somewhere?  Or did that IDE work more like a Smalltalk, saving such
> things in image(s)?

InterLisp indeed does have a special way to deal with source.

In LispWorks one would just open up an editor with (ed) and
define the function BAR. Next time calling (ed 'bar) will get you back
to the definition.

>
> The integration of SEDit with the listener did look pretty cool, though.
>   I've installed the Personal edition of LispWorks at home.  I haven't
> really done too much with it yet <cough/> but it does seem like the IDE
> is nice.  I know that Edi Weitz has coded some customizations of the IDE
> <http://tinyurl.com/lq7ja>, too, so apparently it is extensible and
> self-documenting.  I did just notice that attempting to call an
> undefined function from the LispWorks listener does present an ":ed"
> restart, but I only get an error "The source of ERROR cannot be
> located".  I'm probably doing something wrong.  Are there no existing
> lisp implementations which have something as powerful as the legend of
> SEdit?  I tend to use SLIME, myself.

If you have an undefined function, then you get an error.

(defun foo ()
  (bar))

Call:

(foo)

Now you get the error.

Just define bar:

(defun bar () 'baz)

and select the retry call to bar restart in your favorite Lisp.

Here in LispWorks:

CL-USER 1 > (defun foo () (bar))
FOO

CL-USER 2 > (foo)

Error: Undefined operator BAR in form (BAR).
  1 (continue) Try invoking BAR again.
  2 Return some values from the form (BAR).
  3 Try invoking something other than BAR with the same arguments.
  4 Set the symbol-function of BAR to another function.
  5 Set the macro-function of BAR to another function.
  6 (abort) Return to level 0.
  7 Restart top-level loop.

Type :b for backtrace, :c <option number> to proceed,  or :? for other
options

CL-USER 3 : 1 > (defun bar () 'baz)
BAR

CL-USER 4 : 1 > :c 1
BAZ


Another problem could be that BAR was defined with a different arglist:

(defun baz (a) a)

(defun foo (a) (baz))

Now if you put the definitions in a file or editor buffer  and compile
those, LispWorks will remember where it is.

If you call (foo) you get the error and you have multiple ways to look
up the source to BAR.

1) put the cursor on the symbol BAR and press meta-.
2) type (ed 'bar) to the debugger prompt.
3) right-click, expression->find source
...

Now change the implementation of BAR, compile it, return to the
debugger and invoke BAR again.

Done.



>
> I am hoping that Climacs <http://common-lisp.net/project/climacs/>
> starts building steam <pause/> or continues to build steam <pause/> or
> does something steamy, though.  It seems like it would be very powerful
> to have the same meta-circularity of having ones editor of lisp
> implemented in lisp as one finds from having the object system of lisp
> being implemented in lisp.  An Emacs users, I don't want Climacs so that
> I can use CL from my editor (require :cl) but rather so that I can use
> editor from CL.    There is a lot of (or much (or some)) functionality
> in elisp code I wish I had from my CL implementation.  Unfortunately, I
> tried to install Climacs and I haven't yet had much luck with McClim
> <http://tinyurl.com/ybp2hg>.  CLX seems to be working for me, but not
> one of the example applications shipped with McClim.
From: =?iso-8859-1?B?QXNiavhybiBCavhybnN0YWQ=?=
Subject: Re: N00b question on let
Date: 
Message-ID: <1164705711.198277.152590@45g2000cws.googlegroups.com>
On Nov 27, 12:38 pm, Miss Elaine Eos <····@*your-pants*PlayNaked.com>
wrote:
> Yeah, ok.  Iv'e been using simple text-editor.  Will get on board with a
> good code editor...
>
> (No, not emacs -- a *GOOD* one! ;)

I haven't tested this myself as I've been an emacs user since long
before
I started fumbling with lisp, but maybe cusp works for you?
http://www.paragent.com/lisp/cusp/cusp.htm
-- 
  -asbjxrn
From: Pedro Kröger
Subject: Re: N00b question on let
Date: 
Message-ID: <87hcwlwnwx.fsf@gmail.com>
Miss Elaine Eos <····@*your-pants*PlayNaked.com> writes:

> I think the only non-standard thing I still do with parens is to try to 
> close all the "code" on its own line, and all the "close everything 
> else" on a separate line.  I'll probably go to hell for it, but my old 
> "what if you want to add something, later" habits are showing through, 
> there.
>
> In C, this is why it's important to use { } on if statements, even if 
> what follows is only 1 line -- because if you add something later, and 
> forget to add the { }, you can totally hose yourself.  In my lisp 
> programs, this ends up looking like this:

usually a lisp programmer thinks in terms of _expressions_, not parens.
of course we use tools that help that task. I suggest you check Marco
Baringer's video on using slime to develop lisp programs:

http://www.cl-user.net/asp/web-sites/slime-video

you may also want to see this page:

http://www.cliki.net/Editing%20Lisp%20Code%20with%20Emacs

Pedro Kroger
From: Pascal Bourguignon
Subject: Re: N00b question on let
Date: 
Message-ID: <87lklxcyax.fsf@thalassa.informatimago.com>
Miss Elaine Eos <····@*your-pants*PlayNaked.com> writes:
> In my lisp 
> programs, this ends up looking like this:
>
> (defun our-member (obj lst)
>    (if (null lst)
>       nil
>       (if (eql (car lst) obj)
>          lst
>          (our-member obj (cdr lst))
>       )))

This is not too bad.  The more so when you have a ; comment on the
last line:

 (defun our-member (obj lst)
    (if (null lst)
       nil
       (if (eql (car lst) obj)
          lst
          (our-member obj (cdr lst)) ; recursive call ;-)
       )))

If you try to close the parentheses on the same line as the comment,
with the various emacs lisp modes including paredit, when you need to
add a form, the comments follows the last parenthesis instead of being
anchored to the (our-member ...) form.  


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

ATTENTION: Despite any other listing of product contents found
herein, the consumer is advised that, in actuality, this product
consists of 99.9999999999% empty space.
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <VXDah.2$Mg.1@newsfe11.lga>
Miss Elaine Eos wrote:
> In article <···················@newsfe10.lga>,
>  Ken Tilton <·········@gmail.com> wrote:
> 
> 
>>>Which is why, in a single var-binding pair, there LOOKS to be an "extra 
>>>set" of parens, but it's really:
>>>
>>>   (let
>>>      (     ; set of var/bindings follows
>>>         (v1 b1)
>>>            ; optional: (v2 b2) (v3 b3)...
>>>      )     ; end of var/bindings
>>>            ; optional, but it's silly not to have them...
>>>            ; expressions go here.
>>>   )        ; end of "let-expression" (it probably has a better name)
>>>
>>>Right?
> 
> 
>>Yeah, but this crowd gets downright ugly if you put parens on their own 
>>line, let alone name them "end-let" or anything else (it is the editor's 
> 
> 
> Oh, sure -- I'd never code Lisp like that, I just did it to 
> "graphically" show what I understood to be going on.
> 
> I think the only non-standard thing I still do with parens is to try to 
> close all the "code" on its own line, and all the "close everything 
> else" on a separate line.  I'll probably go to hell for it, but my old 
> "what if you want to add something, later" habits are showing through, 
> there.

I do the same, partly for the reason you gave, partly to irritate the 
yobbos in this group. Post some camelCase if you want to see them 
foaming at mouth.

hth, kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Miss Elaine Eos
Subject: Re: N00b question on let
Date: 
Message-ID: <Misc-96C6A8.20423327112006@coml.de>
In article <············@newsfe11.lga>,
 Ken Tilton <·········@gmail.com> wrote:

> Post some camelCase if you want to see them  foaming at mouth.

Oh, bah -- really?!  <sigh> What's the preferred lisp-mechanism?

Oh, wait, I know this one -- it's hypen, right?  As in

   (defun this-is-my-function ...)

vice

   (defun thisIsMyFunciton ...)

right?  Will they really lynch me for that?  I'm going to have trouble 
getting over the fact that "-" is the subtraction operator, dammit!

-- 
Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <SgRah.211$Gs5.115@newsfe10.lga>
Miss Elaine Eos wrote:
> In article <············@newsfe11.lga>,
>  Ken Tilton <·········@gmail.com> wrote:
> 
> 
>>Post some camelCase if you want to see them  foaming at mouth.
> 
> 
> Oh, bah -- really?!  <sigh> What's the preferred lisp-mechanism?
> 
> Oh, wait, I know this one -- it's hypen, right?  As in
> 
>    (defun this-is-my-function ...)
> 
> vice
> 
>    (defun thisIsMyFunciton ...)
> 
> right?  Will they really lynch me for that?

Absolutely, and even if you helpfully point out to them their 
close-minded, lock-step, conformist, xenophobic inflexibility -- do they 
slap their heads and say, Doh! Silly me!? Nope, they defend themselves!

>  I'm going to have trouble 
> getting over the fact that "-" is the subtraction operator, dammit!
> 

Ah, The Operator Lisp Got Wrong:

(- 1  ) -> -1
(- 1 0) ->  1

And here's another:

   (expt -3 2) -> 9

Puh-leeeze.

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Pillsy
Subject: Re: N00b question on let
Date: 
Message-ID: <1164742796.573839.169230@h54g2000cwb.googlegroups.com>
Ken Tilton wrote:
> Miss Elaine Eos wrote:
[...]
> > Oh, wait, I know this one -- it's hypen, right?  As in

> >    (defun this-is-my-function ...)

> > vice

> >    (defun thisIsMyFunciton ...)

> > right?  Will they really lynch me for that?

> Absolutely, and even if you helpfully point out to them their
> close-minded, lock-step, conformist, xenophobic inflexibility -- do they
> slap their heads and say, Doh! Silly me!? Nope, they defend themselves!

Would you mock me if I took the opportunity to mention that, "You can
use hyphens instead of ugly-ass camelCase and under_scores," is one of
my Top Ten reasons for liking Lisp?

> >  I'm going to have trouble
> > getting over the fact that "-" is the subtraction operator, dammit!

> Ah, The Operator Lisp Got Wrong:

> (- 1  ) -> -1
> (- 1 0) ->  1

This is obviously ludicrous...

> And here's another:

>    (expt -3 2) -> 9

> Puh-leeeze.

...but what's the problem with this one? Except that "expt" is kind of
a doofy name?

Cheers,
Pillsy
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <IZ1bh.302$tv6.241@newsfe09.lga>
Pillsy wrote:
> Ken Tilton wrote:
> 
>>Miss Elaine Eos wrote:
> 
> [...]
> 
>>>Oh, wait, I know this one -- it's hypen, right?  As in
> 
> 
>>>   (defun this-is-my-function ...)
> 
> 
>>>vice
> 
> 
>>>   (defun thisIsMyFunciton ...)
> 
> 
>>>right?  Will they really lynch me for that?
> 
> 
>>Absolutely, and even if you helpfully point out to them their
>>close-minded, lock-step, conformist, xenophobic inflexibility -- do they
>>slap their heads and say, Doh! Silly me!? Nope, they defend themselves!
> 
> 
> Would you mock me if I took the opportunity to mention that, "You can
> use hyphens instead of ugly-ass camelCase and under_scores," is one of
> my Top Ten reasons for liking Lisp?

No, I would mock you for being so locked into mob-rule and aggression 
that you think my insistence on walking to a different drummer entails 
also abusing anyone not conforming to my non-conformity.

> 
> 
>>> I'm going to have trouble
>>>getting over the fact that "-" is the subtraction operator, dammit!
> 
> 
>>Ah, The Operator Lisp Got Wrong:
> 
> 
>>(- 1  ) -> -1
>>(- 1 0) ->  1
> 
> 
> This is obviously ludicrous...
> 
> 
>>And here's another:
> 
> 
>>   (expt -3 2) -> 9
> 
> 
>>Puh-leeeze.
> 
> 
> ...but what's the problem with this one? 

A small matter of -3 squared being -9? Exponentiation takes precedence 
over sign. Actually, if this were documented it would make sense, since 
a consequence of exponentiation's higher precedence is that it cannot be 
applied to a signed number and discarding the sign might be a useful 
convenience for EXPT to provide.

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Kaz Kylheku
Subject: Re: N00b question on let
Date: 
Message-ID: <1164751497.574576.174180@14g2000cws.googlegroups.com>
Ken Tilton wrote:
> Pillsy wrote:
> > ...but what's the problem with this one?
>
> A small matter of -3 squared being -9?

``Negative-three, squared, is nine.''

The other meaning must be said like this for clarity:

``The negative of three squared is negative nine.''

> Exponentiation takes precedence  over sign.

That is false. Precedence is a matter of syntactic convention, not
semantics. Exponentiation takes precedence over sign when you design
the syntax that way.

In Lisp here the syntactic convention is that sign is syntactically
part of a token, and so the sign's association with its token takes
precedence over the association between that token and other tokens.

 (expt -3 2)

There is no whitespace between - and 3, so it binds more tightly. The
parsing follows visual intution.
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <kf3bh.19$u36.10@newsfe11.lga>
Kaz Kylheku wrote:

>  (expt -3 2)
> 
> There is no whitespace between - and 3, so it binds more tightly.

Were you able to keep a straight face while writing that? Well, since 
white space is so significant, let's check with the experts on 
whitespace, Python:

-3**2
-9

Nothing less than parentheses (or a broken EXPT) will get the negation 
raised to the intended power. Now go away.

:)

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Kaz Kylheku
Subject: Re: N00b question on let
Date: 
Message-ID: <1164757132.166144.248390@16g2000cwy.googlegroups.com>
Ken Tilton wrote:
> Kaz Kylheku wrote:
>
> >  (expt -3 2)
> >
> > There is no whitespace between - and 3, so it binds more tightly.
>
> Were you able to keep a straight face while writing that? Well, since
> white space is so significant,

Of course it is significant. We depend on it, for instance, to
understand WHITESPACE to be a single symbol, and WHITE SPACE to be two
symbols.

> let's check with the experts on
> whitespace, Python:

Those idjits make the amount of whitespace significant, rather than
merely its presence and absence.

> -3**2
> -9

Note that ** isn't  standard mathematical notation. It's
``computerese''. As such, it can do whatever you want it to do in a
given language. In C, it means dereference 2 and then multiply it by 3.
Of course, 2 isn't a pointer, so a diagnostic is required.

I would suggest the reading ``minus three star star nine'' for the
above, lest anyone become confused.

In math, it is:

  2
-3

which is ``minus three superscript two''. As in, perhaps it's better
not to read it out loud, to avoid risking the ambiguities that are
introduced in the English.

In that language, you can make yourself clear with the help of, well,
pauses: the spoken equivalent of whitespace! Negative ...
three-squared, or negative three .... squared.

I'd use the former reading for

  2
-3

and the latter for

    2
(-3)
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <2L4bh.195$3k4.156@newsfe10.lga>
Kaz Kylheku wrote:

> In math, it is:
> 
>   2
> -3
> 
> which is ``minus three superscript two''. As in, perhaps it's better
> not to read it out loud, to avoid risking the ambiguities that are
> introduced in the English.
> 
> In that language, you can make yourself clear with the help of, well,
> pauses: the spoken equivalent of whitespace! Negative ...
> three-squared, or negative three .... squared.

Spot on, though I think we need to be a little clearer:

    negative... threesquared

Fine, and now that we are standardizing on whitespace, howsabout:

   (expt -3 2) -> -9
   (expt -3    2) -> 9

? And by your other infatuation, consistency, we have:

   (expt -3) -> (expt 1 -3) -> 1/1^3 -> 1

I like it!

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Kaz Kylheku
Subject: Re: N00b question on let
Date: 
Message-ID: <1164767284.489914.194740@j44g2000cwa.googlegroups.com>
Ken Tilton wrote:
> Kaz Kylheku wrote:
>
> > In math, it is:
> >
> >   2
> > -3
> >
> > which is ``minus three superscript two''. As in, perhaps it's better
> > not to read it out loud, to avoid risking the ambiguities that are
> > introduced in the English.
> >
> > In that language, you can make yourself clear with the help of, well,
> > pauses: the spoken equivalent of whitespace! Negative ...
> > three-squared, or negative three .... squared.
>
> Spot on, though I think we need to be a little clearer:
>
>     negative... threesquared

The only problem with this pause after negative and before
three-squared is that it's only borderline grammatical. Though not
incomprehensible, it jars the ear of an English speaker.

> Fine, and now that we are standardizing on whitespace, howsabout:
>
>    (expt -3 2) -> -9
>    (expt -3    2) -> 9

No thanks. All whitespace should reduce to a single space for the
purposes of terminating a token.

> ? And by your other infatuation, consistency, we have:
>
>    (expt -3) -> (expt 1 -3) -> 1/1^3 -> 1
>
> I like it!

Nah. Here we should refine the rule and default the base with something
other than the identity value from the exponent.  That aspect of the
rule needs to be refined. Now the problem with using a default base of
1 is that it's obviously useless---notwithstanding that you like it.

(expt x) might perhaps be (expt e x), where e is the base of the
natural logarithms.

I hope you like this better.

The consistency rule is not that you take the identity element into the
left operand, but rather a ``cool'' value which may or may not be the
identity element, by coincidence.

The reason (/ x) is (/ 1 x) isn't at all that 1 is the division
identity element; I was very mistaken in that observation. It's rather
that it's a useful default value to use as the numerator. 1 is an
identity element in division only in its role as the divisor. In
exponentiation, using the identity exponent as the default base bears
no fruit.
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <8J6bh.388$tv6.290@newsfe09.lga>
Kaz Kylheku wrote:

> The reason (/ x) is (/ 1 x) isn't at all that 1 is the division
> identity element; I was very mistaken in that observation. It's rather
> that it's a useful default value to use as the numerator.

Nonsense. The zero key is much easier to hit. But I do like e, it seems 
so much more natural.

kenny

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: John Thingstad
Subject: Re: N00b question on let
Date: 
Message-ID: <op.tjq3k2gjpqzri1@pandora.upc.no>
On Wed, 29 Nov 2006 00:38:52 +0100, Kaz Kylheku <········@gmail.com> wrote:

> In math, it is:
>
>   2
> -3
>

NO!

    2
-3   = -9

also in math

     2
(-3)  = 9

(You could try it in mathematica say)

That being said. To me this is just a advantage of Lisp.
In lisp (expt -3 2) always means (-3)^2 and (- (expt 3 2))
always -3^2 so it is easy to see the difference.
You are probably not the first to make that mistake.

He is wrong that it is semantically significant and that
Lisp is wrong. It is just a syntactic convention.
There is no reason prefix syntax should follow infix syntax rules.
Lisp is complete and consistent. That is the necessary requirement.

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: Wolfram Fenske
Subject: Re: N00b question on let
Date: 
Message-ID: <1164759653.198045.64490@l39g2000cwd.googlegroups.com>
Ken Tilton <·········@gmail.com> writes:

> Kaz Kylheku wrote:
>
>>  (expt -3 2)
>> There is no whitespace between - and 3, so it binds more tightly.
>
> Were you able to keep a straight face while writing that? Well,
> since white space is so significant,

You may not believe that whitespace separates your tokens (i. e. your
symbols, strings, positive integers, *negative* integers, ...), but
maybe you believe this:

--8<---------------cut here---------------start------------->8---
[1]> (list (quote expt) (quote -3) (quote 2))
(EXPT -3 2)
[2]> (eval (list (quote expt) (quote -3) (quote 2)))
9
[3]> (equal (list (quote expt) (quote -3) (quote 2)) (quote (expt -3
2)))
T
[4]>
--8<---------------cut here---------------end--------------->8---

> let's check with the experts on whitespace, Python:
>
> -3**2
> -9

I see three possibilities:

  a) you're having a joke, and nobody gets it,
  b) you have a seriously warped understanding of what `expr' should
     do, [1]
  c) the real Kenny has been abducted by aliens and you, his
     replacement, hasn't grokked prefix notation yet.

At this point, I believe c) to be the most likely one.  So let me
explain it to you, my extraterrestrial friend: (expt -3 2) is not
equivalent to the Python expression -3**2 but to (-3)**2 since in the
Lisp expression, "-3" is a single token (and hence becomes a single
expression (which evaluates to -3)).  Python's -3**2 would be
equivalent to (- (expt 3 2)) [2].


Footnotes:
[1]  I suspect you want (let ((a -3)) (expt a 2)) to equal -9, too?

[2]  or (- 0 (expt 3 2)), since you don't like (- 1) being -1, either.

--
Wolfram Fenske

A: Yes.
>Q: Are you sure?
>>A: Because it reverses the logical flow of conversation.
>>>Q: Why is top posting frowned upon?
From: Ken Tilton
Subject: Opinions on PGs Prolog [was Re: N00b question on let]
Date: 
Message-ID: <e55bh.30$u36.26@newsfe11.lga>
Wolfram Fenske wrote:
> Ken Tilton <·········@gmail.com> writes:
> 
> 
>>Kaz Kylheku wrote:
>>
>>
>>> (expt -3 2)
>>>There is no whitespace between - and 3, so it binds more tightly.
>>
>>Were you able to keep a straight face while writing that? Well,
>>since white space is so significant,
> 
> 
> You may not believe that whitespace separates your tokens (i. e. your
> symbols, strings, positive integers, *negative* integers, ...), but
> maybe you believe this:
> 
> --8<---------------cut here---------------start------------->8---
> [1]> (list (quote expt) (quote -3) (quote 2))
> (EXPT -3 2)
> [2]> (eval (list (quote expt) (quote -3) (quote 2)))
> 9
> [3]> (equal (list (quote expt) (quote -3) (quote 2)) (quote (expt -3
> 2)))
> T
> [4]>
> --8<---------------cut here---------------end--------------->8---
> 
> 
>>let's check with the experts on whitespace, Python:
>>
>>-3**2
>>-9
> 
> 
> I see three possibilities:
> 
>   a) you're having a joke, and nobody gets it,
>   b) you have a seriously warped understanding of what `expr' should
>      do, [1]
>   c) the real Kenny has been abducted by aliens and you, his
>      replacement, hasn't grokked prefix notation yet.

d) OpenGL is kicking my ass again, this time over transparent regions of 
textures derived from gifs

e) My problem cloner/randomizer is turning into an exercise in prologian 
unification

...and in either case I would rather hide out here trolling c.l.l. than 
work on these problems.


> 
> At this point, I believe c) to be the most likely one.

Wrong. (e) GIFs dance to my tune now, thank you very much.

Speaking of which, what do you all think, is PGs Prolog in On Lisp 
industrial strength? It would be so cool to ship an app with that in 
there. Or should I keep looking for that beautiful volume called 
Warren's Abstract machine? There is no way that got thrown out, and I 
have always wanted to build one.

> [1]  I suspect you want (let ((a -3)) (expt a 2)) to equal -9, too?

prithee, what would the difference be between (expt -3 2) and (expt a 2) 
with a bound to -3?

I think you are the one needing a star-system check. Open the pod bay 
doors, Hal.

kenny

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Bill Atkins
Subject: Re: Opinions on PGs Prolog [was Re: N00b question on let]
Date: 
Message-ID: <m23b836nxy.fsf@bertrand.local>
Ken Tilton <·········@gmail.com> writes:

> Speaking of which, what do you all think, is PGs Prolog in On Lisp
> industrial strength? It would be so cool to ship an app with that in
> there. Or should I keep looking for that beautiful volume called
> Warren's Abstract machine? There is no way that got thrown out, and I
> have always wanted to build one.

Peter Norvig's Prolog implementation in PAIP is probably
industrial-strength.  IIRC, The Prolog that Franz ships is based on
Norvig's Prolog code.
From: John Thingstad
Subject: Re: Opinions on PGs Prolog [was Re: N00b question on let]
Date: 
Message-ID: <op.tjrdxsmmpqzri1@pandora.upc.no>
On Wed, 29 Nov 2006 02:28:41 +0100, Bill Atkins <······@rpi.edu> wrote:

> Ken Tilton <·········@gmail.com> writes:
>
>> Speaking of which, what do you all think, is PGs Prolog in On Lisp
>> industrial strength? It would be so cool to ship an app with that in
>> there. Or should I keep looking for that beautiful volume called
>> Warren's Abstract machine? There is no way that got thrown out, and I
>> have always wanted to build one.
>
> Peter Norvig's Prolog implementation in PAIP is probably
> industrial-strength.  IIRC, The Prolog that Franz ships is based on
> Norvig's Prolog code.

Naw it is fairly basic.
It also contains errors. I remeber sending inn a correction where it
handles kvantors incorrectly. You need to reduce the kvantors to
preneks normal form before Skolhemization. Otherwise kvantor variables are  
subject
to variable name capture. This had not been done.
Franz has as I understand improved on the basic implementation mostly by
improving the speed. Can't say I have tried it..

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: Ken Tilton
Subject: Re: Opinions on PGs Prolog [was Re: N00b question on let]
Date: 
Message-ID: <P97bh.41$u36.20@newsfe11.lga>
Ken Tilton wrote:

> Speaking of which, what do you all think, is PGs Prolog in On Lisp 
> industrial strength? It would be so cool to ship an app with that in 
> there.

Oops:

> ; This code is copyright 1993 by Paul Graham, but anyone who wants 
> ; to use the code in any nonprofit activity, or distribute free
> ; verbatim copies (including this notice), is encouraged to do so.

As for...

> Or should I keep looking for that beautiful volume called 
> Warren's Abstract machine? There is no way that got thrown out, and I 
> have always wanted to build one.

Found it! (And it is now out of print but downloadable on-line):

    http://www.vanx.org/archive/wam/wam.html

Must be getting old, cannot follow it now. (As Kenny desperately 
rationalizes his raging NIH syndrome.)

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: jayessay
Subject: Re: Opinions on PGs Prolog [was Re: N00b question on let]
Date: 
Message-ID: <m3mz6arxpr.fsf@rigel.goldenthreadtech.com>
Ken Tilton <·········@gmail.com> writes:

> Speaking of which, what do you all think, is PGs Prolog in On Lisp
> industrial strength?

No.  Even PAIP's isn't.  You'd have to optimize its unifier for that -
as Norvig suggests along the lines of WAM.  Just guessing but I think
that is what (or at least one of the big things that) Franz did to
create theirs out of PAIP's.


/Jon

-- 
'j' - a n t h o n y at romeo/charley/november com
From: Rahul Jain
Subject: Re: Opinions on PGs Prolog
Date: 
Message-ID: <874psdwxwr.fsf@nyct.net>
jayessay <······@foo.com> writes:

> Ken Tilton <·········@gmail.com> writes:
>
>> Speaking of which, what do you all think, is PGs Prolog in On Lisp
>> industrial strength?
>
> No.  Even PAIP's isn't.  You'd have to optimize its unifier for that -
> as Norvig suggests along the lines of WAM.  Just guessing but I think
> that is what (or at least one of the big things that) Franz did to
> create theirs out of PAIP's.

LW's is based on a WAM.

-- 
Rahul Jain
·····@nyct.net
Professional Software Developer, Amateur Quantum Mechanicist
From: Tim Bradshaw
Subject: Re: N00b question on let
Date: 
Message-ID: <ekjiag$f3f$1$8300dec7@news.demon.co.uk>
On 2006-11-29 00:20:53 +0000, "Wolfram Fenske" <·····@gmx.net> said:

> I see three possibilities:
> 
>   a) you're having a joke, and nobody gets it,
>   b) you have a seriously warped understanding of what `expr' should
>      do, [1]
>   c) the real Kenny has been abducted by aliens and you, his
>      replacement, hasn't grokked prefix notation yet.

You know, this thread is why I don't read CLL any more.  People, some 
of whom clearly having only the most sketchy understanding of maths or 
programming language design, discussing operator precedence in a 
newsgroup devoted to a language which as a really basic part of its 
syntax does not actually *have* operator precedence.

I'm afraid I will just have to kill you all and stick your heads on 
stakes: it's the kindest way.

--tim
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <V5hbh.57$6e6.37@newsfe08.lga>
Tim Bradshaw wrote:
> On 2006-11-29 00:20:53 +0000, "Wolfram Fenske" <·····@gmx.net> said:
> 
>> I see three possibilities:
>>
>>   a) you're having a joke, and nobody gets it,
>>   b) you have a seriously warped understanding of what `expr' should
>>      do, [1]
>>   c) the real Kenny has been abducted by aliens and you, his
>>      replacement, hasn't grokked prefix notation yet.
> 
> 
> You know, this thread is why I don't read CLL any more.  People, some of 
> whom clearly having only the most sketchy understanding of maths or 
> programming language design, discussing operator precedence in a 
> newsgroup devoted to a language which as a really basic part of its 
> syntax does not actually *have* operator precedence.
> 
> I'm afraid I will just have to kill you all and stick your heads on 
> stakes: it's the kindest way.

[thanks, I have had the devil of a time getting a flamewar started.* 
people kept giving me serious answers!]

kenny

* ...so imagine my delight at discovering an alternate and perhaps 
preferred etymology of Kenneth leads back to "fire-head".

k

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Sidney Markowitz
Subject: Re: N00b question on let
Date: 
Message-ID: <456cd621$0$82596$742ec2ed@news.sonic.net>
Ken Tilton wrote, On 29/11/06 12:04 PM:
> let's check with the experts on
> whitespace, Python:
> 
> -3**2
> -9

This is c.l.l so let's check with the experts on Lisp, the REPL (in this
case in SBCL):

-3**2

debugger invoked on a UNBOUND-VARIABLE: The variable -3**2 is unbound.

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-INT:SIMPLE-EVAL-IN-LEXENV -3**2 #<NULL-LEXENV>)
0]

-- 
    Sidney Markowitz
    http://www.sidney.com
From: Timofei Shatrov
Subject: Re: N00b question on let
Date: 
Message-ID: <456cba17.52634664@news.readfreenews.net>
On 28 Nov 2006 14:04:57 -0800, "Kaz Kylheku" <········@gmail.com> tried to
confuse everyone with this message:

>Ken Tilton wrote:
>> Pillsy wrote:
>> > ...but what's the problem with this one?
>>
>> A small matter of -3 squared being -9?
>
>``Negative-three, squared, is nine.''
>
>The other meaning must be said like this for clarity:
>
>``The negative of three squared is negative nine.''
>

I got a bit worried here with Kenny writing an Algebra tutoring program and
all...

If (- 3) is 3 and (expt -3 2) is -3^2, then how to express (-3)^2?

(expt (- 3) 2) doesn't work. (- (expt 3 2)) doesn't work either.

I've got a feeling he didn't really think this one through...

-- 
|Don't believe this - you're not worthless              ,gr---------.ru
|It's us against millions and we can't take them all... |  ue     il   |
|But we can take them on!                               |     @ma      |
|                       (A Wilhelm Scream - The Rip)    |______________|
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <Nz4bh.191$3k4.133@newsfe10.lga>
Timofei Shatrov wrote:
> On 28 Nov 2006 14:04:57 -0800, "Kaz Kylheku" <········@gmail.com> tried to
> confuse everyone with this message:
> 
> 
>>Ken Tilton wrote:
>>
>>>Pillsy wrote:
>>>
>>>>...but what's the problem with this one?
>>>
>>>A small matter of -3 squared being -9?
>>
>>``Negative-three, squared, is nine.''
>>
>>The other meaning must be said like this for clarity:
>>
>>``The negative of three squared is negative nine.''
>>
> 
> 
> I got a bit worried here with Kenny writing an Algebra tutoring program and
> all...
> 
> If (- 3) is 3 and (expt -3 2) is -3^2, then how to express (-3)^2?
> 
> (expt (- 3) 2) doesn't work. (- (expt 3 2)) doesn't work either.

(- (expt 3 2))?

<sigh>

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Timofei Shatrov
Subject: Re: N00b question on let
Date: 
Message-ID: <456d3eb6.1644554@news.readfreenews.net>
On Tue, 28 Nov 2006 19:34:52 -0500, Ken Tilton <·········@gmail.com> tried to
confuse everyone with this message:

>
>
>Timofei Shatrov wrote:
>> 
>> I got a bit worried here with Kenny writing an Algebra tutoring program and
>> all...
>> 
>> If (- 3) is 3 and (expt -3 2) is -3^2, then how to express (-3)^2?
>> 
>> (expt (- 3) 2) doesn't work. (- (expt 3 2)) doesn't work either.
>
>(- (expt 3 2))?
>
><sigh>
>

Yeah, it kind of works for this particular case (although the syntax is
ass-backwards). By pure luck. A better example would be (-3)^3=-27

(- (expt 3 3)) is 27, which is not what we want.

Inconsistency!
-- 
|Don't believe this - you're not worthless              ,gr---------.ru
|It's us against millions and we can't take them all... |  ue     il   |
|But we can take them on!                               |     @ma      |
|                       (A Wilhelm Scream - The Rip)    |______________|
From: Rob Warnock
Subject: Re: N00b question on let
Date: 
Message-ID: <j4mdnTKr3JNgyPDYnZ2dnUVZ_q2dnZ2d@speakeasy.net>
Timofei Shatrov <····@mail.ru> wrote:
+---------------
| A better example would be (-3)^3=-27
|   (- (expt 3 3)) is 27, which is not what we want.
| Inconsistency!
+---------------

Hunh? Common Lisp agrees completely with classical mathematics
in this case:

    cmu> (expt -3 3)

    -27
    cmu> (- (expt 3 3))

    -27
    cmu> 

Where's the inconsistency?


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Timofei Shatrov
Subject: Re: N00b question on let
Date: 
Message-ID: <456d6646.11772457@news.readfreenews.net>
On Wed, 29 Nov 2006 03:42:21 -0600, ····@rpw3.org (Rob Warnock) tried to confuse
everyone with this message:

>Timofei Shatrov <····@mail.ru> wrote:
>+---------------
>| A better example would be (-3)^3=-27
>|   (- (expt 3 3)) is 27, which is not what we want.
>| Inconsistency!
>+---------------
>
>Hunh? Common Lisp agrees completely with classical mathematics
>in this case:
>
>    cmu> (expt -3 3)
>
>    -27
>    cmu> (- (expt 3 3))
>
>    -27
>    cmu> 
>
>Where's the inconsistency?
>

In Ken's Lisp. In Common Lisp there is no inconsistency.

-- 
|Don't believe this - you're not worthless              ,gr---------.ru
|It's us against millions and we can't take them all... |  ue     il   |
|But we can take them on!                               |     @ma      |
|                       (A Wilhelm Scream - The Rip)    |______________|
From: Duane Rettig
Subject: Re: N00b question on let
Date: 
Message-ID: <o0k61e1zki.fsf@gemini.franz.com>
"Kaz Kylheku" <········@gmail.com> writes:

>  (expt -3 2)
>
> There is no whitespace between - and 3, so it binds more tightly. The
> parsing follows visual intution.

This is fun.  OK, so let's put some whitespace in there:  What happens
when you try (expt - 3 2) ?  I get an error in my lisp; what do you
get in yours?

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Pillsy
Subject: Re: N00b question on let
Date: 
Message-ID: <1164754314.965358.251670@h54g2000cwb.googlegroups.com>
Ken Tilton wrote:
> Pillsy wrote:
> > Ken Tilton wrote:
[...]
> >>Absolutely, and even if you helpfully point out to them their
> >>close-minded, lock-step, conformist, xenophobic inflexibility -- do they
> >>slap their heads and say, Doh! Silly me!? Nope, they defend themselves!

> > Would you mock me if I took the opportunity to mention that, "You can
> > use hyphens instead of ugly-ass camelCase and under_scores," is one of
> > my Top Ten reasons for liking Lisp?

> No, I would mock you for being so locked into mob-rule and aggression
> that you think my insistence on walking to a different drummer entails
> also abusing anyone not conforming to my non-conformity.

Your hypothetical mocking has hypothetically silenced my hypothetical
objection.

> A small matter of -3 squared being -9?

Er....

> Exponentiation takes precedence over sign.

We don't need no stinkin' order of operations---that's what all the
parens are for!

> Actually, if this were documented it would make sense, since
> a consequence of exponentiation's higher precedence is that it cannot be
> applied to a signed number and discarding the sign might be a useful
> convenience for EXPT to provide.

EXPT doesn't do that, though. 

* (expt -2 3)
-8

Cheers,
Pillsy
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <lC4bh.193$3k4.131@newsfe10.lga>
Pillsy wrote:
> Ken Tilton wrote:
> 

>>Actually, if this were documented it would make sense, since
>>a consequence of exponentiation's higher precedence is that it cannot be
>>applied to a signed number and discarding the sign might be a useful
>>convenience for EXPT to provide.
> 
> 
> EXPT doesn't do that, though. 
> 
> * (expt -2 3)
> -8

Good point. There is no hope for the beast. I say we deprecate the damn 
thing and have done with it.

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Pillsy
Subject: Re: N00b question on let
Date: 
Message-ID: <1164762454.832473.214290@l39g2000cwd.googlegroups.com>
Ken Tilton wrote:
> Pillsy wrote:

> > EXPT doesn't do that, though.

> > * (expt -2 3)
> > -8

> Good point. There is no hope for the beast. I say we deprecate the damn
> thing and have done with it.

"-2" is just the way you write a negative number literal in (Common)
Lisp, though, like :FOO is the way you write a keyword symbol, or #\c
is how you write a character literal. Writing things out in English is
ambiguous[1] due to an absence of parentheses. Both Lisp and standard
notation add parentheses to clear up the ambiguity, but they add their
parentheses in different ways.

What else is new?

Cheers,
Pillsy

[1] "Negative 3 squared is negative 9," is either true or false
depending on how things are grouped, and English gives you no useful
clues on the grouping.
From: Pascal Bourguignon
Subject: Re: N00b question on let
Date: 
Message-ID: <87zmab80tw.fsf@thalassa.informatimago.com>
"Pillsy" <·········@gmail.com> writes:

> Ken Tilton wrote:
>> Pillsy wrote:
>
>> > EXPT doesn't do that, though.
>
>> > * (expt -2 3)
>> > -8
>
>> Good point. There is no hope for the beast. I say we deprecate the damn
>> thing and have done with it.
>
> "-2" is just the way you write a negative number literal in (Common)
> Lisp, though, like :FOO is the way you write a keyword symbol, or #\c
> is how you write a character literal. Writing things out in English is
> ambiguous[1] due to an absence of parentheses. Both Lisp and standard
> notation add parentheses to clear up the ambiguity, but they add their
> parentheses in different ways.
>
> What else is new?

Well, in APL, IIRC, they distinguish -3 from ⎻3, the first being two
tokens, - and 3 meaning lisp (- 3) and the second one token, ⎻3
meaning lisp -3.

So we can write:

   -3↑2 = ⎻9               (- (expt 3 2)) = -9
   ⎻3↑2 =  9               (expt -3 2)    =  9



For a few weeks, it seems Ken has gone to full <irony> mode and can't
find any closing tag.  Personnaly, I've just killfiled him.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
You never feed me.
Perhaps I'll sleep on your face.
That will sure show you.
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <vs6bh.387$tv6.217@newsfe09.lga>
Pascal Bourguignon wrote:
> "Pillsy" <·········@gmail.com> writes:
> 
> 
>>Ken Tilton wrote:
>>
>>>Pillsy wrote:
>>
>>>>EXPT doesn't do that, though.
>>
>>>>* (expt -2 3)
>>>>-8
>>
>>>Good point. There is no hope for the beast. I say we deprecate the damn
>>>thing and have done with it.
>>
>>"-2" is just the way you write a negative number literal in (Common)
>>Lisp, though, like :FOO is the way you write a keyword symbol, or #\c
>>is how you write a character literal. Writing things out in English is
>>ambiguous[1] due to an absence of parentheses. Both Lisp and standard
>>notation add parentheses to clear up the ambiguity, but they add their
>>parentheses in different ways.
>>
>>What else is new?
> 
> 
> Well, in APL, IIRC, they distinguish -3 from ⎻3, the first being two
> tokens, - and 3 meaning lisp (- 3) and the second one token, ⎻3
> meaning lisp -3.
> 
> So we can write:
> 
>    -3↑2 = ⎻9               (- (expt 3 2)) = -9
>    ⎻3↑2 =  9               (expt -3 2)    =  9
> 

Awesome!

> 
> 
> For a few weeks, it seems Ken has gone to full <irony> mode...

...and in spite of that great things result:

- we discover a rare case of List operator overloading where arity 
changes semantics (-, /) btw, I was unaware (/ 2) -> (/ 1 2)

- at least one denizen discovers that -3^2 -> -9

- and we (I anyway) now discover that APL has taken the bull by the 
horns and provided an alternate negating notation, which for some reason 
reminds me of the difference between oui and si in French.

Man, I must be good!

>  Personnaly, I've just killfiled him.

Aparrently there is a second school of thought...

kenny

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Kaz Kylheku
Subject: Re: N00b question on let
Date: 
Message-ID: <1164782121.463386.226270@n67g2000cwd.googlegroups.com>
Ken Tilton wrote:
> - we discover a rare case of List operator overloading where arity
> changes semantics (-, /) btw, I was unaware (/ 2) -> (/ 1 2)

Would you count (log x) -> (log e x)?

This also suports the case for introducing (expt x) -> (expt e x).

> - at least one denizen discovers that -3^2 -> -9

To be clear, I am not that denizen. :)

I know all too well that -3^2 is -12, at least on two's complement.

I'm also not so lacking in education as not to know about the relative
precedence of superscripted exponents versus unary minus in
mathematics. I don't think you can pass highschool algebra if you don't
know that, outside of the USA at least. (If you do manage, though, you
should, after that, be quite easily able to keep your little
incompetence hidden throughout the course of obtaining a CS degree).

I still insist that, independently of the written notations and their
rules, the English sentence ``negative three squared is nine'' is a
true one, by any reasonable native speaker's interpretation of the
sentence, combined with facts about ordinary numbers. You can't put an
adjective on top of the result of applying an adjective on the right
side of a noun. So for instance, ``stupid troll flamed'' could not ever
mean ``stupid (troll flamed)''. Somehow, it's not grammatical, even
though ``troll flamed'' can serve as a noun (``Hell hath no fury as a
troll flamed''). We just can't put adjectives on both sides of a noun
such that the precedence favors the postfix side. A possible theory to
explain this is that ``troll flamed'' is a syntactic transformation of
``flamed troll''. The movement of ``flamed'' after ``troll'' leaves
behind an invisible trace which conflicts with the insertion of another
adjective in that spot. Or, an alternative way of looking at it is that
the movement over to the right side cannot take place from other than
the first position of the sequence of adjectives preceding the noun. So
in ``stupid troll flamed'', the transformation can only be that of
``flamed stupid troll'' (movement of the frontmost noun to the back),
not that of ``stupid flamed troll'' (forbidden movement of second
element). Negative three squared is analogous; it's a transformation of
squared negative three, not of negative squared three. And squared
negative three is, quite unmistakably, (squared (negative 3)).

> Aparrently there is a second school of thought...

That fills me with hope, because the first one turned down my
application. What's the campus scene like?
From: Pascal Bourguignon
Subject: Re: N00b question on let
Date: 
Message-ID: <87r6vm91uq.fsf@thalassa.informatimago.com>
"Kaz Kylheku" <········@gmail.com> writes:

> Ken Tilton wrote:
>> - we discover a rare case of List operator overloading where arity
>> changes semantics (-, /) btw, I was unaware (/ 2) -> (/ 1 2)
>
> Would you count (log x) -> (log e x)?
>
> This also suports the case for introducing (expt x) -> (expt e x).
>
>> - at least one denizen discovers that -3^2 -> -9
>
> To be clear, I am not that denizen. :)
>
> I know all too well that -3^2 is -12, at least on two's complement.

In base seven, yes.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"You question the worthiness of my code? I should kill you where you
stand!"
From: Kaz Kylheku
Subject: Re: N00b question on let
Date: 
Message-ID: <1164784749.200831.109480@j72g2000cwa.googlegroups.com>
Ken Tilton wrote:
> Pillsy wrote:
> > Ken Tilton wrote:
> >
>
> >>Actually, if this were documented it would make sense, since
> >>a consequence of exponentiation's higher precedence is that it cannot be
> >>applied to a signed number and discarding the sign might be a useful
> >>convenience for EXPT to provide.
> >
> >
> > EXPT doesn't do that, though.
> >
> > * (expt -2 3)
> > -8
>
> Good point.

But also if x is -3, then (expt x 2) is 9, just like x^9 in some other
notation. Whereas you want (expt -3 2) where there is no variable
substitution to be -9.

It could be done like this. Suppose that the leading - were to be a
notation which causes -X to expand to (- X), just like 'X means (QUOTE
X). Then EXPT could be a special form which checks for the (- ...)
syntax and treats (expt (- X) Y) as (- (expt X Y)).

So if the negative sign is in the value, then it's exponentiated along
with the value. If it's in the syntax, it's factored out as lower
precedence.

Problem solved! Or, should we say, awful bullshit introduced! :)

But if you had this unary minus read macro, you would just use it like
this:

 -(expt 3 2)

This would be understood as being the equivalent of -3^2, and

(expt -3 2)

which, being (expt (- 3) 2)  would be serve as the equivalent (-3)^2.
So there would be no need for the special form hacking.  And in fact
there would be no real need for the unary minus read macro either.
Everyone could just use the minus function directly: (- (expt 3 2)) or
(expt (- 3) 2) just like in other languages where unary minus is an
operator. The key is that we banished the sign from numeric constants.

You don't have a problem with (expt (- 3) 2) being nine, right?
Basically, what you are pretending to have a problem with is that Lisp
numeric symbols have support for negation built into them. But this  is
very useful, particularly when Lisp expressions are used as data.  What
should the printed representation of a negative number be? If you print
negative forty-two as (- 42), you have an issue. When scanned back,
should this be converted---at read time!---to an integer atom
representing negative forty-two? Or should it stay as a list
expression, making the program deal with it when it's reading numeric
data?

In a language whose code does not serve as data, only the compiler or
interpreter has the privilege of processing expressions, and those
represent program code. That compiler or interpreter hunts down the
unary minuses and folds them to constants, as part of its translation
scheme. It's a processing step that would have to be repeated
everywhere, if that language were opened up to its programs as a data
and code representation.

Lastly, think about the stupid issues caused by supporting negative
numbers with a unary operator in some languages, like ANSI C.

Two's complement representations have an extra negative value. E.g. in
an implementation where int is 16 bits, the available range is from
-32768 to 32767.

This means that in C on a two's complement platform, you cannot
freaking write the most negative number directly. Because -32768 means
apply the unary minus operator to 32768, and 32768 is out of range.
Like, doh, know what I mean? The Lisp approach here would eliminate
that problem, because the tokenizer would just recognize -32768 and
produce the corresponding value. So in a Lisp with range-limited
integers, you'd just have  straightforward (defconstant *int-min*
-32768).

In a C compiler, if you want to define INT_MIN in <limits.h>, you have
to do some convolutions like:

#define INT_MAX 2147483647  /* 32 bit impl */
#define INT_MIN (-INT_MAX-1)

Try searching for "#define INT_MIN (-INT_MAX-1)" on
codesearch.google.com.

> There is no hope for the beast. I say we deprecate the damn
> thing and have done with it.

But Kenny, in programming languages, there tends to be a big, huge
disconnect between deprecating something and actually being done with
it.
From: John Thingstad
Subject: Re: N00b question on let
Date: 
Message-ID: <op.tjq58fetpqzri1@pandora.upc.no>
On Wed, 29 Nov 2006 01:37:36 +0100, Ken Tilton <·········@gmail.com> wrote:

>
>
> Pillsy wrote:
>> Ken Tilton wrote:
>>
>
>>> Actually, if this were documented it would make sense, since
>>> a consequence of exponentiation's higher precedence is that it cannot  
>>> be
>>> applied to a signed number and discarding the sign might be a useful
>>> convenience for EXPT to provide.
>>   EXPT doesn't do that, though.  * (expt -2 3)
>> -8
>
> Good point. There is no hope for the beast. I say we deprecate the damn  
> thing and have done with it.
>
> kt
>

(-2)^3 = (-2)*(-2)*(-2)=-8
Why would you want it any different?

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: John Thingstad
Subject: Re: N00b question on let
Date: 
Message-ID: <op.tjqzh4xhpqzri1@pandora.upc.no>
On Tue, 28 Nov 2006 22:37:42 +0100, Ken Tilton <·········@gmail.com> wrote:

>
> A small matter of -3 squared being -9? Exponentiation takes precedence  
> over sign. Actually, if this were documented it would make sense, since  
> a consequence of exponentiation's higher precedence is that it cannot be  
> applied to a signed number and discarding the sign might be a useful  
> convenience for EXPT to provide.
>
> kt
>

well (expt -3 2) makes (-3)^2=9
In a preprosessor you should indeed make -3^2 into (- (expt 3 2))

exp --> val ^ val
unary --> - exp

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: Kaz Kylheku
Subject: Re: N00b question on let
Date: 
Message-ID: <1164749583.079479.167410@l12g2000cwl.googlegroups.com>
Ken Tilton wrote:
> Ah, The Operator Lisp Got Wrong:
>
> (- 1  ) -> -1
> (- 1 0) ->  1

Kenny, you dumbass! There is a consistency at work here, namely that if
the operator is used as unary, the identity element is implicitly added
on the /left/. Get it?

Let's look at division. The identity element is 1.

  (/ 2)  -> 1/2  ;; implicitly (/ 1 2)

Subtraction:

  (- 1) -> -1 ;; implicitly (- 0 1)

Addition:

  (+ 1) -> 1 ;; implicitly (+ 0 1)

When you use :INITIAL-VALUE with REDUCE, where does it go? It's the
leftmost value.

You probably want it to work like this, don't you:

  (defun - (minuend &optional (subtrahend 0) &rest other-subtrahends)
...)

But how useful would that be? People /like/ being able to take the
additive inverse with (- x) or the reciprocal with (/ x).

> And here's another:
>
>    (expt -3 2) -> 9
>
> Puh-leeeze.

Puh-leeze what? Negative three squared is in fact nine.
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <853bh.17$u36.0@newsfe11.lga>
Kaz Kylheku wrote:
> Ken Tilton wrote:
> 
>>Ah, The Operator Lisp Got Wrong:
>>
>>(- 1  ) -> -1
>>(- 1 0) ->  1
> 
> 
> Kenny, you dumbass! There is a consistency at work here, namely that if
> the operator is used as unary, the identity element is implicitly added
> on the /left/. Get it?

I see. A justification for "wrong" is consistency? Works for Dubbya, but 
I am surprised you want to group yourself with a mass murderer.

No, fool, the justification is documentation of (gasp!) synatx:

"Syntax:
- number    negation
- minuend &rest subtrahends+    difference"

This has nothing to do with consistently acting weird. The CL spec does 
not need your desperate hand-waving. Rather, it simply documents the 
(gasp!) overloading of the - operator to mean different things based on 
the signature.

Get it?

>>And here's another:
>>
>>   (expt -3 2) -> 9
>>
>>Puh-leeeze.
> 
> 
> Puh-leeze what? Negative three squared is in fact nine.
> 

No, -3*-3 is 9. -3^2 is -9. Since you do not know that, you should stand 
aside and let the grownups sort this out. Dumbass.

:)

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: bradb
Subject: Re: N00b question on let
Date: 
Message-ID: <1164760674.876664.59070@14g2000cws.googlegroups.com>
On Nov 28, 2:53 pm, Ken Tilton <·········@gmail.com> wrote:
> Kaz Kylheku wrote:
> > Ken Tilton wrote:
>
> >>Ah, The Operator Lisp Got Wrong:
>
> >>(- 1  ) -> -1
> >>(- 1 0) ->  1
>
> > Kenny, you dumbass! There is a consistency at work here, namely that if
> > the operator is used as unary, the identity element is implicitly added
> > on the /left/. Get it?I see. A justification for "wrong" is consistency? Works for Dubbya, but
> I am surprised you want to group yourself with a mass murderer.
>
> No, fool, the justification is documentation of (gasp!) synatx:
>
> "Syntax:
> - number    negation
> - minuend &rest subtrahends+    difference"
>
> This has nothing to do with consistently acting weird. The CL spec does
> not need your desperate hand-waving. Rather, it simply documents the
> (gasp!) overloading of the - operator to mean different things based on
> the signature.
>
> Get it?
>
> >>And here's another:
>
> >>   (expt -3 2) -> 9
>
> >>Puh-leeeze.
>
> > Puh-leeze what? Negative three squared is in fact nine.No, -3*-3 is 9. -3^2 is -9. Since you do not know that, you should stand
> aside and let the grownups sort this out. Dumbass.
>
> :)
>

How then do I represent (-3)^2 in Lisp?
Since Lisp has no precidence rules for math I think that
(expt -3 2)  === (-3)^2
(- (expt 3 2)) === -3^2

Cheers
Brad
From: Jack Unrue
Subject: Re: N00b question on let
Date: 
Message-ID: <qrkpm25impt698ohqd918i9fluov6igi2q@4ax.com>
On Tue, 28 Nov 2006 17:53:54 -0500, Ken Tilton <·········@gmail.com> wrote:
> 
> Kaz Kylheku wrote:
> > 
> > Puh-leeze what? Negative three squared is in fact nine.
> > 
> 
> No, -3*-3 is 9. -3^2 is -9. Since you do not know that, you should stand 
> aside and let the grownups sort this out. Dumbass.

Kenny, you wouldn't happen to be the same person as Dr. Ken at
mathforum.org, would you? Such as in the following reply to a
question on this very topic?

  http://mathforum.org/library/drmath/view/55709.html

If someone had asked me this on a quiz before today, I would have
gotten it wrong!

-- 
Jack Unrue
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <Fa5bh.31$u36.25@newsfe11.lga>
Jack Unrue wrote:
> On Tue, 28 Nov 2006 17:53:54 -0500, Ken Tilton <·········@gmail.com> wrote:
> 
>>Kaz Kylheku wrote:
>>
>>>Puh-leeze what? Negative three squared is in fact nine.
>>>
>>
>>No, -3*-3 is 9. -3^2 is -9. Since you do not know that, you should stand 
>>aside and let the grownups sort this out. Dumbass.
> 
> 
> Kenny, you wouldn't happen to be the same person as Dr. Ken at
> mathforum.org, would you? Such as in the following reply to a
> question on this very topic?
> 
>   http://mathforum.org/library/drmath/view/55709.html
> 
> If someone had asked me this on a quiz before today, I would have
> gotten it wrong!
> 

No, but I did surf that up in the middle of this train wreck of a thread 
and was delighted to see another handsome* fellow holding forth on this 
devilish subject.

fire-head

* http://en.wikipedia.org/wiki/Kenneth

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Pascal Costanza
Subject: Re: N00b question on let
Date: 
Message-ID: <4t539kF11c8s2U1@mid.individual.net>
Ken Tilton wrote:
> 
> 
> Kaz Kylheku wrote:
>> Ken Tilton wrote:
>>
>>> Ah, The Operator Lisp Got Wrong:
>>>
>>> (- 1  ) -> -1
>>> (- 1 0) ->  1
>>
>>
>> Kenny, you dumbass! There is a consistency at work here, namely that if
>> the operator is used as unary, the identity element is implicitly added
>> on the /left/. Get it?
> 
> I see. A justification for "wrong" is consistency? Works for Dubbya, but 
> I am surprised you want to group yourself with a mass murderer.
> 
> No, fool, the justification is documentation of (gasp!) synatx:
> 
> "Syntax:
> - number    negation
> - minuend &rest subtrahends+    difference"
> 
> This has nothing to do with consistently acting weird. The CL spec does 
> not need your desperate hand-waving. Rather, it simply documents the 
> (gasp!) overloading of the - operator to mean different things based on 
> the signature.
> 
> Get it?
> 
>>> And here's another:
>>>
>>>   (expt -3 2) -> 9
>>>
>>> Puh-leeeze.
>>
>>
>> Puh-leeze what? Negative three squared is in fact nine.
>>
> 
> No, -3*-3 is 9. -3^2 is -9. Since you do not know that, you should stand 
> aside and let the grownups sort this out. Dumbass.

You should read the section on Lisp syntax in the HyperSpec again, 
especially Section 2.3.1 "Numbers as Tokens".


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: jayessay
Subject: Re: N00b question on let
Date: 
Message-ID: <m3r6vnrtaj.fsf@rigel.goldenthreadtech.com>
Ken Tilton <·········@gmail.com> writes:

> Ah, The Operator Lisp Got Wrong:
> 
> (- 1  ) -> -1
> (- 1 0) ->  1
> 
> And here's another:
> 
>    (expt -3 2) -> 9
> 
> Puh-leeeze.


It appears this algebra tutor thing has "gone to your head"...
precedence rules - what next?


/Jon

-- 
'j' - a n t h o n y at romeo/charley/november com
From: Pascal Bourguignon
Subject: Re: N00b question on let
Date: 
Message-ID: <877ixf9ums.fsf@thalassa.informatimago.com>
Ken Tilton <·········@gmail.com> writes:
> Ah, The Operator Lisp Got Wrong:
>
> (- 1  ) -> -1
> (- 1 0) ->  1

Well, at least, it's consistently inconsistent:

  (1-  0) -> -1


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

In a World without Walls and Fences, 
who needs Windows and Gates?
From: John Thingstad
Subject: Re: N00b question on let
Date: 
Message-ID: <op.tjqz9gznpqzri1@pandora.upc.no>
On Tue, 28 Nov 2006 21:35:55 +0100, Pascal Bourguignon  
<···@informatimago.com> wrote:

> Ken Tilton <·········@gmail.com> writes:
>> Ah, The Operator Lisp Got Wrong:
>>
>> (- 1  ) -> -1
>> (- 1 0) ->  1
>
> Well, at least, it's consistently inconsistent:
>
>   (1-  0) -> -1
>
>

Wrong?
1-0=1
-(1)=-1

You expect(+ -1 0) perhaps? The sign is part of the number.
I fail to see how this is wrong but if confused think of -n as (- n)

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: Thomas A. Russ
Subject: Re: N00b question on let
Date: 
Message-ID: <ymilklsbkk9.fsf@sevak.isi.edu>
Miss Elaine Eos <····@*your-pants*PlayNaked.com> writes:

> In article <············@newsfe11.lga>,
>  Ken Tilton <·········@gmail.com> wrote:
> 
> > Post some camelCase if you want to see them  foaming at mouth.
> 
> Oh, bah -- really?!  <sigh> What's the preferred lisp-mechanism?
> 
> Oh, wait, I know this one -- it's hypen, right?  As in
> 
>    (defun this-is-my-function ...)
> 
> vice
> 
>    (defun thisIsMyFunciton ...)
> 
> right?  Will they really lynch me for that?

They won't lynch you for that, but you will find that it makes your code
and the output from your code easier to read when it gets printed by the
lisp system.  Unless you do some mucking about with the default settings
of the readtable, your wonderful symbol

   thisIsMyFunction prints as THISISMYFUNCTION

which is much less readable than the alternative 

   THIS-IS-MY-FUNCTION

In addition, you don't have to shift to type the hyphen.

The printing issue is a fairly useful reason to go with hyphens,
especially since it makes it easier for you to use various tools.  For
example, the APROPOS function prints symbols, and getting a nice printed
version for your own functions is a good thing.

Also, if you make the change to Emacs, it is easier to navigate to
individual components of a hyphenated identifier than it is to navigate
to the parts of a CamelCase identifier, since "-" is an Emacs word
delimiter whereas a change from lower to upper case is not.

>   I'm going to have trouble 
> getting over the fact that "-" is the subtraction operator, dammit!

You need to let go of some of this thinking.

- is just a symbol in lisp, just like SUBTRACT, DO-IT or anything else.
It is just that the symbol named hyphen is used for the subtraction
function.  You now have a lot more freedom in naming functions.  For
example, you can 

  (defun compute-%-discount (value discount)
    ...)

Feel the freedom!


-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Pascal Bourguignon
Subject: Re: N00b question on let
Date: 
Message-ID: <87k61c5sfn.fsf@thalassa.informatimago.com>
···@sevak.isi.edu (Thomas A. Russ) writes:

> Miss Elaine Eos <····@*your-pants*PlayNaked.com> writes:
>
>> In article <············@newsfe11.lga>,
>>  Ken Tilton <·········@gmail.com> wrote:
>> 
>> > Post some camelCase if you want to see them  foaming at mouth.
>> 
>> Oh, bah -- really?!  <sigh> What's the preferred lisp-mechanism?
>> 
>> Oh, wait, I know this one -- it's hypen, right?  As in
>> 
>>    (defun this-is-my-function ...)
>> 
>> vice
>> 
>>    (defun thisIsMyFunciton ...)
>> 
>> right?  Will they really lynch me for that?
>
> They won't lynch you for that, but you will find that it makes your code
> and the output from your code easier to read when it gets printed by the
> lisp system.  Unless you do some mucking about with the default settings
> of the readtable, your wonderful symbol
>
>    thisIsMyFunction prints as THISISMYFUNCTION
>
> which is much less readable than the alternative 
>
>    THIS-IS-MY-FUNCTION

Not necessarily:

C/USER[31]>(setf (readtable-case *readtable*) :preserve *print-case* :preserve)
:PRESERVE
C/USER[32]> (DEFUN thisIsMyFunction (x) (+ x 1))
thisIsMyFunction
C/USER[33]> (thisIsMyFunction 2)
3

> In addition, you don't have to shift to type the hyphen.
>
> The printing issue is a fairly useful reason to go with hyphens,
> especially since it makes it easier for you to use various tools.  For
> example, the APROPOS function prints symbols, and getting a nice printed
> version for your own functions is a good thing.


C/USER[36]> (APROPOS "this")
SYSTEM::OVER-THIS-LEVEL                 
thisIsMyFunction                           function


> Also, if you make the change to Emacs, it is easier to navigate to
> individual components of a hyphenated identifier than it is to navigate
> to the parts of a CamelCase identifier, since "-" is an Emacs word
> delimiter whereas a change from lower to upper case is not.

Well, it's a simple matter to write a completing function for emacs...


>>   I'm going to have trouble 
>> getting over the fact that "-" is the subtraction operator, dammit!
>
> You need to let go of some of this thinking.
>
> - is just a symbol in lisp, just like SUBTRACT, DO-IT or anything else.
> It is just that the symbol named hyphen is used for the subtraction
> function.  You now have a lot more freedom in naming functions.  For
> example, you can 
>
>   (defun compute-%-discount (value discount)
>     ...)
>
> Feel the freedom!

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"Do not adjust your mind, there is a fault in reality"
 -- on a wall many years ago in Oxford.
From: Thomas A. Russ
Subject: Re: N00b question on let
Date: 
Message-ID: <ymiu00f9sxz.fsf@sevak.isi.edu>
Pascal Bourguignon <···@informatimago.com> writes:

> ···@sevak.isi.edu (Thomas A. Russ) writes:
> >
> > They won't lynch you for that, but you will find that it makes your code
> > and the output from your code easier to read when it gets printed by the
> > lisp system.  Unless you do some mucking about with the default settings
> > of the readtable, your wonderful symbol
> >
> >    thisIsMyFunction prints as THISISMYFUNCTION
> >
> > which is much less readable than the alternative 
> >
> >    THIS-IS-MY-FUNCTION
> 
> Not necessarily:
> 
> C/USER[31]>(setf (readtable-case *readtable*) :preserve *print-case* :preserve)
> :PRESERVE
> C/USER[32]> (DEFUN thisIsMyFunction (x) (+ x 1))
> thisIsMyFunction
> C/USER[33]> (thisIsMyFunction 2)
> 3

Of course, precisely this sort of "mucking about with the default
settings of the readtable." ;)

-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Rob Warnock
Subject: Re: N00b question on let
Date: 
Message-ID: <2pidnQwJgIu8K-_YnZ2dnUVZ_vqdnZ2d@speakeasy.net>
Pascal Bourguignon  <···@informatimago.com> wrote:
+---------------
| C/USER[31]>(setf (readtable-case *readtable*) :preserve *print-case* :preserve)
| :PRESERVE
| C/USER[32]> (DEFUN thisIsMyFunction (x) (+ x 1))
| thisIsMyFunction
| C/USER[33]> (thisIsMyFunction 2)
| 3
+---------------

Silly wabbit. Of *course* you know you really want :INVERT, not
:PRESERVE, yes? [And you don't have to mess with *PRINT-CASE*, either.]

    > (setf (readtable-case *readtable*) :invert)

    :invert
    > (defun thisIsMyFunction (x) (+ x 1))

    thisIsMyFunction
    > (cons (thisIsMyFunction 2) (expt 2 10))

    (3 . 1024)
    >

*SOOOoooooo* much nicer than :PRESERVE.  ;-}  ;-}

+---------------
| C/USER[36]> (APROPOS "this")
| SYSTEM::OVER-THIS-LEVEL                 
| thisIsMyFunction                           function
+---------------

    > (apropos :thisi)

    thisIsMyFunction [function] 
    :thisi [constant] value: :thisi
    > 


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Pascal Bourguignon
Subject: Re: N00b question on let
Date: 
Message-ID: <87irgt1a9g.fsf@thalassa.informatimago.com>
····@rpw3.org (Rob Warnock) writes:

> Pascal Bourguignon  <···@informatimago.com> wrote:
> +---------------
> | C/USER[31]>(setf (readtable-case *readtable*) :preserve *print-case* :preserve)
> | :PRESERVE
> | C/USER[32]> (DEFUN thisIsMyFunction (x) (+ x 1))
> | thisIsMyFunction
> | C/USER[33]> (thisIsMyFunction 2)
> | 3
> +---------------
>
> Silly wabbit. Of *course* you know you really want :INVERT, not
> :PRESERVE, yes? [And you don't have to mess with *PRINT-CASE*, either.]

No, I like uppercase. 
I don't mind writting (CONS (thisIsMyFunction 2) (EXPT 2 10))

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Litter box not here.
You must have moved it again.
I'll poop in the sink. 
From: Miss Elaine Eos
Subject: Re: N00b question on let
Date: 
Message-ID: <Misc-A24685.20195001122006@coml.de>
In article <···············@sevak.isi.edu>,
 ···@sevak.isi.edu (Thomas A. Russ) wrote:

> > I'm going to have trouble 
> > getting over the fact that "-" is the subtraction operator, dammit!

> You need to let go of some of this thinking.

Oh, I know -- I was just kidding.

In fact, my entire interest in learning lisp is less about 
yet-another-syntax and more about letting go of some old dogma and 
learning some new ways of thinking about problems.  It is that promise 
of lisp that contains most of the allure, for me.

...But still, it's slow going for an old dog, learning these "new" 
tricks!

-- 
Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.
From: Ken Tilton
Subject: Re: N00b question on let
Date: 
Message-ID: <bX7ch.951$7t3.455@newsfe11.lga>
Miss Elaine Eos wrote:
> In article <···············@sevak.isi.edu>,
>  ···@sevak.isi.edu (Thomas A. Russ) wrote:
> 
> 
>>>I'm going to have trouble 
>>>getting over the fact that "-" is the subtraction operator, dammit!
> 
> 
>>You need to let go of some of this thinking.
> 
> 
> Oh, I know -- I was just kidding.
> 
> In fact, my entire interest in learning lisp is less about 
> yet-another-syntax and more about letting go of some old dogma and 
> learning some new ways of thinking about problems.  It is that promise 
> of lisp that contains most of the allure, for me.
> 
> ...But still, it's slow going for an old dog, learning these "new" 
> tricks!

Changing thinking is hard. It is easier just to change your typing. Do 
what graham said in on lisp: type the shape described on p30, don't type 
the operators on p32 (or LET).

The thinking will perforce follow.

kt

ps. Man, I look away for a second and problem generation starts writing 
itself. Suh-weet. k


-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Kaz Kylheku
Subject: Re: N00b question on let
Date: 
Message-ID: <1164761564.414084.106210@14g2000cws.googlegroups.com>
Miss Elaine Eos wrote:
> In article <··············@thalassa.informatimago.com>,
>  Pascal Bourguignon <···@informatimago.com> wrote:
>
> > First, it's not an "assignment".  It's a _binding_.
>
> Ah, I'm afraid I'm not advanced enough in my lisp to understand the
> difference.  I'm sure that'll come, soon.

You might first want to revisit the analogous concept in C and C++
first and understand /that/:

  /* examples of initialization */
  T x = a, y(b);

  /* examples of assignment */
   x = a; y = b;

A binding is an association between a name and a location which holds a
value. Lispers use the term often, but the concept exists in C and C++
also; the definition T x = a, when executed, causes the name x to refer
to a memory location. A binding exists with respect to some
environment; there may concurrently exist other environments where the
same name is involved in a different binding. An example of that is
recursive, invocations of the same block which are active at the same
time. (Or reentrance via signals or threads). Binding is also dependent
on use context. In Lisp, a name can have a separate function and value
binding in the same environment. Which one is used depends on the
syntactic context of the reference.

LET is an instance of a class of ``binding constructs''. These create
envrionments in which some bindings exist.

An assignment (to a variable) doesn't create or manipulate the
bindings; it stores a new value through the binding which is in effect
for a name in the given environment.
From: Thomas A. Russ
Subject: Re: N00b question on let
Date: 
Message-ID: <ymihcwkn8cj.fsf@sevak.isi.edu>
Miss Elaine Eos <····@*your-pants*PlayNaked.com> writes:

> Fist, is this the appropriate group for lisp noob questions?  If not, 
> please redirect me to the appropriate forum.  As background, I'm a 30+ 
> developer with strong C/C++ & Java skills (among others), learning lisp 
> as my 1st functional language (I think I took a stab at it ~20 yrs ago 
> and bailed after a week), following along in Paul Graham's _Ansi Common 
> Lisp_
> 
> Ok, my question:
> 
> What is the purpose of the 2nd level of parentheses around the variable 
> and its assignment?

The reason is to group the variable with its value.
You need an extra level, because you are not required
to supply a value for the variable.  You can just supply
the symbol and have it default to a value of NIL.

In other words:

(let (a b c)
  ...)

is the same as

(let ((a nil)
      (b nil)
      (c nil))
   ...)


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