From: Deep
Subject: Why doesnt this work?
Date: 
Message-ID: <1127417576.182577.146000@g49g2000cwa.googlegroups.com>
I am missing something here.


(functionp (third '(? x #'+)))

From: bradb
Subject: Re: Why doesnt this work?
Date: 
Message-ID: <1127420330.580767.75500@g43g2000cwa.googlegroups.com>
I think that it has something to do with quoting the list, try
(functionp (third `(? x ,#'+))

Brad
From: Dave Baum
Subject: Re: Why doesnt this work?
Date: 
Message-ID: <Dave.Baum-0BBB76.17440622092005@newshost.mot.com>
In article <························@g49g2000cwa.googlegroups.com>,
 "Deep" <················@gmail.com> wrote:

> I am missing something here.
> 
> 
> (functionp (third '(? x #'+)))

#' is a reader macro that makes #'x equivalent to (function x) and 'x is 
a reader macro for (quote x) so the reader returns:

(functionp (third (quote (? x (function +)))))

quote is a special form that returns its argument unevaluated, so the 
call to third actually sees (? x (function +)) as its argument.  It then 
returns the third element of that list, (function +), which is a list of 
two symbols and not a function.

Depending on what you want to do, you may find fdefinition or fboundp 
useful:

(functionp (fdefinition (third '(? x +))))  ==> t

(fboundp (third '(? x +))) ==> #<Compiled-function + #x6089EF6>

Dave
From: Wade Humeniuk
Subject: Re: Why doesnt this work?
Date: 
Message-ID: <KzEYe.185590$wr.38537@clgrps12>
Deep wrote:
> I am missing something here.
> 
> 
> (functionp (third '(? x #'+)))
> 

Whenever you run into something like this, just
back up and un-nest the form, something like ...


CL-USER 1 > (third '(? x #'+))
(FUNCTION +)

CL-USER 2 > (type-of (third '(? x #'+)))
CONS

CL-USER 3 > (functionp (third '(? x #'+)))
NIL

CL-USER 6 > (type-of (third `(? x ,#'+)))
LOW:COMPILED-CODE

CL-USER 7 > (functionp (third `(? x ,#'+)))
T

CL-USER 8 >
From: Christopher C. Stacy
Subject: Re: Why doesnt this work?
Date: 
Message-ID: <uaci47qo9.fsf@news.dtpq.com>
"Deep" <················@gmail.com> writes:
> I am missing something here.
> (functionp (third '(? x #'+)))

Not missing -- adding something you didn't mean.
You might have meant this:

  (functionp (third (list '? 'x #'+)))
From: tichy
Subject: Re: Why doesnt this work?
Date: 
Message-ID: <1127481929.462387.23860@g47g2000cwa.googlegroups.com>
Hi.
.....
> (functionp (third (list '? 'x #'+)))

Maybe he wants a literal ?

(functionp (third '(? x #.#'+))) ==> T

I'm not sure that it's portable ? Is it ?

Regards.
From: Pascal Bourguignon
Subject: Re: Why doesnt this work?
Date: 
Message-ID: <87vf0rpslx.fsf@thalassa.informatimago.com>
"tichy" <·····@o2.pl> writes:
>> (functionp (third (list '? 'x #'+)))
>
> Maybe he wants a literal ?
>
> (functionp (third '(? x #.#'+))) ==> T
>
> I'm not sure that it's portable ? Is it ?

AFAIK, it's portable.  

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

The world will now reboot.  don't bother saving your artefacts.
From: Peter Seibel
Subject: Re: Why doesnt this work?
Date: 
Message-ID: <m2aci3pow4.fsf@gigamonkeys.com>
Pascal Bourguignon <····@mouse-potato.com> writes:

> "tichy" <·····@o2.pl> writes:
>>> (functionp (third (list '? 'x #'+)))
>>
>> Maybe he wants a literal ?
>>
>> (functionp (third '(? x #.#'+))) ==> T
>>
>> I'm not sure that it's portable ? Is it ?
>
> AFAIK, it's portable.  

As long as you don't compile it. (Functions are not necessarily
externalizable objects.)

-Peter

-- 
Peter Seibel           * ·····@gigamonkeys.com
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp  * http://www.gigamonkeys.com/book/
From: Pascal Costanza
Subject: Re: Why doesnt this work?
Date: 
Message-ID: <3pj3n7Fapso5U1@individual.net>
Peter Seibel wrote:
> Pascal Bourguignon <····@mouse-potato.com> writes:
> 
> 
>>"tichy" <·····@o2.pl> writes:
>>
>>>>(functionp (third (list '? 'x #'+)))
>>>
>>>Maybe he wants a literal ?
>>>
>>>(functionp (third '(? x #.#'+))) ==> T
>>>
>>>I'm not sure that it's portable ? Is it ?
>>
>>AFAIK, it's portable.  
> 
> 
> As long as you don't compile it. (Functions are not necessarily
> externalizable objects.)

You mean "As long as you don't compile it to a file." It's possible to 
compile expressions that contain functions:

? (compile nil '(lambda (x)
                   (funcall #.(lambda (x) (+ x x)) x)))
#<Anonymous Function #x3321DDE>
NIL
NIL
? (funcall * 5)
10


Pascal

-- 
OOPSLA'05 tutorial on generic functions & the CLOS Metaobject Protocol
++++ see http://p-cos.net/oopsla05-tutorial.html for more details ++++
From: Steven M. Haflich
Subject: Re: Why doesnt this work?
Date: 
Message-ID: <4334D897.6030407@alum.mit.edu>
Pascal Costanza wrote:

> You mean "As long as you don't compile it to a file." It's possible to 
> compile expressions that contain functions:

God anticipated problems with this restriction.  That's why he created 
load-time-value, which does The Right Thing whether interpreted,
compile'd, or compile-file'd.  Details left as an exercise to the
reader (human reader, not cl:read).
From: Pascal Bourguignon
Subject: Re: Why doesnt this work?
Date: 
Message-ID: <87irwsrhm9.fsf@thalassa.informatimago.com>
"Deep" <················@gmail.com> writes:

> I am missing something here.
>
>
> (functionp (third '(? x #'+)))

Yes. You should forget for a while ' and #' and write explicitely what you mean:

 (functionp (third (quote (? x (function +)))))

Is it clearer yet?

If no:  (quote (? x (function +))) 
evaluates to:  (? x (function +))
Do you see a function here?

Try: (COM.INFORMATIMAGO.COMMON-LISP.CONS-TO-ASCII:PRINT-CONSES  '(? x #'+))
It prints:

   (?  . (X  . ((FUNCTION  . (+  . ())) . ())))

Do you still see a function here?



Unfortunately, some implementations will print (quote (function x)) as
#'x which is highly misleading, since CL actually sees no more than a
list of two symbols. I see no reason to print (quote (x y)) as (x y)
and to print (quote (function y)) as #'y, this is ridiculous.


Anyway, by now you will have seen that there's no function in the list
passed to third, so obviously functionp returns nil.

Perhaps  you'll want to write: (functionp (third (list (quote ?) 
                                                       (quote x)
                                                       (function +))))


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Until real software engineering is developed, the next best practice
is to develop with a dynamic system that has extreme late binding in
all aspects. The first system to really do this in an important way
is Lisp. -- Alan Kay
From: Deep
Subject: Re: Why doesnt this work?
Date: 
Message-ID: <1127419957.099825.136890@o13g2000cwo.googlegroups.com>
Thanks for the heads up :)
From: Brian Downing
Subject: Re: Why doesnt this work?
Date: 
Message-ID: <4gZYe.399298$xm3.223386@attbi_s21>
In article <··············@thalassa.informatimago.com>,
Pascal Bourguignon  <····@mouse-potato.com> wrote:
> Unfortunately, some implementations will print (quote (function x)) as
> #'x which is highly misleading, since CL actually sees no more than a
> list of two symbols. I see no reason to print (quote (x y)) as (x y)
> and to print (quote (function y)) as #'y, this is ridiculous.

And I see no reason to print (quote #'y) as (function y).  Since there's
no magical presentation information carried through the list structure,
you've got to pick one or the other for output.  If you don't like it,
*PRINT-PRETTY* is over there.

-bcd
-- 
*** Brian Downing <bdowning at lavos dot net> 
From: Steven M. Haflich
Subject: Re: Why doesnt this work?
Date: 
Message-ID: <OI4Ze.6090$6e1.4470@newssvr14.news.prodigy.com>
Brian Downing wrote:

> And I see no reason to print (quote #'y) as (function y).  Since there's
> no magical presentation information carried through the list structure,
> you've got to pick one or the other for output.  If you don't like it,
> *PRINT-PRETTY* is over there.

The ANS does not specify that #'foo prints as "(function foo)" when
*print-pretty* is false.  I believe this is left up to the
implementation.