Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Using #' with lambda
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  16 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rupert Swarbrick  
View profile  
 More options Apr 27 2012, 10:34 am
Newsgroups: comp.lang.lisp
From: Rupert Swarbrick <rswarbr...@gmail.com>
Date: Fri, 27 Apr 2012 15:34:14 +0100
Local: Fri, Apr 27 2012 10:34 am
Subject: Using #' with lambda

Hi,

I'm looking at some existing code and the original author seems to use
the construct #'(lambda...) quite a lot. As far as I can understand,
this isn't required, because of how LAMBDA works as a macro (indeed, the
note at the bottom of its CLHS page seems to say this explicitly).

To be clear, the code does stuff like this:

   (find 1 '((1 2) (3 4)) :key #'(lambda (x) (car x)))

(yes, I know I could use #'car here).

If I've understood correctly, this isn't required. (Please correct me if
I'm wrong!) But I was wondering if someone here knows of some ancient
system / lisp dialect where this would have made a difference?

The author of the code in question is clearly very competent, so I was
wondering what inspired him/her to use what I *think* is a two-character
no-op. One thing I wondered about was if it was to make the lambda form
stand out in a similar way to named functions:

   (find 17 '((1 2) (4 3))
         :key #'car
         :test #'(lambda (a b) (eq (oddp a) (oddp b))))

But I don't really see why you'd bother... Lack of syntax highlighting?

Ideas?

Rupert

  application_pgp-signature_part
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zach Beane  
View profile  
 More options Apr 27 2012, 10:51 am
Newsgroups: comp.lang.lisp
From: Zach Beane <x...@xach.com>
Date: Fri, 27 Apr 2012 10:51:19 -0400
Local: Fri, Apr 27 2012 10:51 am
Subject: Re: Using #' with lambda

I can't comment on why this author did it, but I used to do it because
it felt/looked more like a reference to a function a la #'car, as you
mention above.

After a while, though, I just started writing (lambda ...) instead and
now prefer it.

In the rare situation where LAMBDA is in the car of a form, you can't
use #', but otherwise, I can't think of anything except aesthetic
preference to use one form or the other.

Zach


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Margolin  
View profile  
 More options Apr 27 2012, 10:58 am
Newsgroups: comp.lang.lisp
From: Barry Margolin <bar...@alum.mit.edu>
Date: Fri, 27 Apr 2012 10:58:01 -0400
Local: Fri, Apr 27 2012 10:58 am
Subject: Re: Using #' with lambda
In article <87ipglxm6w....@aliengleams.portland.xach.com>,
 Zach Beane <x...@xach.com> wrote:

> In the rare situation where LAMBDA is in the car of a form, you can't
> use #', but otherwise, I can't think of anything except aesthetic
> preference to use one form or the other.

For some people it just may be an old habit that they never got rid of.  
Most dialects prior to Common Lisp didn't have the LAMBDA macro, so #'
was required.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rupert Swarbrick  
View profile  
 More options Apr 27 2012, 11:18 am
Newsgroups: comp.lang.lisp
From: Rupert Swarbrick <rswarbr...@gmail.com>
Date: Fri, 27 Apr 2012 16:18:53 +0100
Local: Fri, Apr 27 2012 11:18 am
Subject: Re: Using #' with lambda

Barry Margolin <bar...@alum.mit.edu> writes:
> In article <87ipglxm6w....@aliengleams.portland.xach.com>,
>  Zach Beane <x...@xach.com> wrote:

>> In the rare situation where LAMBDA is in the car of a form, you can't
>> use #', but otherwise, I can't think of anything except aesthetic
>> preference to use one form or the other.

> For some people it just may be an old habit that they never got rid of.  
> Most dialects prior to Common Lisp didn't have the LAMBDA macro, so #'
> was required.

Ahah! That makes sense - I wondered whether it was something like
that.

Thank you both,

Rupert

  application_pgp-signature_part
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Costanza  
View profile  
 More options Apr 28 2012, 5:26 pm
Newsgroups: comp.lang.lisp
From: Pascal Costanza <p...@p-cos.net>
Date: Sat, 28 Apr 2012 23:26:35 +0200
Local: Sat, Apr 28 2012 5:26 pm
Subject: Re: Using #' with lambda
On 27/04/2012 16:58, Barry Margolin wrote:

> In article<87ipglxm6w....@aliengleams.portland.xach.com>,
>   Zach Beane<x...@xach.com>  wrote:

>> In the rare situation where LAMBDA is in the car of a form, you can't
>> use #', but otherwise, I can't think of anything except aesthetic
>> preference to use one form or the other.

> For some people it just may be an old habit that they never got rid of.
> Most dialects prior to Common Lisp didn't have the LAMBDA macro, so #'
> was required.

Wasn't the LAMBDA macro even a late addition to the Common Lisp
standard? I'm pretty sure that CLtL2 doesn't even have it...

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/
The views expressed are my own, and not those of my employer.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
D Herring  
View profile  
 More options Apr 28 2012, 8:29 pm
Newsgroups: comp.lang.lisp
From: D Herring <dherr...@at.tentpost.dot.com>
Date: Sat, 28 Apr 2012 20:29:43 -0400
Local: Sat, Apr 28 2012 8:29 pm
Subject: Re: Using #' with lambda
On 04/28/2012 05:26 PM, Pascal Costanza wrote:

> On 27/04/2012 16:58, Barry Margolin wrote:
>> In article<87ipglxm6w....@aliengleams.portland.xach.com>,
>> Zach Beane<x...@xach.com> wrote:

>>> In the rare situation where LAMBDA is in the car of a form, you can't
>>> use #', but otherwise, I can't think of anything except aesthetic
>>> preference to use one form or the other.

>> For some people it just may be an old habit that they never got rid of.
>> Most dialects prior to Common Lisp didn't have the LAMBDA macro, so #'
>> was required.

> Wasn't the LAMBDA macro even a late addition to the Common Lisp
> standard? I'm pretty sure that CLtL2 doesn't even have it...

According to "Common Lisp: The Untold Story" by Kent Pitman (presented
at Lisp50), both the LAMBDA macro and DEFINE-SYMBOL-MACRO were added
to CL because he found they were needed to emulate ISLISP in Symbolics
Common Lisp.  This all happened some time after Symbolics went
bankrupt in 1992.

- Daniel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Apr 29 2012, 3:14 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@tfeb.org>
Date: Sun, 29 Apr 2012 08:14:17 +0100
Local: Sun, Apr 29 2012 3:14 am
Subject: Re: Using #' with lambda
On 2012-04-28 21:26:35 +0000, Pascal Costanza said:

> Wasn't the LAMBDA macro even a late addition to the Common Lisp
> standard? I'm pretty sure that CLtL2 doesn't even have it...

Yes, it was late.  I think it was added to provide infrastructure to
let you implement some other Lisp standard in CL: the problem being
that if you don't have a macro such that (lambda ...) -> (function
(lambda ...)) you can't conformingly write one because LAMBDA is in the
CL package.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kaz Kylheku  
View profile  
 More options Apr 29 2012, 10:36 am
Newsgroups: comp.lang.lisp
From: Kaz Kylheku <k...@kylheku.com>
Date: Sun, 29 Apr 2012 14:36:40 +0000 (UTC)
Local: Sun, Apr 29 2012 10:36 am
Subject: Re: Using #' with lambda
On 2012-04-29, Tim Bradshaw <t...@tfeb.org> wrote:

> On 2012-04-28 21:26:35 +0000, Pascal Costanza said:

>> Wasn't the LAMBDA macro even a late addition to the Common Lisp
>> standard? I'm pretty sure that CLtL2 doesn't even have it...

> Yes, it was late.  I think it was added to provide infrastructure to
> let you implement some other Lisp standard in CL: the problem being
> that if you don't have a macro such that (lambda ...) -> (function
> (lambda ...)) you can't conformingly write one because LAMBDA is in the
> CL package.

What? Even though it has no binding if such a macro doesn't exist?
LIST is in the CL package, yet we can use it as as a variable name.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Margolin  
View profile  
 More options Apr 29 2012, 12:24 pm
Newsgroups: comp.lang.lisp
From: Barry Margolin <bar...@alum.mit.edu>
Date: Sun, 29 Apr 2012 12:24:09 -0400
Local: Sun, Apr 29 2012 12:24 pm
Subject: Re: Using #' with lambda
In article <20120429072356....@kylheku.com>,
 Kaz Kylheku <k...@kylheku.com> wrote:

> On 2012-04-29, Tim Bradshaw <t...@tfeb.org> wrote:
> > On 2012-04-28 21:26:35 +0000, Pascal Costanza said:

> >> Wasn't the LAMBDA macro even a late addition to the Common Lisp
> >> standard? I'm pretty sure that CLtL2 doesn't even have it...

> > Yes, it was late.  I think it was added to provide infrastructure to
> > let you implement some other Lisp standard in CL: the problem being
> > that if you don't have a macro such that (lambda ...) -> (function
> > (lambda ...)) you can't conformingly write one because LAMBDA is in the
> > CL package.

> What? Even though it has no binding if such a macro doesn't exist?
> LIST is in the CL package, yet we can use it as as a variable name.

You can use it as a local variable, but not a global one.

The rationale is that local bindings don't interfere with each other,
but if two applications tried to create global bindings on the same
symbol they would conflict.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
 More options Apr 29 2012, 2:04 pm
Newsgroups: comp.lang.lisp
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Date: Sun, 29 Apr 2012 20:04:26 +0200
Local: Sun, Apr 29 2012 2:04 pm
Subject: Re: Using #' with lambda

Furthermore the fbinding of symbols in the CL packages are reserved to
the implementation: there very possibly was implementations already
using it for their purpose.

See 11.1.2.1.2 for details.

--
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Apr 29 2012, 3:48 pm
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@tfeb.org>
Date: Sun, 29 Apr 2012 20:48:53 +0100
Local: Sun, Apr 29 2012 3:48 pm
Subject: Re: Using #' with lambda
On 2012-04-29 14:36:40 +0000, Kaz Kylheku said:

> What? Even though it has no binding if such a macro doesn't exist?
> LIST is in the CL package, yet we can use it as as a variable name.

Yes.  You can lexically bind such symbols (including as functions or
macros), but that's about it.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kaz Kylheku  
View profile  
 More options Apr 29 2012, 3:53 pm
Newsgroups: comp.lang.lisp
From: Kaz Kylheku <k...@kylheku.com>
Date: Sun, 29 Apr 2012 19:53:15 +0000 (UTC)
Local: Sun, Apr 29 2012 3:53 pm
Subject: Re: Using #' with lambda
On 2012-04-29, Tim Bradshaw <t...@tfeb.org> wrote:

> On 2012-04-29 14:36:40 +0000, Kaz Kylheku said:

>> What? Even though it has no binding if such a macro doesn't exist?
>> LIST is in the CL package, yet we can use it as as a variable name.

> Yes.  You can lexically bind such symbols (including as functions or
> macros), but that's about it.

So if loop keywords were CL symbols, you couldn't have dynamic variable
or global function called finally. Hmm.

--
If you ever need any coding done, I'm your goto man!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Margolin  
View profile  
 More options Apr 29 2012, 4:21 pm
Newsgroups: comp.lang.lisp
From: Barry Margolin <bar...@alum.mit.edu>
Date: Sun, 29 Apr 2012 16:21:25 -0400
Local: Sun, Apr 29 2012 4:21 pm
Subject: Re: Using #' with lambda
In article <20120429123320....@kylheku.com>,
 Kaz Kylheku <k...@kylheku.com> wrote:

> On 2012-04-29, Tim Bradshaw <t...@tfeb.org> wrote:
> > On 2012-04-29 14:36:40 +0000, Kaz Kylheku said:

> >> What? Even though it has no binding if such a macro doesn't exist?
> >> LIST is in the CL package, yet we can use it as as a variable name.

> > Yes.  You can lexically bind such symbols (including as functions or
> > macros), but that's about it.

> So if loop keywords were CL symbols, you couldn't have dynamic variable
> or global function called finally. Hmm.

Since dynamic variables are supposed to following the *name* convention,
there's not much problem with the variable restriction.

One of the reasons that loop keywords are compared by namestring, not
symbol equality, may be so that we wouldn't pollute the CL package with
symbols like IN, TO, FOR, FROM, etc.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Apr 30 2012, 5:43 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@tfeb.org>
Date: Mon, 30 Apr 2012 10:43:52 +0100
Local: Mon, Apr 30 2012 5:43 am
Subject: Re: Using #' with lambda
On 2012-04-29 19:53:15 +0000, Kaz Kylheku said:

> So if loop keywords were CL symbols, you couldn't have dynamic variable
> or global function called finally. Hmm.

Or implement a macro called FOR, for instance.  It would be a pain.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
 More options Apr 30 2012, 6:27 am
Newsgroups: comp.lang.lisp
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Date: Mon, 30 Apr 2012 12:27:42 +0200
Local: Mon, Apr 30 2012 6:27 am
Subject: Re: Using #' with lambda

Tim Bradshaw <t...@tfeb.org> writes:
> On 2012-04-29 19:53:15 +0000, Kaz Kylheku said:

>> So if loop keywords were CL symbols, you couldn't have dynamic variable
>> or global function called finally. Hmm.

> Or implement a macro called FOR, for instance.  It would be a pain.

Hence my habit of using keywords in LOOP.

--
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Apr 30 2012, 7:21 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@tfeb.org>
Date: Mon, 30 Apr 2012 12:21:54 +0100
Local: Mon, Apr 30 2012 7:21 am
Subject: Re: Using #' with lambda
On 2012-04-30 10:27:42 +0000, Pascal J. Bourguignon said:

> Hence my habit of using keywords in LOOP.

That doesn't follow.  Well, I suppose it would follow in the case where
the current package was CL I guess, but otherwise it doesn't (and even
then it would only follow if you then exported the symbol from CL,
which would, I think, not be conforming).

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »