Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Slashdot Log In

Log In

Create Account  |  Retrieve Password

Draft Scheme Standard R6RS Released

Posted by kdawson on Sun Sep 17, 2006 02:21 PM
from the scheming-with-a-lisp dept.
Watson Ladd writes, "The new version of the official Scheme standard has been released as a draft (PDF)." From the draft: "[This] report gives a defining description of the programming language Scheme. Scheme is a statically scoped and properly tail-recursive dialect of the Lisp programming language invented by Guy Lewis Steele Jr. and Gerald Jay Sussman. It was designed to have an exceptionally clear and simple semantics and few different ways to form expressions. A wide variety of programming paradigms, including imperative, functional, and message passing styles, find convenient expression in Scheme."
+ -
story
This discussion has been archived. No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More
Loading... please wait.
  • Hurray! (Score:5, Funny)

    by Anonymous Coward on Sunday September 17 2006, @02:27PM (#16125716)
    (I (for one (welcome (our new (Scheme (overlords.))))))
  • Actually, I have been carrying around R5RS with me for a while; it will be nice to suck down more print quota on r5r6 (when it is released). Scheme is quite a fun language, though as far as Lisps go, I do prefer Common. Still, for people who want to learn how to program, I generally tell them to start out with Scheme, usually using the PLT stuff [plt-scheme.org], and to look at SICP [mit.edu].
      • Because it is a small language, and one which will teach them the essentials of how to think about programming and structuring programs without the burdens of many heavier languages. And remember that I said "first language", and not "only language". While it may not be "useful" if they go into a programming career, I think that it helps to establish good reasoning and thought processes for when they do pick up other languages later.
      • Scheme is a great language for teaching how to program. Knowing that is far more important than knowing the details of any particular language... these things can be picked up as needed.
  • by RAMMS+EIN (578166) on Sunday September 17 2006, @02:31PM (#16125736) Homepage Journal
    Scheme is a language that every programming language enthusiast should know. Being both simple and flexible, it's suitable for communicating and explaining all kinds of concepts. A lot of books and papers are about Scheme or use Scheme for examples or teaching (see Readscheme.org [readscheme.org]). Scheme also pioneered some of the concepts in modern programming languages (such as lexical scoping), as well as several uncommon features (such as hygienic macros and first-class continuations). There are many Scheme implementations, some tiny, some slow, some fast, some with extensive libraries, some which interface to other programming languages, etc. etc.
    • by TheRaven64 (641858) on Sunday September 17 2006, @02:47PM (#16125813) Homepage Journal
      Scheme is a language that every programming language enthusiast should know.

      No, it (or some other Lisp dialect) is a language that every programmer should know. Every programmer should know Lisp, Smalltalk, and either C or some dialect of assembly language (ideally both). As a bonus, they should also know Haskell and Prolog. Once you know these languages, it is trivial to pick up any other. I would also recommend Erlang; not because it's a particularly good example of anything, but just because it's a real joy to work with.

      • Re: (Score:3, Interesting)

        by brilinux (255400)
        While we are on this bit, I would recommend an ML, either SML [standardml.org] or OCaml [inria.fr], perhaps even in place of Haskell [haskell.org] (Haskell's syntax can be easily argued to be either better than or worse than ML's, and anything you can so in Haskell (including type-classes and lazyness) can be done in ML, so while I do use Haskell, I generally recommend one of the MLs as a well-typed, type-inferring functional language to know (OCaml if they are more systems/applications oriented, and SML if they are more theory oriented or just cur
        • SML or OCaml are great lenguages, but if you're going to learn a functional language, Haskell is a great place to start. First because the syntax is very clean (I never quite liked the "let rec" bit) but also because in both SML and OCaml it is too easy to slip back into imperative styles. Haskell makes that substantially more difficult, which means to use it well you really, really have to get the whole functional programming idea.
        • Re: (Score:3, Funny)

          Be careful man. It's not wise to leave unbalanced parentheses in a Slashdot post in general, but in an article about Scheme, it's damn near suicidal!
      • Re: (Score:3, Insightful)

        by Poeir (637508)
        I'm with you on the recommendation of learning Erlang, but not for the same reason you are. The vast majority of new systems are at least dual core today. Most people run at least two programs, often meaning that one program can run entirely on one core, and another program runs on another core. Intel recently announced quad-core CPUs, and the first prototypes have got into a few people's hands. It looks like as time goes on, instead of upping the clock speed, the number of cores will increase. Most pr
    • Being both simple and flexible, it's suitable for communicating and explaining all kinds of concepts.

      Scheme is an extremely cumbersome language for experienced computer scientists to communicate ideas: Scheme lacks many concepts (e.g., exceptions, threads, records, associative data structures) that are widely used for communicating ideas. That may be justifiable for a teaching language, but it makes Scheme too cumbersome for most other purposes.

      Scheme also pioneered some of the concepts in modern programmi
            • Re: (Score:3, Insightful)

              by oohshiny (998054)
              As for what "Scheme is defined by", it doesn't matter: You program with implementations, not standards

              We're not discussing whether Scheme is a good language to program in (that's a separate debate), we're discussing whether it's a good language to communicate ideas in, as the GP claimed.

              Furthermore, Scheme, as it is now, can be a very good "grown-up" language (whatever that means).

              It means that programmers and computer scientists find other languages more useful for communicating their ideas and getting the
  • ..."I came, I saw, I programmed in LISP." This is interesting, but what I'd like to see is a dual-core-optimized dialect of QBasic that will handle obscenely large arrays without kvetching.
  • by RPoet (20693) on Sunday September 17 2006, @02:45PM (#16125791) Journal
    I've never heard about this language, but hopefully the new version will help it keep up with the latest innovations in programming languages, such as codeblocks and Web 2.0.

    Yours truly,
    Fictional stereotypical teenage Ruby fanatic.
  • by mav[LAG] (31387) on Sunday September 17 2006, @02:46PM (#16125800)
    are both tools of beauty that have taught me more about programming and problem-solving than all other languages combined. SICP [mit.edu] and PAIP [norvig.com] are both classics in this regard that everyone should rush out and get now.

    It's just such a pity that, since they're both standards which anyone can implement, lots of people do, and as a result, finding one you like and then getting it to talk to other languages and libraries can be a very frustrating experience. And languages like Python with one canonical implementation driven by a BDFL and with exceptional library support are just getting more Lisp-like, which can't be good news for for a renaissance in Lisp or Scheme. Pity really, since I really like 'em both...

  • Tail Recursion (Score:5, Informative)

    by RAMMS+EIN (578166) on Sunday September 17 2006, @02:52PM (#16125838) Homepage Journal
    For those of you who don't know what "properly tail recursive" means, a quick explanation. Consider the following code:

    (define (f x) (x x))
    (f f)

    This defines a function, f, which takes one argument, x, which should be a function (yay, first-class functions!), and calls x upon itself. Then, it calls f on f.

    Of course, this will cause f to call f upon itself. Again. And again. Infinite recursion!

    Now, proper tail recursion means that if a function call returns in tail position (meaning it is the last thing the surrounding function does before it returns), the activation frame for the surrounding function is replaced by that of the function it calls. Contrast this with normal recursion, where a _new_ activation frame would be created for the called function.

    Tail recursion makes the example code above run in bounded memory...looping forever. :-)
    • Not bounded memory. It just has to run forever. If the system has an infinite amount of memory, that memory can be consumed by the recusion and that is propert tail recursion. Not that that would matter at all in reality.
      • Re:an oxymoron (Score:5, Interesting)

        by RAMMS+EIN (578166) on Sunday September 17 2006, @05:39PM (#16126559) Homepage Journal
        ``"properly tail recursive" is an oxymoron. Tail recursion is not proper. Decent programmers use loop constructs for looping.''

        That's highly debatable. I would agree that when you want to express the concept of a loop, it's best to use a looping construct, but other people would disagree. Also, tail calls are more general than loops; for example, they also work for mutually recursive functions.

        Which is more elegant?

        int gcd(int a, int b) {
            return (b == 0) ? a : gcd(b, a % b);
        }

        or

        int gcd(int a, int b) {
            int t;
            while (b != 0) {
                t = b;
                b = a % b;
                a = t;
            }
            return a;
        }

        ``Your problem is that Scheme can't do that.''

        That depends on what you mean by "Scheme can't do that". It's entirely possible to implement looping constructs in Scheme, and several people have done so. Scheme can't do looping in the same sense that C can't compute factorials.

        ``When all you have is a hammer, everything looks like a nail.''

        Except that, in Scheme, you can make your own tools on a much more fundamental level than in many other languages. Thanks to tail call optimization, you can _implement_ looping constructs, even though the language doesn't provide them.

        ``Needless recursion makes your code more convoluted and less readable.''

        I think the example I gave earlier illustrates that, sometimes, recursion leads to less convoluted, more readable programs. The right tool for the job, ey? In a language that isn't properly tail recursive, the recursive gcd would be a bad idea because the recursion would eat memory, but in Scheme it's no problem.

        ``It's amazing how people can claim a deficiency as some kind of advantage. You just keep smoking...''

        I'm not claiming a deficiency as an advantage. I'm claiming tail call optimization is a nice features to have. There is no deficiency here.

        You could argue that the lack of looping constructs is a deficiency. However, the lack of looping constructs (1) is not at all implied by the language being properly tail recursive, (2) is easily remedied, and (3) actually has been remedied in many implementations.

        And no, I don't smoke, though I do live in the Netherlands.
          • no it doesn't (Score:3, Interesting)

            by r00t (33219)
            It's time you looked at the output from a modern C compiler. I compiled the example for PowerPC using gcc 4.1 and got the assembly shown below. There is no recursion. There isn't even any memory access; everything is done in registers. (FYI, "blr" is the PowerPC instruction for "return")

            gcd:
            cmpwi 0,4,0
            bne 0,.L7
            blr .p2align 4,,15 .L9:
          • Re: (Score:3, Insightful)

            Most modern C compilers will do tail-call optimization. However, it is not a requirement of the language (an implementation that fails to do so will still be "C"), and so implementation-agnostic portable code shouldn't count on it, and the language itself provides strong support for programming constructs that make sense when you can't count on tail-call optimization.

            Functional programming languages that require tail-call optimization as part of their definition, tend not to support such constructs as well
  • I notice that r6rs has a lot more editors than r5rs, and another author...

    Which isn't surprising. r6rs is twice as long as r5rs which had the entire table of contents on the first page.

    I'm glad to see that a lot of the slib stuff is being merged into scheme, and that they're making a lot of progress on number types. r6rs is laying out a lot more information on ADTs, IO and Unicode support.

    The explanation of continuations is still as clear as mud. How are they so easy in Python and so hard in Scheme?
    • Short and simple explanation of continuations:

      A continuation is "the part of the program that hasn't been executed yet". If your code is

      (foo)
      (bar)
      (baz)

      and you've just executed (foo), the continuation is (bar) (baz).

      In Scheme, continuations are first-class values, which means they can be stored in variables, returned from functions, passed as arguments, etc.

      There is a single way to create continuations, namely through the call-with-current-continuation form (often abbreviated call/cc). You pass call/cc a fun
  • by Bluesman (104513) on Sunday September 17 2006, @05:15PM (#16126415) Homepage
    This always comes up, but if you're at all interested in programming languages, here's why you should learn Scheme.

    A few years ago I was doing a project that involved parsing the intermediate code that GCC generated while compiling a C program. Doing a bit of research I found out that one of GCC's intermediate stages was a language called RTL (register transfer language). To my surprise, RTL looked something like this:

    (set (reg:0) (mem:blah blah))

    But wait, I thought -- that looks like Lisp. Come to find out RTL was based on lisp s-expressions.

    It was then I realized what the Big Deal with Lisp was - it has no syntax at all, and programs written in this parenthetical form are trivially converted into a parse tree. In fact, if you've ever written a simple interpreter or compiler, odds are good you'd use a list-like structure to store the parsed code.

    The reason Lisp and Scheme are so "powerful" is that you, as a programmer, have direct access to the program's parse tree at all times. (You can even alter the parse tree at compile time with macros, which is really modifying the compiler to suit your program.)

    But really, the best way to learn why Scheme or Lisp are so great is to implement them. Writing a Scheme to assembly compiler will give you an incredibly deep understanding as to how compilers and programming languages in general work.

    If you were to try to write a compiler for any other language, you'd probably spend most of your time on the lexer and parser. With Lisp or Scheme, the program, as written, is already almost fully parsed for you. Once you understand that, you'll realize why it's so cool.

  • Learn Scheme (Score:4, Informative)

    by borgboy (218060) on Sunday September 17 2006, @05:29PM (#16126509)
    I am sure there are a numer of ways to learn Scheme if you are interested. Here's one: follow the CS-61A course podcast [berkeley.edu] of Brian Harvey's class at Berkeley.
    • Re:Qs (Score:5, Informative)

      by CRCulver (715279) <crculver@christopherculver.com> on Sunday September 17 2006, @02:34PM (#16125739) Homepage
      The GNU project adopted Scheme (with the Guile interpreter) as its official scripting language. Applications are not meant to be written in Scheme, but applications can expose functionality to the user through a Scheme interface. That is to say, plugins for extensible applications could be written in Scheme. The Gimp [gimp.org] is one of the most noteworthy applications with a Scheme interface, and much of the lower-level functionality of GNU Lilypond [lilypond.org] is reached with Scheme.
      • Re: (Score:3, Interesting)

        by smallpaul (65919)
        Given the fact that Guile is more than just Scheme and that Scheme has very little traction as a scripting language, Guile is essentially "yet another scripting language" in competition with Python, Ruby and the rest. At one point there was a pipe dream that other languages would be compiled to Guile but that never materialized. In retrospect, Guile was a huge mistake for the FSF. Despite their long-term investment in Guile, Python is more popular for programming Gnome than Guile is. If the translation conc
    • Re: (Score:3, Informative)

      by brilinux (255400)
      Hmmm... you will need libraries and such for that, though some people do use Scheme for all of those things (see http://www.plt-scheme.org/ [plt-scheme.org] and http://www-sop.inria.fr/mimosa/fp/Bigloo/ [inria.fr]). I have personally used it for web applications, though I usually use common lisp and ocaml for that. In fact, if you are looking for an alternative to C++, Java, or Python, I must recommend OCaml [inria.fr]. Look at this book [inria.fr]. In fact, I wrote an interpreter for R5RS in OCaml...
    • Re: (Score:3, Interesting)

      by RAMMS+EIN (578166)
      ``What about a web application?''

      Scheme's first-class continuations [wikipedia.org] are actually a very good match for web programming, where a user can re-submit an old form at any time. Basically, with languages that lack call/cc, you will have to break up your application in little pieces to account for this, whereas call/cc allows you to structure your application like a regular one, and the language implementation will deal with the issues.

      When it comes to practicality, it all depends on the implementation. The Scheme
        • ``Without extensive libraries, most programming languages are not very useful for many common tasks.''

          True, but that's neither here nor there. A language can make an excellent text processing, web programming, scripting, etc. language without needing extensive libraries.
            • Re: (Score:3, Interesting)

              by RAMMS+EIN (578166)
              ``Languages without extensive first/third parties libraries are useless.''

              I won't argue this point further. I've already stated that languages without _extensive_ libraries can still be useful in specific domains. I still stand by that view.

              ``And languages like Scheme and Lisp are particularly crippled because they don't even have a standard extension mechanism.''

              Huh? The package system is a standard feature of Common Lisp. R6RS may standardize a module system for Scheme (although this is not certain yet);
    • by Goaway (82658)
      Here, let me help you parse the replies to your questions:

      No, no, no, no, no, no and no.
    • Does using scheme make sense when building a windows GUI application?

      Short subjective answer: No

      Scheme is a nice language and has some very interesting properties, so learning it is well worth it, but its really not the lanuage that you would want to use for your daily work, for that it simply lacks a lot of convenience features (++a becomes (set! a (+ a 1)) and it also lacks standardization bejoint its very core, which means that every Scheme implementation comes with its own set of libraries for all

      • Um. (Score:2, Informative)

        ;;;
        ;;; Macro to increment a variable by one.
        ;;;
        ;;; Usage:
        ;;;
        ;;; (define a 5)
        ;;; (inc! a)     ; a is now 6
        ;;;
        (define-syntax inc!
          (syntax-rules ()
            ((inc! x)
             (set! x (+ x 1)))))

        Not that idiomatic Scheme code will do this very often.  Langauges like Java or C use "++a" most often for loop indexes.  Looping in Scheme is typically driven off data structures.
      • Re:Qs (Score:5, Insightful)

        by John Nowak (872479) on Sunday September 17 2006, @04:31PM (#16126193)
        but its really not the lanuage that you would want to use for your daily work, for that it simply lacks a lot of convenience features (++a becomes (set! a (+ a 1))

        This just shows a lack of fundamental understanding of how one typically writes Scheme programs. If you're incrementing variables to the point where that becomes a concern, you're completely misusing the language.

        even trivial tasks like a for-loop you have to either code yourself or rely on non-portable extensions.

        Again, this shows you have no experience with the language, or you've been using it horribly wrong. There's no reason you should ever need a for loop in Scheme. If you're going to use Scheme as mostly imperative language, you're better off with Python or similar.
      • Re: (Score:3, Insightful)

        even trivial tasks like a for-loop you have to either code yourself or rely on non-portable extensions.

        Isn't a central point of Scheme that it is properly tail-recursive, functional programming language? While I'm not all that familiar with Scheme, wouldn't you usually use a recursive function rather than a for-loop in such a language?

        A for-loop isn't a task, its a construct that is natural in the idiom of certain languages for accomplishing certain tasks. Its not the idiomatic way to approach those tasks i

    • Who knows enough to condense it into a few sentences?

      You're joking, of course. It's a language specification.

      If you insist on having a condensed version, it would read:

      "This is a specification for the Scheme programming language. [specification deleted]"
      • Well, I have the old on on me right now; it is about 50 pages... I really hope that they do not turn it into ... something that is not Scheme...
        • i think there is some danger of that. section 7 in particular i found
          very disturbing, writing unix-style script execution syntax into
          the language. its clear that they are going for pragmatism and adoption
          rather than the clarity that was present in the earlier definition.

          frankly really i wish they had just stuck to core+sfri (and left
          hygenic macros as an sfri)
          • Re:142 page PDF... (Score:4, Insightful)

            by John Nowak (872479) on Sunday September 17 2006, @04:14PM (#16126138)
            This is only distributing until you remember that almost every implementation has to implement something similar, often in a way that's slightly different and incompatible with everything else. I'll agree that there is a danger, yes.

            However, I personally feel that R6RS is nearly at the perfect point. It is still very heavily leaning towards simplicity and clarity, but includes the bits that everyone ends up implementing anyway in non-standard ways. The truth is that modern unix systems are ugly, i/o is complicated, and a lack of a standard macro system (see the syntax-case variants) is horribly annoying. R6RS does reflect all of this, but I think trying to cleanly negate issues is far better than simply ignoring them. There are a few things that I think overreach, but I'm very happy with 95% of the additions. This is a standard we can make use of for the next 10-20 years.
              • Re: (Score:3, Interesting)

                by John Nowak (872479)
                For one, I'm not sure unicode should be mandatory. I believe it should be described as a recommended component, but not necessary to call your language R6RS-compliant. Would I use a Scheme without unicode support? No, but for some applications and on some systems it isn't necessary. It is great to standardize on an interface, so all that do implement it (and most will) will do it compatibly, but it shouldn't be mandatory. Other things that should probably be recommended by not required are exceptions and th
    • If you RTFA and follow a few obvious links, you get to The R6RS Status Report [schemers.org] which gives a relatively concise overview of the changes from R5 to R6.

      Since Scheme wasn't the one of the versions of LISP that I learned back in the dark ages, I couldn't really follow the subtleties of which changes are really significant, but it looks like it would make sense if you were following Scheme.

    • by RPoet (20693)
      The name "Scheme" was picked in the 1970s, so I wouldn't say Scheme joins Source in "today's" bad naming practices.
    • (let loop ()
              (display "> ")
              (write (eval (read)))
              (newline)
              (loop))
    • That's because you're an idiot. The parentheses are not a problem at all when reading code.
    • by Estanislao Martínez (203477) on Sunday September 17 2006, @04:00PM (#16126092) Homepage

      But Scheme looks like one of the many programming languages developed for parsers and compilers, instead of for the people. Programming languages should be easy to read for humans too.

      Lisp syntax certainly does not attempt to look like the combination of English text and mathematical formulas that most languages shoot for, but this in fact has many advantages. The idea of making a language look like that doesn't change the fact that the language will work in a way very different from English or mathematical notation; your previous knowledge of those things will not necessarily help you reason about your code, and at worst, may confuse newcomers by tempting them to apply analogies that don't hold. And to achieve that "look" for your language, you always end up giving it a really complex and inflexible syntax, whose users are not going to have any systematic knowledge of. (Do you know many people who can give you a BNF grammar for Java, or tell you the exact precedence rules for it?)

      Lisp makes no pretence at looking like English or mathematics. You're certainly expected to understand the syntax rules of the language more than in "friendlier" ones, but these rules are far, far simpler, and you can actually reason them through. Remember, Scheme oooks regularly include a section that shows you how to write a Scheme interpreter in one page of Scheme code; basic knowledge of how Scheme itself works is considered to be elementary Scheme knowledge.

      That is, what I'm saying is that compared to other languages, Lisp dialects demand that you understand the language itself far more, but this is a good thing, which will make you program way better. Why? Because you're going to be able to reason about the execution of your program far better than your average Java programmer.

      Plus, you can do macros.