From: Kenny Tilton
Subject: symbol-function vs. #'
Date: 
Message-ID: <3BE9CFAF.10B306D2@nyc.rr.com>
I thought #' was perty much the same as 'symbol-function, but:

(defmethod (setf sx) (newvalue self)
  (declare (ignore newvalue self)))

(let ((a 'sx))
  (print #'(setf sx)) ;; ok
  (print (fboundp `(setf ,a))) ;; ok
  ;; (print (symbol-function '(setf sx))) ;; fails on (setf sx)
  (print (symbol-function `(setf ,a))) ;; fails
  )

Both failures are:

   Error: Attempt to access the function field of (SETF SB) which is not
a symbol.

As you can see I found a workaround in fboundp, but I am still curious
as to why #'(setf sx) works where symbol-function does not.

kenny
clinisys

From: Thomas F. Burdick
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <xcvn11y6qtv.fsf@conquest.OCF.Berkeley.EDU>
Kenny Tilton <·······@nyc.rr.com> writes:

> I thought #' was perty much the same as 'symbol-function, but:

No, #' is the same as FUNCTION.  (function thing) gets the current
value of thing as a function.  Thing can be all manner of things,
including a symbol.

SYMBOL-FUNCTION gets the global function value of a symbol.

  [1]> (defun foo () (princ :foo))
  FOO
  [2]> (flet ((foo () (princ :bar)))
         (values (function foo) (symbol-function 'foo)))
  #<CLOSURE FOO NIL (BLOCK FOO (PRINC :BAR))> ;
  #<CLOSURE FOO NIL (DECLARE (SYSTEM::IN-DEFUN FOO)) (BLOCK FOO (PRINC :FOO))>

capice?

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: Kenny Tilton
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <3BE9E236.ECD3EEAB@nyc.rr.com>
Well, turns out 'fboundp is what I wanted. 'fdefinition works too but
signals an error if undefined and I am not always sure the setter
exists.

As for...

"Thomas F. Burdick" wrote:
> 
> Kenny Tilton <·······@nyc.rr.com> writes:
> 
> > I thought #' was perty much the same as 'symbol-function, but:
> 
> No, #' is the same as FUNCTION.  (function thing) gets the current
> value of thing as a function.  Thing can be all manner of things,
> including a symbol.
> 
> SYMBOL-FUNCTION gets the global function value of a symbol.
> 
>   [1]> (defun foo () (princ :foo))
>   FOO
>   [2]> (flet ((foo () (princ :bar)))
>          (values (function foo) (symbol-function 'foo)))
>   #<CLOSURE FOO NIL (BLOCK FOO (PRINC :BAR))> ;
>   #<CLOSURE FOO NIL (DECLARE (SYSTEM::IN-DEFUN FOO)) (BLOCK FOO (PRINC :FOO))>
> 
> capice?

wo zhidao. xie xie.

kenny
clinisys
From: Thomas F. Burdick
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <xcvitcm6l89.fsf@conquest.OCF.Berkeley.EDU>
Kenny Tilton <·······@nyc.rr.com> writes:

> Well, turns out 'fboundp is what I wanted. 'fdefinition works too but
> signals an error if undefined and I am not always sure the setter
> exists.
> 
> As for...
> 
> "Thomas F. Burdick" wrote:
> > 
> > Kenny Tilton <·······@nyc.rr.com> writes:
> > 
> > > I thought #' was perty much the same as 'symbol-function, but:
> > 
> > No, #' is the same as FUNCTION.  (function thing) gets the current
> > value of thing as a function.  Thing can be all manner of things,
> > including a symbol.
> > 
> > SYMBOL-FUNCTION gets the global function value of a symbol.
> > 
> >   [1]> (defun foo () (princ :foo))
> >   FOO
> >   [2]> (flet ((foo () (princ :bar)))
> >          (values (function foo) (symbol-function 'foo)))
> >   #<CLOSURE FOO NIL (BLOCK FOO (PRINC :BAR))> ;
> >   #<CLOSURE FOO NIL (DECLARE (SYSTEM::IN-DEFUN FOO)) (BLOCK FOO (PRINC :FOO))>
> > 
> > capice?

Er, typo.  I meant "capite?" => Italian for "do you get it?".

> wo zhidao. xie xie.

Huh?

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: Kenny Tilton
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <3BE9F2FA.A02AE3D5@nyc.rr.com>
"Thomas F. Burdick" wrote:
> 
> > > capice?
> 
> Er, typo.  I meant "capite?" => Italian for "do you get it?".

right, i figgered that was what you were asking, hence...

> 
> > wo zhidao. xie xie.
> 
> Huh?

mandarin (in pinyin) for:

"i understand. thank you."

kenny
clinisys
From: Kenny Tilton
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <3BE9E2BE.242FDFDD@nyc.rr.com>
just saw the other replies after posting, thx to all.

kenny
clinisys

Kenny Tilton wrote:
> 
> Well, turns out 'fboundp is what I wanted. 'fdefinition works too but
> signals an error if undefined and I am not always sure the setter
> exists.
> 
> As for...
> 
> "Thomas F. Burdick" wrote:
> >
> > Kenny Tilton <·······@nyc.rr.com> writes:
> >
> > > I thought #' was perty much the same as 'symbol-function, but:
> >
> > No, #' is the same as FUNCTION.  (function thing) gets the current
> > value of thing as a function.  Thing can be all manner of things,
> > including a symbol.
> >
> > SYMBOL-FUNCTION gets the global function value of a symbol.
> >
> >   [1]> (defun foo () (princ :foo))
> >   FOO
> >   [2]> (flet ((foo () (princ :bar)))
> >          (values (function foo) (symbol-function 'foo)))
> >   #<CLOSURE FOO NIL (BLOCK FOO (PRINC :BAR))> ;
> >   #<CLOSURE FOO NIL (DECLARE (SYSTEM::IN-DEFUN FOO)) (BLOCK FOO (PRINC :FOO))>
> >
> > capice?
> 
> wo zhidao. xie xie.
> 
> kenny
> clinisys
From: Kent M Pitman
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <sfwy9liowrq.fsf@world.std.com>
Kenny Tilton <·······@nyc.rr.com> writes:

> Well, turns out 'fboundp is what I wanted. 'fdefinition works too but
> signals an error if undefined and I am not always sure the setter
> exists.

It would be better if you called it FBOUNDP or fboundp but not 'fboundp.
When you quote it, you are notating the list (quote fboundp), which is
not an operator name.
From: Erik Naggum
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <3214175058506354@naggum.net>
* Kenny Tilton
| Well, turns out 'fboundp is what I wanted. 'fdefinition works too but
| signals an error if undefined and I am not always sure the setter
| exists.

* Kent M Pitman <······@world.std.com>
| It would be better if you called it FBOUNDP or fboundp but not 'fboundp.
| When you quote it, you are notating the list (quote fboundp), which is
| not an operator name.

  I read it as "turns out the symbol fboundp is what I wanted", since that
  is what 'fboundp would evaluate to, but it is just _wrong_.  That is why
  I try to write "the variable foo", "the function bar", "the class zot",
  etc.  The context we have in our source code is not available in prose,
  so I think it becomes more perspicuous by re-introducing it explicitly.
  I used to write symbols in all caps to make it stand out, but it looks
  bad, and in order to ease searching for stuff, but I never used that.

///
-- 
  Norway is now run by a priest from the fundamentalist Christian People's
  Party, the fifth largest party representing one eighth of the electorate.
-- 
  Carrying a Swiss Army pocket knife in Oslo, Norway, is a criminal offense.
From: Dorai Sitaram
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <9seobd$bhe$1@news.gte.com>
In article <···············@world.std.com>,
Kent M Pitman  <······@world.std.com> wrote:
>Kenny Tilton <·······@nyc.rr.com> writes:
>
>> Well, turns out 'fboundp is what I wanted. 'fdefinition works too but
>> signals an error if undefined and I am not always sure the setter
>> exists.
>
>It would be better if you called it FBOUNDP or fboundp but not 'fboundp.
>When you quote it, you are notating the list (quote fboundp), which is
>not an operator name.

I find the usage rather Lispily appropriate.  It
assumes that the quote mark functions the same way in
natlang discourse as in Lisp.  Without the quote, the
word would evaluate to its _natlang_ value (which in
this case isn't anything meaningful).  

It is indeed a symbol that is being referred to,
_in the natlang discourse_.   

--d
From: Kenny Tilton
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <3BEB146B.CFFEC79E@nyc.rr.com>
Dorai Sitaram wrote:
> 
> In article <···············@world.std.com>,
> Kent M Pitman  <······@world.std.com> wrote:
> >Kenny Tilton <·······@nyc.rr.com> writes:
> >
> >> Well, turns out 'fboundp is what I wanted. 'fdefinition works too but
> >> signals an error if undefined and I am not always sure the setter
> >> exists.
> >
> >It would be better if you called it FBOUNDP or fboundp but not 'fboundp.
> >When you quote it, you are notating the list (quote fboundp), which is
> >not an operator name.

i do not simply write fboundp because (a) i like to be consistent and
(2) many function names are also perfectly good words in English. but
maybe in extreme cases where there is no chance of confusion i could
give a little on the consistency thing and just say fboundp or
fdefinition. All caps is an excellent solution visually but I loathe and
despise the shift key with all my being. Nor do I want to hunt and peck
"the function ..." all the time.

> 
> I find the usage rather Lispily appropriate.  It
> assumes that the quote mark functions the same way in
> natlang discourse as in Lisp.  Without the quote, the
> word would evaluate to its _natlang_ value (which in
> this case isn't anything meaningful).
> 
> It is indeed a symbol that is being referred to,
> _in the natlang discourse_.

That explains better than i could the legislative intent of my usage. 

But I don't want to drive y'all up the wall, I'll play with a new policy
for a while:

   unquoted for names which are unmistakeably names, such as fboundp

   uppercase for names too natlang-y

kenny
clinisys
From: Kent M Pitman
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <sfwd72sg7i9.fsf@shell01.TheWorld.com>
Kenny Tilton <·······@nyc.rr.com> writes:

> i do not simply write fboundp because (a) i like to be consistent and
> (2) many function names are also perfectly good words in English. but
> maybe in extreme cases where there is no chance of confusion i could
> give a little on the consistency thing and just say fboundp or
> fdefinition. All caps is an excellent solution visually but I loathe and
> despise the shift key with all my being. Nor do I want to hunt and peck
> "the function ..." all the time.

Well, I'm one of those people who has no trouble just dedicating a finger
to holding the shift key and then just typing away as if shift-lock were
down--I often don't even realize I'm shifting.  I just think about stuff
and the words come out.  But if you're in Emacs, you can also just type in
lowercase and then type meta-b meta-u.  The meta (alt) shift on my keyboard
may be easier to hit than the shift, since you can use the (usually) unused
thumb for it, if you have the normal pc keyboard.  The symbolics keyboard
worked harder to make all the shifts ergonomically reachable.

But your real problem is hunt and peck.  No matter where you are in your
career, any time spent learning to touch type will almost surely pay for
itself many times over in very short order...
From: David Sletten
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <3BEA0938.8050408@home.com>
keshi, shei dong nide zhongwen? :)

Kenny Tilton wrote:

> Well, turns out 'fboundp is what I wanted. 'fdefinition works too but
> signals an error if undefined and I am not always sure the setter
> exists.
> 
> As for...
> 
> "Thomas F. Burdick" wrote:
> 
>>Kenny Tilton <·······@nyc.rr.com> writes:
>>
>>
>>>I thought #' was perty much the same as 'symbol-function, but:
>>>
>>No, #' is the same as FUNCTION.  (function thing) gets the current
>>value of thing as a function.  Thing can be all manner of things,
>>including a symbol.
>>
>>SYMBOL-FUNCTION gets the global function value of a symbol.
>>
>>  [1]> (defun foo () (princ :foo))
>>  FOO
>>  [2]> (flet ((foo () (princ :bar)))
>>         (values (function foo) (symbol-function 'foo)))
>>  #<CLOSURE FOO NIL (BLOCK FOO (PRINC :BAR))> ;
>>  #<CLOSURE FOO NIL (DECLARE (SYSTEM::IN-DEFUN FOO)) (BLOCK FOO (PRINC :FOO))>
>>
>>capice?
>>
> 
> wo zhidao. xie xie.
> 
> kenny
> clinisys
> 
From: Kenny Tilton
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <3BEA22F7.A9206899@nyc.rr.com>
zenshide, "dong". xx.

kt

David Sletten wrote:
> 
> keshi, shei dong nide zhongwen? :)
>
From: Kenny Tilton
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <3BE9CFF2.E4C30E56@nyc.rr.com>
shoulda mentioned I was using ACL5 on WinNT.

kt

Kenny Tilton wrote:
> 
> I thought #' was perty much the same as 'symbol-function, but:
> 
> (defmethod (setf sx) (newvalue self)
>   (declare (ignore newvalue self)))
> 
> (let ((a 'sx))
>   (print #'(setf sx)) ;; ok
>   (print (fboundp `(setf ,a))) ;; ok
>   ;; (print (symbol-function '(setf sx))) ;; fails on (setf sx)
>   (print (symbol-function `(setf ,a))) ;; fails
>   )
> 
> Both failures are:
> 
>    Error: Attempt to access the function field of (SETF SB) which is not
> a symbol.
> 
> As you can see I found a workaround in fboundp, but I am still curious
> as to why #'(setf sx) works where symbol-function does not.
> 
> kenny
> clinisys
From: Kent M Pitman
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <sfwsnbq9icw.fsf@world.std.com>
Kenny Tilton <·······@nyc.rr.com> writes:

> I thought #' was perty much the same as 'symbol-function, but:
> 
> (defmethod (setf sx) (newvalue self)
>   (declare (ignore newvalue self)))
> 
> (let ((a 'sx))
>   (print #'(setf sx)) ;; ok
>   (print (fboundp `(setf ,a))) ;; ok
>   ;; (print (symbol-function '(setf sx))) ;; fails on (setf sx)
>   (print (symbol-function `(setf ,a))) ;; fails

You want fdefinition.

And no, #'... or (function ...) is not the same as (symbol-function ...)
unless there are no local function bindings so that #' is grabbing the
global functional value.  #' is capable of getting a lexical name,
while symbol-function is not.

But yes, #' also takes (setf xxx) and symbol-function doesn't.
fdefinition takes both.
From: Pierre R. Mai
Subject: Re: symbol-function vs. #'
Date: 
Message-ID: <874ro6aw2s.fsf@orion.bln.pmsf.de>
Kenny Tilton <·······@nyc.rr.com> writes:

> I thought #' was perty much the same as 'symbol-function, but:

No.  Symbol-function is like symbol-value, in that it only accesses
the function slot of a given symbol, and hence doesn't see lexically
apparent functions (i.e. stuff introduced by flet and labels).

Furthermore, for functions with non-symbol names, like (setf foo), you
have to use fdefinition instead of symbol-function, since those
functions aren't stored in the function slot of a symbol, but
somewhere else.

Regs, Pierre.

-- 
Pierre R. Mai <····@acm.org>                    http://www.pmsf.de/pmai/
 The most likely way for the world to be destroyed, most experts agree,
 is by accident. That's where we come in; we're computer professionals.
 We cause accidents.                           -- Nathaniel Borenstein