Google Groups Home
Help | Sign in
Python syntax in Lisp and Scheme
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
  Messages 126 - 150 of 797 - Collapse all < Older  Newer >
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
Erann Gat  
View profile
 More options Oct 6 2003, 3:59 pm
Newsgroups: comp.lang.lisp, comp.lang.python, comp.lang.scheme, comp.lang.functional
From: my-first-name.my-last-n...@jpl.nasa.gov (Erann Gat)
Date: Mon, 06 Oct 2003 12:19:54 -0700
Local: Mon, Oct 6 2003 3:19 pm
Subject: Re: Python syntax in Lisp and Scheme
In article <eppstein-9700A3.10461306102...@news.service.uci.edu>, David

You left out the with-collector part.

But it's true that my examples are less convincing given the existence of
yield (which I had forgotten about).  But the point is that in pre-yield
Python you were stuck until the langauge designers got around to adding
it.

I'll try to come up with a more convincing short example if I find some
free time today.

E.


    Reply to author    Forward  
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.
Peter Seibel  
View profile
 More options Oct 6 2003, 4:22 pm
Newsgroups: comp.lang.lisp
From: Peter Seibel <pe...@javamonkey.com>
Date: Mon, 06 Oct 2003 20:21:55 GMT
Local: Mon, Oct 6 2003 4:21 pm
Subject: Re: Python syntax in Lisp and Scheme

Not obvious to you or me maybe. But Emacs Knows(tm). ;-)

-Peter

--
Peter Seibel                                      pe...@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp


    Reply to author    Forward  
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.
Joe Marshall  
View profile
 More options Oct 6 2003, 4:55 pm
Newsgroups: comp.lang.lisp
From: Joe Marshall <j...@ccs.neu.edu>
Date: Mon, 06 Oct 2003 16:55:43 -0400
Local: Mon, Oct 6 2003 4:55 pm
Subject: Re: Python syntax in Lisp and Scheme

Heh heh heh.... yet another reason that indentation is a poor choice
for block delimiting.

    Reply to author    Forward  
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.
Joe Marshall  
View profile
 More options Oct 6 2003, 4:56 pm
Newsgroups: comp.lang.lisp, comp.lang.python, comp.lang.scheme, comp.lang.functional
From: Joe Marshall <j...@ccs.neu.edu>
Date: Mon, 06 Oct 2003 16:56:17 -0400
Local: Mon, Oct 6 2003 4:56 pm
Subject: Re: Python syntax in Lisp and Scheme

David Rush <dr...@aol.net> writes:
> On Mon, 06 Oct 2003, Raymond Wiker <Raymond.Wi...@fast.no> wrote:
>> Matthias <n...@spam.pls> writes:
>>> (In certain cases macros) can easily be misused.
> ...
>>> You have to know if you want a sharp knife (which may hurt you when
>>> misused) or a less sharper one (where it takes more effort to cut
>>> with).

>> It is easier to hurt yourself with a blunt knife than a sharp
>> one.

> Actually I've noticed that I usually cut myself when I *switch* from
> a dull knife to a sharp one.

Grasp the sharp knife by the *handle* when switching.

    Reply to author    Forward  
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.
Raffael Cavallaro  
View profile
 More options Oct 6 2003, 6:05 pm
Newsgroups: comp.lang.lisp, comp.lang.python, comp.lang.scheme, comp.lang.functional
From: raff...@mediaone.net (Raffael Cavallaro)
Date: 6 Oct 2003 15:05:30 -0700
Local: Mon, Oct 6 2003 6:05 pm
Subject: Re: Python syntax in Lisp and Scheme

gr...@cs.uwa.edu.au wrote in message <news:blr1cq$bb1$1@enyo.uwa.edu.au>...
> In comp.lang.functional Erann Gat <my-first-name.my-last-n...@jpl.nasa.gov> wrote:
> :> I can't see why a LISP programmer would even want to write a macro.
> : That's because you are approaching this with a fundamentally flawed
> : assumption.  Macros are mainly not used to make the syntax prettier
> : (though they can be used for that).  They are mainly used to add features
> : to the language that cannot be added as functions.

> Really? Turing-completeness and all that... I presume you mean "cannot
> so easily be added as functions", but even that would surprise me.
> (Unless you mean cannot be added _to_Lisp_ as functions, because I don't
> know as much as I'd like to about Lisp's capabilities and limitations.)

Two words: code duplication.

Yes, anything that can be done with macros can also be done with
functions, but if you do it with functions, you will end up with more
code, and that code will be duplicated in every single source location
in which that abstraction it utilized.

With a macro, the abstraction is defined once, and the source code
reflects that abstraction everywhere that abstraction is used
throughout your program. For large projects this could be hundreds of
source locations.

Without a macro, you have multiple points of maintenance. If your
abstraction changes, you have to edit scores or hundreds of source
locations. With a macro, you redefine a single form, in one source
location, and recompile the dependent code.

All turing complete languages are computationally equivalent. That
doesn't mean you'll see me programming by punching holes in a paper
tape any time soon though.

Finally, there is one thing that macros can do that ordinary functions
cannot do easily - change the language's rules for functional
evaluation. This can only be accomplished with functions if you're
willing to write a set of functions that defer evaluation, by, say
parsing input, massaging it appropriately, and then passing it to the
compiler. At that point, however, you've just written your own macro
system, and invoked Greenspun's 10th Law.


    Reply to author    Forward  
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.
Thomas F. Burdick  
View profile
 More options Oct 6 2003, 6:10 pm
Newsgroups: comp.lang.lisp
From: t...@firestorm.OCF.Berkeley.EDU (Thomas F. Burdick)
Date: 06 Oct 2003 15:10:54 -0700
Local: Mon, Oct 6 2003 6:10 pm
Subject: Re: Python syntax in Lisp and Scheme

Or, with sufficiently developed paren-goggles, you can just see it.

--
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                              
   |     ) |                              
  (`-.  '--.)                              
   `. )----'                              


    Reply to author    Forward  
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.
Thomas F. Burdick  
View profile
 More options Oct 6 2003, 6:13 pm
Newsgroups: comp.lang.lisp, comp.lang.python, comp.lang.scheme, comp.lang.functional
From: t...@firestorm.OCF.Berkeley.EDU (Thomas F. Burdick)
Date: 06 Oct 2003 15:13:36 -0700
Local: Mon, Oct 6 2003 6:13 pm
Subject: Re: Python syntax in Lisp and Scheme

David Rush <dr...@aol.net> writes:
> On Mon, 06 Oct 2003, Raymond Wiker <Raymond.Wi...@fast.no> wrote:
> > Matthias <n...@spam.pls> writes:
> >> (In certain cases macros) can easily be misused.
> ...
> >> You have to know if you want a sharp knife (which may hurt you when
> >> misused) or a less sharper one (where it takes more effort to cut
> >> with).

> > It is easier to hurt yourself with a blunt knife than a sharp
> > one.

> Actually I've noticed that I usually cut myself when I *switch* from
> a dull knife to a sharp one.

I don't think the truism about cutting yourself with dull vs sharp
knives means to say anything about superficial cuts.  You don't lop
your finger off with a sharp knife, because you're handling it
carefully.  With a dull knife, your best bet is to put your weight
behind it; that's also a good way to lose a finger / dump core.

--
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                              
   |     ) |                              
  (`-.  '--.)                              
   `. )----'                              


    Reply to author    Forward  
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.
Jock Cooper  
View profile
 More options Oct 6 2003, 9:20 pm
Newsgroups: comp.lang.lisp, comp.lang.python, comp.lang.scheme, comp.lang.functional
From: Jock Cooper <jo...@mail.com>
Date: 06 Oct 2003 18:02:16 -0700
Local: Mon, Oct 6 2003 9:02 pm
Subject: Re: Python syntax in Lisp and Scheme

I'm afraid it's very hard to give any convincing examples of the
utility of macros -- as long as you are sticking to trivial examples.
On the other hand, you can't exactly post real world complex examples
of how macros saved you time and LOC (we all have em) because reader's
eyes would just glaze over.  I think macros are just another one of
CL's features that some most people just don't get until they actually
use them.  But here's a small one:

I wrote about 60 lines worth of macro based code (including a few reader
 macros) that allows me to write things like:

(with-dbconnection
  (sql-loop-in-rows
   "select col1, col2 from somewhere where something"
   :my-package row-var "pfx"
   ...
   ...some code...
   ...))

In the "some code" section, the result columns' values are accessed by
#!pfx-colname (eg #!pfx-col1), or directly from row-var using
#?pfx-colname (which returns the position).  Also, error handling code
can be automatically included by the macro code.  How much time and
effort (and possible bugs) has this saved me?  Well at least 60+ lines
or more of boilerplate every time I use this pattern..  Plus the expansions
for #!colname include error checks/warnings etc. -- all hidden from view.  

Jock
---
www.fractal-recursions.com


    Reply to author    Forward  
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.
Hartmann Schaffer  
View profile
 More options Oct 6 2003, 9:28 pm
Newsgroups: comp.lang.lisp
From: h...@heaven.nirvananet (Hartmann Schaffer)
Date: 6 Oct 2003 21:28:30 -0400
Local: Mon, Oct 6 2003 9:28 pm
Subject: Re: Python syntax in Lisp and Scheme
In article <llry2m99....@ccs.neu.edu>,
        Joe Marshall <j...@ccs.neu.edu> writes:

> ...
> Freedom, horrible freedom!  It so much harder to think than it is to
> let other people do it for you.

reminds me of an argument an intel guy (probably sales) put forward in
SIGPLAN in praise of the 8086 architecture (shortly after this
abomination was introduced):  he argued that instructions requiring
their operands relieves programmers (and compilers) from the burden of
having to chose registers

> ...

hs

--

ceterum censeo SCO esse delendam


    Reply to author    Forward  
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.
Daniel P. M. Silva  
View profile
 More options Oct 6 2003, 9:53 pm
Newsgroups: comp.lang.lisp, comp.lang.python, comp.lang.scheme, comp.lang.functional
Followup-To: comp.lang.lisp
From: "Daniel P. M. Silva" <dsi...@ccs.neu.edu>
Date: Mon, 06 Oct 2003 21:53:30 -0400
Local: Mon, Oct 6 2003 9:53 pm
Subject: Re: Python syntax in Lisp and Scheme

Erann Gat wrote:
> [...] But the point is that in pre-yield
> Python you were stuck until the langauge designers got around to adding
> it.

> I'll try to come up with a more convincing short example if I find some
> free time today.

Haven't some people implemented an entire class system as one huge macro?

- Daniel


    Reply to author    Forward  
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.
Bengt Richter  
View profile
 More options Oct 7 2003, 12:04 am
Newsgroups: comp.lang.lisp, comp.lang.python, comp.lang.scheme, comp.lang.functional
From: b...@oz.net (Bengt Richter)
Date: 7 Oct 2003 04:04:09 GMT
Local: Tues, Oct 7 2003 12:04 am
Subject: Re: Python syntax in Lisp and Scheme
On 06 Oct 2003 12:54:30 +0200, Matthias <n...@spam.pls> wrote: