Python syntax in Lisp and Scheme

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pascal Bourguignon

    Re: Python syntax in Lisp and Scheme

    Edi Weitz <edi@agharta.de > writes:
    [color=blue]
    > [Followup-To ignored because I don't read comp.lang.pytho n]
    >
    > On Thu, 09 Oct 2003 16:13:54 GMT, Alex Martelli <aleax@aleax.it > wrote:
    >[color=green]
    > > I think it's about a single namespace (Scheme, Python, Haskell, ...)
    > > vs CLisp's dual namespaces. People get used pretty fast to having
    > > every object (whether callable or not) "first-class" --
    > > e.g. sendable as an argument without any need for stropping or the
    > > like. To you, HOFs may feel like special cases needing special
    > > syntax that toots horns and rings bells; to people used to passing
    > > functions as arguments as a way of living, that's as syntactically
    > > obtrusive as, say, O'CAML's mandate that you use +. and not plain +
    > > when summing floats rather than ints[/color]
    >
    > In Common Lisp (not "CLisp", that's an implementation) functions /are/
    > first-class and sendable as an argument "without any need for
    > stropping or the like." What exactly are you talking about?[/color]

    Read him.

    He's talking about NAMESPACES. "namespace" occurs twice in his
    paragraph, while "function" occurs only once, that should have given
    you a hint.

    Namely, he's saying that people used to write: (mapcar cadr '((a 1) (b 2)))
    don't like having to write: (mapcar #'cadr '((a 1) (b 2))) in Common-Lisp.
    [ Personnaly, I rather write it as: (mapcar (function cadr) '((a 1) (b 2)))
    The less read macro the better I feel.]


    --
    __Pascal_Bourgu ignon__

    Do not adjust your mind, there is a fault in reality.

    Comment

    • Lulu of the Lotus-Eaters

      Re: Python syntax in Lisp and Scheme

      Kenny Tilton <ktilton@nyc.rr .com> wrote previously:
      |Do they ever plan to do a compiler for it [Python]?

      You mean like Psyco?

      Been there, done that. (and it's great, and getting better).

      --
      mertz@ | The specter of free information is haunting the `Net! All the
      gnosis | powers of IP- and crypto-tyranny have entered into an unholy
      ..cx | alliance...idea s have nothing to lose but their chains. Unite
      | against "intellectu al property" and anti-privacy regimes!
      -------------------------------------------------------------------------


      Comment

      • Kenny Tilton

        Re: Python syntax in Lisp and Scheme



        Andrew Dalke wrote:[color=blue]
        > Kenny Tilton:
        >[color=green]
        >>I wouldn't take the Greenspun crack too seriously. That's about
        >>application s recreating Lisp, not languages copying Lisp features.[/color]
        >
        >
        > Are you stating that all references of Greenspun's 10th rule,
        > when applied to Python, are meant in jest?[/color]

        Can't speak for others, but it certainly would be a mistake to apply it
        to another HLL.

        [color=blue]
        > Python isn't doing that. It's lives in a perfectly good niche wherein
        > Lisp is not the most appropriate language.[/color]

        OK, another Pythonista just told me GVR had greater ambitions. Just
        tellin ya what I hear.


        [color=blue][color=green]
        >>You presume that only Lisp gurus can learn Lisp because of the syntax.[/color]
        >
        >
        > Not at all. What I said is that Lisp gurus are self-selected to be
        > the ones who don't find the syntax to be a problem. You incorrectly
        > assumed the converse to be true.[/color]

        No, I got that, but I just wrote it kinda convoluted. And that
        self-selection thing is just silly, until people over here:

        http://alu.cliki.net/Kenny's%20RtLS% 20Top-Ten

        ....come back in a month and update their responses to say "Drat! That
        language is every bit as great as I thought it was, but that syntax is
        driving me nuts. I'm outtahere!"

        Won't happen, btw. Hell, Tolton loved Lisp even before he picked up some
        editing tips.

        You know, I just remembered a relevant experience I had, only with a
        very early release of Dylan during the search I conducted which led to
        Common Lisp, aka The Promised Land.

        I actually made a bug report to the Dylan team: "hey, when I hit tab the
        cursor jumps way the hell out here, just inside the IF. I mean, that's
        pretty fucking cool if you meant that to happen, but what's going on?"

        :)

        [color=blue]
        >
        >[color=green]
        >>But methinks a number of folks using Emacs Elisp and Autocad's embedded
        >>Lisp are non-professionals.[/color]
        >
        >
        > Methinks there are a great many more people using the VBA
        > interface to AutoCAD than its Lisp interface. In fact, my friends
        > (ex-Autodesk) told me that's the case.[/color]

        Sheesh, who hasn't been exposed to basic? From my generation, that is.
        :) But no matter, the point is anyone can handled parens if they try for
        more than an hour.

        [color=blue]
        > What does it mean to be "a Lisp"? Is Python considered "a Lisp"
        > for some definitions of Lisp?[/color]

        lessee:

        symbols? no
        sexprs? no
        code as data as code? no

        sorry, charlie.

        [color=blue][color=green]
        >>You (Alex?) also worry about groups of programmers and whether what is
        >>good for the gurus will be good for the lesser lights.[/color]
        >
        >
        > If you ever hear me call anyone who is not an expert programmer
        > a "lesser light" then I give you -- or anyone else here -- permission
        > to smack me cross-side the head.[/color]

        Boy, you sure can read a lot into a casually chosen cliche. But can we
        clear up once and for all whether these genius scientists are or are not
        as good a programmer as you? I thought I heard Python being recommended
        as better for non-professional programmers.

        Mind you, to my horror my carefully trained goalie turned out not to
        scale at all into game play (my fault) so i am back to square one with
        two days to go, so maybe I am not following all this as well as I should.


        --

        What?! You are a newbie and you haven't answered my:


        Comment

        • Pascal Bourguignon

          Re: Python syntax in Lisp and Scheme

          "Andrew Dalke" <adalke@mindspr ing.com> writes:
          [color=blue]
          > Pascal Costanza:[color=green]
          > > So what's the result of ("one" - "two") then? ;)[/color]
          >
          > It's undefined on strings -- a type error. Having + doesn't
          > mean that - must exist.[/color]

          What about:

          (defun nl-string-to-number (text)
          ;; Of course, you could program it more intelligently and more efficiently.
          (do* ((i 0 (1+ i))
          (s (format nil "~r" i) (format nil "~r" i))
          )
          ((or (string-equal s text) (< (* 2 (length text)) (length s)))
          (when (string-equal s text) i)))
          );;nl-string-to-number

          (defmacro def-s-op (name num-op)
          `(defun ,name (&rest args)
          (format nil "~r"
          (apply (function ,num-op)
          (mapcar (function nl-string-to-number) args))))
          );;def-s-op


          (def-s-op +s +)
          (def-s-op -s -)
          (def-s-op *s *)
          (def-s-op /s /)
          (def-s-op =s =)
          (def-s-op /=s /=)
          (def-s-op <s <)
          (def-s-op <=s <=)
          (def-s-op >s >)
          (def-s-op =>s <=)

          (-s "one" "two")

          ==> "minus one"


          --
          __Pascal_Bourgu ignon__

          Do not adjust your mind, there is a fault in reality.

          Comment

          • oleg@pobox.com

            Re: higher-order macros [Re: Python syntax in Lisp and Scheme

            Macros generating macros and macros that take other macros as
            arguments are quite common in Scheme. CPS-macros in particular are
            higher-order macros as they take macro-continuations. Macro-lambda and
            macro-apply (in syntax-rules) are further examples of higher-order
            macros. Macros are closely related to multi-stage computations. In
            MetaOCaml, code is just a regular value. You can write regular OCaml
            functions that take, e.g., an argument of a type (char code) and
            returns a value of (int->int code). These functions can be
            higher-order.

            Syntax-rule-level ??!lambda and ??!apply:
            Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.


            Haskell functions as CL/Scheme macros:
            Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.



            Comment

            • Edi Weitz

              Re: Python syntax in Lisp and Scheme

              On 10 Oct 2003 00:00:24 +0200, Pascal Bourguignon <spam@thalassa. informatimago.c om> wrote:
              [color=blue]
              > Edi Weitz <edi@agharta.de > writes:
              >[color=green]
              > > [Followup-To ignored because I don't read comp.lang.pytho n]
              > >
              > > On Thu, 09 Oct 2003 16:13:54 GMT, Alex Martelli <aleax@aleax.it > wrote:
              > >[color=darkred]
              > > > I think it's about a single namespace (Scheme, Python, Haskell,
              > > > ...) vs CLisp's dual namespaces. People get used pretty fast
              > > > to having every object (whether callable or not) "first-class"
              > > > -- e.g. sendable as an argument without any need for stropping
              > > > or the like. To you, HOFs may feel like special cases needing
              > > > special syntax that toots horns and rings bells; to people used
              > > > to passing functions as arguments as a way of living, that's as
              > > > syntactically obtrusive as, say, O'CAML's mandate that you use
              > > > +. and not plain + when summing floats rather than ints[/color]
              > >
              > > In Common Lisp (not "CLisp", that's an implementation) functions
              > > /are/ first-class and sendable as an argument "without any need
              > > for stropping or the like." What exactly are you talking about?[/color]
              >
              > Read him.
              >
              > He's talking about NAMESPACES. "namespace" occurs twice in his
              > paragraph, while "function" occurs only once, that should have given
              > you a hint.[/color]

              Thanks, I think my reading comprehension is quite good. What you said
              doesn't change the fact that Mr. Martelli's wording insinuates that in
              Scheme and Python functions are first-class objects and in Common Lisp
              they're not. For the sake of c.l.p readers who might not know CL I
              think this should be corrected.

              * (let ((fn (lambda (x) (* x x))))
              (mapcar fn (list 1 2 3 4 5)))

              (1 4 9 16 25)

              There you have it. I can create a function, assign it to a variable
              and pass it to another function like any other object, that's what I'd
              call a "first-class object."
              [color=blue]
              > Namely, he's saying that people used to write: (mapcar cadr '((a 1)
              > (b 2))) don't like having to write: (mapcar #'cadr '((a 1) (b 2)))
              > in Common-Lisp.[/color]

              This old namespace debate only makes me yawn, sorry.
              [color=blue]
              > [ Personnaly, I rather write it as: (mapcar (function cadr) '((a 1)
              > (b 2))) The less read macro the better I feel.][/color]

              Sincere condolences... :)

              Edi.

              Comment

              • Steven E. Harris

                Re: Python syntax in Lisp and Scheme

                Alex Martelli <aleax@aleax.it > writes:
                [color=blue]
                > Personally, the only thing I find alien in Pascal's recommendation
                > is a glaring lack -- no mention of the possibility of downloading
                > and reusing open-source libraries from the net, just getting them as
                > a part of the implementation or else rolling your own.[/color]

                Don't think it doesn't happen. Just today I downloaded and started
                using both CL-PPCRE¹ and net-telent-date².


                Footnotes:
                ¹ http://www.weitz.de/cl-ppcre/
                ² http://www.cliki.net/net-telent-date

                --
                Steven E. Harris :: seharris@raythe on.com
                Raytheon :: http://www.raytheon.com

                Comment

                • Andrew Dalke

                  Re: Python syntax in Lisp and Scheme

                  Edi Weitz[color=blue]
                  > As far as "mix and match" of packages is concerned: Use Debian
                  > (testing) or Gentoo. I've been told it's just a matter of some
                  > invocations of 'apt-get install' or 'emerge' to get the CL packages
                  > you want. At least it shouldn't be harder than, say, getting stuff
                  > from CPAN. What? You don't use Debian or Gentoo? Hey, you said you
                  > wanted "free" stuff - you get what you pay for.[/color]

                  Python's free. And I've paid for it in my efforts.

                  My primary machine is Mac OS X. I always got frustrated getting
                  fonts, sound, and movies working under the various Linux-based
                  distributions, and I suspect there are the same problems with
                  BSD-based distributions.

                  I downloaded (years ago) the Allegro demo package, but that
                  was to test a package from biolisp.org. There being no other
                  code for doing bioinformatics, and given my known proclivities
                  for Python, I didn't see the justification of paying for the full
                  commercial version.
                  [color=blue]
                  > So, here are your choices:
                  >
                  > 1. Buy a commercial Lisp. I've done that and I think it was a good
                  > decision.[/color]

                  I'm already making my living from doing Python, so I've got an
                  incentive to stay with it. ;)

                  In the scientific conferences I attend, no one I've seen uses Lisp
                  for their work, excepting those old enough that they started before
                  there were other high-quality high-level languages.

                  No one has told me they would hire me for contract work "if only
                  you were a Lisp programmer."

                  If the barrier to entry to do what are common-place tasks requires
                  I buy a commercial Lisp then it's much less likely others will use
                  my code. I like having others use my code.

                  (Then why do I use Python? It's a tradeoff, since writing Java/C++
                  is just too tedious. And I like the people in Python (Hi Laura!).
                  And I'm picky the domain -- I like doing computational life sciences.)
                  [color=blue]
                  > 2. Try to improve the situation of the free CL implementations by
                  > writing libraries or helping with the infrastructure. That's how
                  > this "Open Source" thingy is supposed to work. I'm also doing this.[/color]

                  And I'm doing it for Python. For my domain, it seems like a much
                  better language choice, for reasons I've mentioned here several times.
                  [color=blue]
                  > 3. Run around complaining that you can't use Lisp because a certain
                  > combination of features is not available for free. We have far too
                  > many of these guys on c.l.l.[/color]

                  Technically I'm cross-posting from c.l.py. And I actually complain
                  for other reasons. ;)
                  [color=blue]
                  > 4. Just don't use it. That's fine with me.[/color]

                  So far I've made ... 4(?) half-hearted attempts at learning Lisp.
                  And 1 at learning Haskell. And 0.1 at learning OCaml.
                  [color=blue]
                  > It currently looks like the number of people choosing #2 is
                  > increasing. Looks promising. You are invited to take part - it's a
                  > great language and a nice little community... :)[/color]

                  "A rising tide lifts all boats". The same is true in Python, in
                  Java, in Ruby, in ...
                  [color=blue]
                  > PS: You might also want to look at
                  >
                  > <http://web.metacircles .com/cirCLe+CD>.[/color]

                  *sigh*. Another package that doesn't (err, won't) work on my
                  Mac.

                  Andrew
                  dalke@dalkescie ntific.com


                  Comment

                  • Andrew Dalke

                    Re: Python syntax in Lisp and Scheme

                    james anderson:[color=blue]
                    > was pep-0261 adopted?[/color]

                    Yes.
                    [color=blue]
                    > has there been any data collected on how many installations are built in[/color]
                    the[color=blue]
                    > respective modes. for users in the 4-byte mode, has there been any data on
                    > storage efficiency? on general string-related algorithm performance?[/color]

                    Given that most people probably kill-threaded this discussion, you
                    might want to ask again on c.l.py with a new subject name.
                    [color=blue]
                    > do python programmers really not care about using things like os-native
                    > international type support? [0][/color]

                    I really am not the right person to talk to on this. I can offer my
                    opinion, for what that's worth.

                    The link you gave is to an Apple API for internationaliz ation. If
                    both they and Python use the same Unicode encoding, then the
                    Python unicode data can be passed directly to the API. I know
                    there are bindings between Python and the Apple framework --
                    Apple asked that Python 2.3 be ready in time for OS 10.3,
                    and I saw a demo using Apple's GUI builder to make code usable
                    by Python. For that, see the current state of the MacPython project.

                    It seems to me then that all Python offers is a way to create and
                    manipulate the unicode string, and so long as the correct translations
                    are done at the interface level to platform-specific features (as
                    when Python's unicode strings are used for a unicode aware
                    filesystem like MS Windows') then all is fine.
                    [color=blue]
                    > that may be a market issue. vendors supply what their clients pay for.[/color]
                    they[color=blue]
                    > have an interest in product differentiation . open-source developers[/color]
                    develop[color=blue]
                    > what they need. they have an interest that their implmentation serves[/color]
                    their[color=blue]
                    > needs. there is some overlap, but evidently the market does not compel the
                    > order of consolidation which you envision.[/color]

                    I listed a set of packages (regexps, unicode, XML, HTTP client&server)
                    which are included in the free version of Python. There are also
                    commercial distributions which add extra modules, like the ones from
                    activestate and scipy, but it seems that the standard free Lisp distribution

                    comes with fewer useful modules than the standard Python one.

                    Conjecture: Is it that the commericial versions of Lisp pull away
                    some of the people who would otherwise help raise the default
                    functionality of the free version? I don't think so... but then why?

                    Andrew
                    dalke@dalkescie ntific.com


                    Comment

                    • Kenny Tilton

                      Re: Python syntax in Lisp and Scheme



                      Lulu of the Lotus-Eaters wrote:
                      [color=blue]
                      > Kenny Tilton <ktilton@nyc.rr .com> wrote previously:
                      > |Do they ever plan to do a compiler for it [Python]?
                      >
                      > You mean like Psyco?
                      >
                      > Been there, done that. (and it's great, and getting better).[/color]

                      Oh, excellent name. OK, the context was "what are Python's aspirations?"
                      .. Is Python now no longer content to be a (very powerful) scripting
                      language? Or is it just tired of being ragged on for being slow?

                      --

                      What?! You are a newbie and you haven't answered my:


                      Comment

                      • Pascal Costanza

                        Re: Python syntax in Lisp and Scheme

                        Rainer Deyke wrote:
                        [color=blue]
                        > Pascal Costanza wrote:
                        >[color=green]
                        >>Pick the one Common Lisp implementation that provides the stuff you
                        >>need. If no Common Lisp implementation provides all the stuff you
                        >>need, write your own libraries or pick a different language. It's as
                        >>simple as that.[/color]
                        >
                        >
                        > Coming from a C/C++ background, I'm surprised by this attitude. Is
                        > portability of code across different language implementations not a priority
                        > for LISP programmers?[/color]

                        IMHO it's better to first get you code right on the CL implementation
                        you have chosen, and then worry about porting it to other CL
                        implementations if the need arises, and not try to do both things at the
                        same time.

                        But that's maybe just me.

                        Perhaps Kenny can better comment on this because he has already ported
                        his Cells stuff to many CL implementations . Would you recommend to take
                        care of portability from the start, or would you rather do it differently?


                        Pascal

                        Comment

                        • Pascal Costanza

                          Re: Python syntax in Lisp and Scheme

                          Alex Martelli wrote:
                          [color=blue]
                          > Personally, the only thing I find alien in Pascal's recommendation is
                          > a glaring lack -- no mention of the possibility of downloading and
                          > reusing open-source libraries from the net, just getting them as a
                          > part of the implementation or else rolling your own.[/color]

                          You're right, that's also an option.


                          Pascal

                          Comment

                          • Pascal Costanza

                            Re: Python syntax in Lisp and Scheme

                            Andrew Dalke wrote:
                            [color=blue]
                            > Edi Weitz
                            >[color=green]
                            >>As far as "mix and match" of packages is concerned: Use Debian
                            >>(testing) or Gentoo. I've been told it's just a matter of some
                            >>invocations of 'apt-get install' or 'emerge' to get the CL packages
                            >>you want. At least it shouldn't be harder than, say, getting stuff
                            >>from CPAN. What? You don't use Debian or Gentoo? Hey, you said you
                            >>wanted "free" stuff - you get what you pay for.[/color]
                            >
                            >
                            > Python's free. And I've paid for it in my efforts.
                            >
                            > My primary machine is Mac OS X. I always got frustrated getting
                            > fonts, sound, and movies working under the various Linux-based
                            > distributions, and I suspect there are the same problems with
                            > BSD-based distributions.[/color]

                            Well, then you already know that free doesn't always mean better. BTW,
                            Xanalys have just released the free personal edition of LispWorks 4.3
                            which runs on Windows, Linux and Mac OS X. [1]


                            Pascal

                            [1] No, I don't work for them. ;)

                            Comment

                            • Pascal Costanza

                              Re: Python syntax in Lisp and Scheme

                              Andrew Dalke wrote:
                              [color=blue]
                              > Conjecture: Is it that the commericial versions of Lisp pull away
                              > some of the people who would otherwise help raise the default
                              > functionality of the free version? I don't think so... but then why?[/color]

                              It's probably just because the Common Lisp community is still relatively
                              small at the moment. But this situation has already started to improve a
                              lot.


                              Pascal

                              Comment

                              • Pascal Costanza

                                Re: Python syntax in Lisp and Scheme

                                Andrew Dalke wrote:
                                [color=blue]
                                > Pascal Costanza:
                                >[color=green]
                                >>Yes, scripting languages have caught up in this regard. (However, note
                                >>that Common Lisp also includes a full compiler at runtime.)[/color]
                                >
                                >
                                > However, that's an implementation difference -- the only thing
                                > users should see is that the code runs faster. It doesn't otherwise
                                > provide new functionality.[/color]

                                No, not quite. You can actually control whether you want a piece of
                                dynamically generated code interpreted or compiled. If such generated
                                code isn't run too often (for example only once) then the overhead of
                                compiling it most probably doesn't pay off but rather can be higher than
                                when the code is just interpreted.

                                Furthermore note that this is not an implementation difference. The ANSI
                                standard defines the function COMPILE.
                                [color=blue][color=green]
                                >>Pick your choice. "There is not only one way to do it." (tm)[/color]
                                >
                                >
                                > Perl beat you to it -- "TMTOWTDO" (There's more than one way to
                                > do it.). ;)
                                >
                                > Python's reply "There should be one-- and preferably only one --
                                > obvious way to do it."[/color]

                                I simply don't believe that this will work out in the long run. Not in a
                                truly general-purpose language.


                                Pascal

                                Comment

                                Working...