Google Groups Home
Help | Sign in
Python syntax in Lisp and Scheme (macro tangent)
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 151 - 175 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
Peter Seibel  
View profile
 More options Oct 7 2003, 9:32 am
Newsgroups: comp.lang.lisp
From: Peter Seibel <pe...@javamonkey.com>
Date: Tue, 07 Oct 2003 13:31:43 GMT
Local: Tues, Oct 7 2003 9:31 am
Subject: Re: Python syntax in Lisp and Scheme (macro tangent)

aabla...@cableone.net (Avi Blackmore) writes:

[comp.lang.scheme,comp.lang.functional removed]

Yup. Well in theory. I haven't gotten around to implementing all that
mostly because I haven't quite figured out the UI I want to have on
top of it. But all the information required is there.

> It sounds like it might be a nice framework to release.

I intend to, once I get this other, er, project off my plate. ;-)

I'm way aheead of you. ;-) If you want a sneak preview, check out:

 <http://www.gigamonkeys.com/book/mini-practical-building-a-unit-test-f...>

I'm sure I'll be doing a lot more work on that chapter, and perhaps
splitting it up so I can introduce a simple test framework early in
the book and then make it more sophisticated as I introduce more
advanced language features.

-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.
Discussion subject changed to "Python syntax in Lisp and Scheme" by Marco Antoniotti
Marco Antoniotti  
View profile
 More options Oct 7 2003, 9:41 am
Newsgroups: comp.lang.lisp
From: Marco Antoniotti <marc...@cs.nyu.edu>
Date: Tue, 07 Oct 2003 09:41:04 -0400
Local: Tues, Oct 7 2003 9:41 am
Subject: Re: Python syntax in Lisp and Scheme

Rayiner Hashem wrote:
>>The vast majority of people who design languages have had minimal,
>>if any, exposure to Lisp.

> To be fair, the designers of Java really do have a lot of Lisp experience.
> Its just that they intentionally chose to restrict the language according
> to their belief that a free-form, expressive language did not mesh-well
> with the types of development models you have in internet companies. You
> may disagree with that conclusion, but you can't disagree with their
> backgrounds.

> PS> You'd be surprised how many language designers like and have exposure
> Lisp. Even Bjarne Stroustrup is a fan of CL + CLOS in addition to ML. If
> you read the new XTI proposal, you'll see bits of Lisp-y stuff in there
> (even a prefix notation.)

Greenspun's Tenth Rules. :)

--
Marco


    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.
prunesquallor  
View profile
 More options Oct 7 2003, 9:54 am
Newsgroups: comp.lang.lisp
From: prunesqual...@comcast.net
Date: Tue, 07 Oct 2003 13:54:08 GMT
Local: Tues, Oct 7 2003 9:54 am
Subject: Re: Python syntax in Lisp and Scheme

Pascal Costanza <costa...@web.de> writes:
> Rayiner Hashem wrote:
>>>The vast majority of people who design languages have had minimal,
>>>if any, exposure to Lisp.
>> To be fair, the designers of Java really do have a lot of Lisp
>> experience.
>> Its just that they intentionally chose to restrict the language according
>> to their belief that a free-form, expressive language did not mesh-well
>> with the types of development models you have in internet companies. You
>> may disagree with that conclusion, but you can't disagree with their
>> backgrounds.

> James Gosling invented mocklisp which obviously isn't really a
> Lisp. See http://www.wikipedia.org/wiki/Gosling_Emacs

He got the syntax about right, though.

> Guy Steele was involved in the Java specification as a kind of
> "biographer" of the specification process. See
> http://groups.google.com/groups?selm=b4aq6e%244h4%241%40f1node01.rhrz...
> and http://www.ai.mit.edu/projects/dynlangs/wizards-panels.html

And Guy Steele has explicitly disavowed having a role in the
design of Java.


    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.
prunesquallor  
View profile
 More options Oct 7 2003, 10:01 am
Newsgroups: comp.lang.lisp
From: prunesqual...@comcast.net
Date: Tue, 07 Oct 2003 14:01:07 GMT
Local: Tues, Oct 7 2003 10:01 am
Subject: Re: Python syntax in Lisp and Scheme

The point was that even though I screwed up the indentation, it was
easily discovered and repaired with Emacs.  If the program were
whitespace-sensitive, then the screwed-up version would be
mechanically indistinguishable from the intended one.

But I had a thought last night.  I assume that Python has comments.
I can imagine a `structural' editor that hid block information in
comment fields in Python, but didn't display them to the user (and
obviously Python wouldn't care about comments).  This sort of editor
*would* be able to detect and repair the kind of mistakes I'm
talking about.  (And when Microsoft gets around to releasing its
Python derivative, I bet the `intellicode' system does just that.)

> The problem with the example arises from the fact that indentation
> is used for human readability, but parens are used by the parser.
> A clash between these two representations can lead to subtle bugs
> like this one. But remove one of the representations, and there
> can't be clashes. Of course removing indentation would lead
> super-ugly code, so why not just remove parens like has been
> done in Python? I haven't heard of people swearing about bugs
> introduced by this syntax choice, nor have I personally ever
> made a mistake with indentation.

Makefile

    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.
Hannu Kankaanp??  
View profile
 More options Oct 7 2003, 10:04 am
Newsgroups: comp.lang.lisp, comp.lang.python
From: hanzs...@yahoo.com.au (Hannu Kankaanp??)
Date: 7 Oct 2003 07:04:48 -0700
Local: Tues, Oct 7 2003 10:04 am
Subject: Re: Python syntax in Lisp and Scheme

Pascal Costanza <costa...@web.de> wrote in message <news:blu4q0$1568$1@f1node01.rhrz.uni-bonn.de>...
> ...but this means that

> collect = []
> for l in some_file_name
>    if some_property:
>        collect.append(l)

> ...is another solution for the single collector case. Now we have two
> ways to do it. Isn't this supposed to be a bad sign in the context of
> Python? I am confused...

It's all about what's the "correct" way to do it. In this case, it
would be

collect = [l for l in some_file_name if some_property]

And this would be expanded to the for-loop form *only* if it is needed.
Of course I can do

x = 5
x += y

Or I can do

x = 5 + y

That's not breaking against Python's principles. The latter
way is the right way.

(surely there are many debatable cases of which is the right
way, but the principle is adhered to as often as possible.
That's the best one can ever have)


    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.
Discussion subject changed to "test frameworks [Re: Python syntax in Lisp and Scheme (macro tangent)" by james anderson
james anderson  
View profile
 More options Oct 7 2003, 10:25 am
Newsgroups: comp.lang.lisp
From: james anderson <james.ander...@setf.de>
Date: Tue, 07 Oct 2003 16:32:41 +0200
Local: Tues, Oct 7 2003 10:32 am
Subject: test frameworks [Re: Python syntax in Lisp and Scheme (macro tangent)

just as a comment from the peanut gallery: the first thought which will occur
when i see the contents entry subtitled "unit test framework", will be to
check the references to the others - eg the one p.dietz uses which derives
from the utility from the ai lab, the test harness associated with acl,
clunit, xptest, ... to see whether they are footnotes or substantial
expositions of differences - something a bit more substantial than the cliki entry.

among other things,
 - the "UI" issues, to which you alluded in your note; especially naming;
 - logistic matters - where do they live - in the source, or in isolation;
 - why don't any of them support descriptions of serious relations among
tests. for example, while xptest defines isolated groups and clunit defines
categories no tool provides a way to describe either intrinscially or
extrinsically relations - for example interdependancy, versioning,
supersesssion, system dependancy - among the tests.

even for a middling-piddling application, none of this scales well.

...

...

    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.
Discussion subject changed to "Python syntax in Lisp and Scheme" by Bengt Richter
Bengt Richter  
View profile
 More options Oct 7 2003, 10:49 am
Newsgroups: comp.lang.lisp, comp.lang.python
From: b...@oz.net (Bengt Richter)
Date: 7 Oct 2003 14:49:55 GMT
Local: Tues, Oct 7 2003 10:49 am
Subject: Re: Python syntax in Lisp and Scheme

Um, about choosing names ...
 >>> filter
 <built-in function filter>
 >>> iter
 <built-in function iter>
;-)

>collect_pos,collect_neg = posneg(some_property, some_file_name)

Nah, just abuse a list comprehension:

 >>> seq = range(10)
 >>> test = lambda x: x%3==0
 >>> pos,neg = [(p,n) for p,n in[map(list,['']*2)]
 ...                  for q in [(x,test(x),i) for i,x in enumerate(seq)]
 ...                  if q[1] and p.append(q[0]) or not q[1] and n.append(q[0]) or not q[2]][0]
 >>> pos
 [0, 3, 6, 9]
 >>> neg
 [1, 2, 4, 5, 7, 8]

;-)

Regards,
Bengt Richter


    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.
Alexander Schmolck  
View profile
 More options Oct 7 2003, 10:50 am
Newsgroups: comp.lang.lisp
From: Alexander Schmolck <a.schmo...@gmx.net>
Date: 07 Oct 2003 15:49:04 +0100
Local: Tues, Oct 7 2003 10:49 am
Subject: Re: Python syntax in Lisp and Scheme

Alex Martelli <al...@aleax.it> writes:
> Alexander Schmolck wrote:
> > Just for the record, in python all you'd write is: v[:] = a
> I suspect you may intend "v[:] = [a]*len(v)", although a good alternative
> may also be "v[:] = itertools.repeat(a, len(v))".

Thanks for the correction (I sent this one of prematurely and then the network
broke down for 2 days).

``v[:] = a`` will actually work fine on Numeric/numarray arrays (thanks to
broadcasting), and presumably this scenario will occur more often in more in
pratice than the need to similarly destructively fill a (python) list (of
course Numeric/numarray are currently add-on's but I'd guess they'll make it
into python core eventually). In either case, as you demonstrate above there
is no need to write a for loop.

'as


    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.
Terry Reedy  
View profile
 More options Oct 7 2003, 11:30 am
Newsgroups: comp.lang.lisp, comp.lang.python
From: "Terry Reedy" <tjre...@udel.edu>
Date: Tue, 7 Oct 2003 11:23:11 -0400
Local: Tues, Oct 7 2003 11:23 am
Subject: Re: Python syntax in Lisp and Scheme

"Pascal Costanza" <costa...@web.de> wrote in message

news:blu4q0$1568$1@f1node01.rhrz.uni-bonn.de...

> What about dealing with an arbitrary number of filters?

[macro snipped]

What about it?  Using macros for somewhat simple functions stikes me
as overkill.

> An example:

>  > (predicate-collect '(-5 -4 -3 -2 -1 0 1 2 3 4 5)
>      (function evenp)
>      (lambda (n) (< n 0))
>      (lambda (n) (> n 3)))
> (-4 -2 0 2 4)
> (-5 -3 -1)
> (5)
> (1 3)

In Python:

def  multisplit(seq, *preds):
    predn = len(preds)
    bins = [[] for i in range(predn+1)]
    predpends = [(p,b.append) for (p,b) in zip(preds,bins)]
    rpend = bins[predn].append
    for item in seq:
        for pred,pend in predpends:
            if pred(item):
                pend(item)
                break
        else: rpend(item)
    return bins

multisplit(range(-5,6), lambda i: not i%2, lambda i: i<0, lambda i:
i>3)

[[-4, -2, 0, 2, 4], [-5, -3, -1], [5], [1, 3]]

Terry J. Reedy


    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.
Matthias Blume  
View profile
 More options Oct 7 2003, 11:39 am
Newsgroups: comp.lang.lisp, comp.lang.python, comp.lang.scheme, comp.lang.functional
From: Matthias Blume <f...@my.address.elsewhere>
Date: 07 Oct 2003 10:39:16 -0500
Local: Tues, Oct 7 2003 11:39 am
Subject: Re: Python syntax in Lisp and Scheme

Three words and a hyphen: Higher-Order Functions.

Most of the things that macros can do can be done with HOFs with just
as little source code duplication as with macros.  (And with macros
only the source code does not get duplicated, the same not being true
for compiled code.  With HOFs even executable code duplication is
often avoided -- depending on compiler technology.)

I say "most" because there are some things that macros can do which
are difficult with HOFs -- but those things have to do with
compile-time calculations.  A good example that was given to me during
the course of a similar discussion here on netnews is that of a
parser-generator macro: it could check at compile time that the input
grammar is, e.g., LL(1).  With HOFs this check would have to happen at
runtime, or at link-time at the earliest.  (Some languages, e.g., SML
can do arbitrary calculations at what we normally call "link time".)

Many static guarantees can be obtained by relying on reasonably
powerful static type systems, but I know of none that is powerful
enough and practical as well as general at the same time which would
be able to check for LL(1)-ness.  That's why macros sometimes "beat"
HOFs.  For most things they don't.

> 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.

Sure. &nb