From: Trent Buck
Subject: |SYMBOL| vs 'SYMBOL
Date: 
Message-ID: <20050313003917.49167358@harpo.marx>
Consider the following code:

	(defstruct rect x y w h)	; any old structure
	=> RECT

	(function-symbol 'RECT-X)
	=> #<Closure ...>

	(function-symbol |RECT-X|)
	!! ERROR

Am I missing something here?  I thought 'foo and |foo| were equivalent.

PS: This came up when I tried to write

	(defun accessor (class attribute)
	  "Return the function bound to the symbol `class-attribute'."
	  (declare (string class attribute)
	  (symbol-function (intern (concatenate 'string class "-" attribute))))

I'm sure you chaps can do same correctly :-)

-- 
Trent Buck, Student Errant
Anyone who considers arithmetical methods of producing random
digits is, of course, in a state of sin.  -- John Von Neumann

From: Pascal Costanza
Subject: Re: |SYMBOL| vs 'SYMBOL
Date: 
Message-ID: <39ga62F5vv9hpU1@individual.net>
Trent Buck wrote:
> Consider the following code:
> 
> 	(defstruct rect x y w h)	; any old structure
> 	=> RECT
> 
> 	(function-symbol 'RECT-X)
> 	=> #<Closure ...>
> 
> 	(function-symbol |RECT-X|)
> 	!! ERROR
> 
> Am I missing something here?  I thought 'foo and |foo| were equivalent.

What's equivalent is 'foo, 'FOO and '|FOO| on the one hand, and foo, FOO 
and |FOO| on the other hand - you're just missing a quote in the second 
invocation of function-symbol.

(The equivalences may change according to the setting of readtable-case, 
I have just described the default. But readtable-case is not where your 
problem is anyway)



Pascal
From: Trent Buck
Subject: Re: |SYMBOL| vs 'SYMBOL
Date: 
Message-ID: <20050313012842.27a97d1d@harpo.marx>
Spake Pascal Costanza:
> > Am I missing something here?  I thought 'foo and |foo| were equivalent.
> 
> What's equivalent is 'foo, 'FOO and '|FOO| on the one hand, and foo, FOO 
> and |FOO| on the other hand - you're just missing a quote in the second 
> invocation of function-symbol.

Ah, I'm always messing that up.  Cheers.

	(defmacro accessor (class attribute)
	  `(symbol-function (quote ,(intern (concatenate 'string class "-" attribute)))))

-- 
Trent Buck, Student Errant
<foo> What was Quetzequatl the patron god of?
<bar> Consonants?
From: Pascal Bourguignon
Subject: Re: |SYMBOL| vs 'SYMBOL
Date: 
Message-ID: <871xakki04.fsf@thalassa.informatimago.com>
Pascal Costanza <··@p-cos.net> writes:

> Trent Buck wrote:
> > Consider the following code:
> > 	(defstruct rect x y w h)	; any old structure
> > 	=> RECT
> > 	(function-symbol 'RECT-X)
> > 	=> #<Closure ...>
> > 	(function-symbol |RECT-X|)
> > 	!! ERROR
> > Am I missing something here?  I thought 'foo and |foo| were
> > equivalent.
> 
> What's equivalent is 'foo, 'FOO and '|FOO| on the one hand, and foo,
> FOO and |FOO| on the other hand - you're just missing a quote in the
> second invocation of function-symbol.
> 
> (The equivalences may change according to the setting of
> readtable-case, I have just described the default. But readtable-case
> is not where your problem is anyway)

Once again, lisp beginners should be forbidden ' for one year, and use
only QUOTE:

    (FUNCTION-SYMBOL (QUOTE RECT-X))

    (FUNCTION-SYMBOL |RECT-X|)


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Cats meow out of angst
"Thumbs! If only we had thumbs!
We could break so much!"
From: Trent Buck
Subject: Re: |SYMBOL| vs 'SYMBOL
Date: 
Message-ID: <20050313032442.3dc6cde5@harpo.marx>
Spake Pascal Bourguignon:
>> What's equivalent is 'foo, 'FOO and '|FOO| on the one hand, and foo,
>
> Once again, lisp beginners should be forbidden ' for one year, and use
> only QUOTE:
> 
>     (FUNCTION-SYMBOL (QUOTE RECT-X))
> 
>     (FUNCTION-SYMBOL |RECT-X|)

The problem, from a cognitive point of view, is that I am often(?)
thinking "Din't work.  I'll just try adding some punctuation
semi-intelligently to see if that fixes it."

I realize how bad this is -- I see a lot of first-year CS students
writing 

	for (p; q; r);
	{
	  s;
	}

in their C programs.  I'm pretty sure this is just a familiarity thing,
because DEFMACRO, APPLY, INTERN et al are aimed at unexpected feet.
I'm a little querulous as to how helpful your maxim will be, but I'll
give it a try.

-- 
Trent Buck, Student Errant
Alter your LISP interpreter to use angle brackets instead of parens, and
tell your PHB that it is the latest nestable incarnation of XML. Call it
`Enterprise XML 2.0' (EXML 2.0) and sell it for fifty grand.
 -- c2.com, LispMachinesAreComingBack
From: Pascal Bourguignon
Subject: Re: |SYMBOL| vs 'SYMBOL
Date: 
Message-ID: <87ll8sir92.fsf@thalassa.informatimago.com>
Trent Buck <·········@tznvy.pbz> writes:

> Spake Pascal Bourguignon:
> >> What's equivalent is 'foo, 'FOO and '|FOO| on the one hand, and foo,
> >
> > Once again, lisp beginners should be forbidden ' for one year, and use
> > only QUOTE:
> > 
> >     (FUNCTION-SYMBOL (QUOTE RECT-X))
> > 
> >     (FUNCTION-SYMBOL |RECT-X|)
> 
> The problem, from a cognitive point of view, is that I am often(?)
> thinking "Din't work.  I'll just try adding some punctuation
> semi-intelligently to see if that fixes it."
> 
> I realize how bad this is -- I see a lot of first-year CS students
> writing 
> 
> 	for (p; q; r);
> 	{
> 	  s;
> 	}
> 
> in their C programs.  I'm pretty sure this is just a familiarity thing,
> because DEFMACRO, APPLY, INTERN et al are aimed at unexpected feet.
> I'm a little querulous as to how helpful your maxim will be, but I'll
> give it a try.

Please, be sure to report success or failure here.

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

Nobody can fix the economy.  Nobody can be trusted with their finger
on the button.  Nobody's perfect.  VOTE FOR NOBODY.
From: Harald Hanche-Olsen
Subject: Re: |SYMBOL| vs 'SYMBOL
Date: 
Message-ID: <pcoacp8r40q.fsf@shuttle.math.ntnu.no>
+ Trent Buck <·········@tznvy.pbz>:

| Spake Pascal Bourguignon:
| >> What's equivalent is 'foo, 'FOO and '|FOO| on the one hand, and foo,
| >
| > Once again, lisp beginners should be forbidden ' for one year, and use
| > only QUOTE:
| > 
| >     (FUNCTION-SYMBOL (QUOTE RECT-X))
| > 
| >     (FUNCTION-SYMBOL |RECT-X|)
| 
| The problem, from a cognitive point of view, is that I am often(?)
| thinking "Din't work.  I'll just try adding some punctuation
| semi-intelligently to see if that fixes it."

And maybe people just have a vague notion in their head about some
kind of escape convention, as a magic bullet that will get you out of
every kind of trouble.  I remember seeing it a lot back in the mists
of time when I hung out on comp.unix.shell for a few months.  Just
about every week, some poor sod would ask how to remove a file named
"-".  And inevitably, well-meaning but clueless folks would jump in
with advice along the lines of rm \-, rm '-', rm -i -, or rm -f -.
Then sooner or later someone would suggest rm -- -, which works with
some rm programs but not universally.  (Inevitably, someone would then
come up with a perl snippet to do the job, before sanity prevailed and
someone actually suggested rm ./- .)

The notion that things are parsed and interpreted on different levels,
and that these different levels often require different kinds of
escape mechanisms, seems inordinately difficult to get across.  I am
skeptical of the notion that forbidding the single quote will help,
though.  It may even be confusing if the implementation prints
(quote foo) as 'foo.

I wonder if life wouldn't be easier for beginners if they used

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

and were told always to use lower case for the standard symbols?
Then you sweep the existence of the |...| escape under the rug until
they're ready to face it.

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
  than thinking does: but it deprives us of whatever chance there is
  of getting closer to the truth.  -- C.P. Snow