I know Scheme is a dialect of Lisp. But I want know exactly the point(s) that distinguish(es) both from each other! It is tough for a newbie in this field to get a clear image without profound experiences. Any clue will be highly appreciated.
On Sat, 2 Dec 2000 12:58:53 -0800, "Frankque" <frank...@infinet.net> wrote:
>Hi! Guru here:
>I know Scheme is a dialect of Lisp. But I want know exactly the point(s) >that distinguish(es) both from each other! It is tough for a newbie in this >field to get a clear image without profound experiences. Any clue will be >highly appreciated.
The above-referenced paper self-identifies as a somewhat superficial overview, and while it has some interesting material, it's not remarkably to-the-point.
Here are some things I think are key differences between Lisp and Scheme:
(1) They have different goals.
Scheme values aesthetics over virtually all else. Common Lisp places aesthetics low on the totem pole.
Scheme values small size-of-language and ease-of-language-implementation. Common Lisp assumes that it's ok for the base language to be large and to take a while to implement, and that it's small size-of-program and ease-of-program-implementation that matters.
Scheme abhors redundancy of expression, so tends not to offer more than one way to do a particular thing. Common Lisp assumes it serves a varied community with a variety of programming styles and provides numerous options to allow the coresidence of people with varied tastes.
Scheme doesn't focus on implementation compatibility, and has historically virtually ignored "small differences" that might make for porting problems. Common Lisp focuses a great deal on language portability, specifying numerous ways of detecting subtle differences between implementation for ported programs trying to "get a foothold".
(2) They are specified differently.
Scheme has both an English text description of its semantics and a formal semantics. CL is specified in English text only.
(3) They have several highly visible differenes in the core language.
Scheme has call-with-current-continuation. Common Lisp does not. UNWIND-PROTECT enjoys a clear semantics in Common Lisp but is beyond the scope of the language in Scheme, at least partly becuase its semantics would be problematic in Scheme in the presence of call-with-current-continuation (and the first class continuations resulting from it).
Order of argument evaluation in Scheme is generally unspecified, whereas it is specified in Common Lisp.
Scheme function argument notations provide primitively only for "required" and "rest" arguments. There is no provision for individual "optional" arguments, nor for "keyword" arguments, both provided by Common Lisp.
Scheme has mandatory tail call elimination. Common Lisp does not.
Common Lisp separates programming units by "package" and Scheme by "module". Though these are often contrasted as if they attempt to solve the same problem, the two are in fact orthogonal. CL could have a module system, but chooses not to. Scheme could have a package system but chooses not to. Package systems separate references at the data level, independent of attached semantics. For example, the program (eq 'x:foo 'y:foo) illustrates a use of symbols that are not variables in a way that exploits the package system.
Scheme is a "Lisp1" (single variable namespace); Common Lisp has several namespaces, though is commonly called merely a "Lisp2" because of the focus on separation of function cells and value cells; in fact, Common Lisp also has separated namespaces for block tags and go tags. A consequence of the distinction in namespaces is the presence of (FUNCALL f ...) and (FUNCTION f) notations in Common Lisp, which are not present in Scheme. Another consequence of this is the need for a much more complicated macro system in Scheme, using macro hygiene to avoid problems that would otherwise be introduced by name clashes; largely these problems do not occur in Common Lisp because of the combined presence of its multiple namespaces and its package system, so a macro hygiene system, while it would be possible in CL is not in practice needed. Some also find the Scheme macro system elegant, although most admit it is less computationally powerful than the Common Lisp macro system.
A class system and condition system are well-integrated with Common Lisp, and are largely absent in Scheme.
(4) CL has a much larger library of functions and classes as part of the core language than does Scheme. The Scheme language intends such libraries to be optional add-ons. Whether this is a bug or a feature in either case appears to be a largely religious/political issue rather than a technical one.
Thanks for prompt replies. As says all materials that you presented, Common Lisp seems more useful in practical problem solving than does Scheme. Why do most universities in North America choose Scheme as their introduction course for computer science students? Of my understanding, it is the semantic simplicity and syntactical focus on aesthetics that makes Scheme easier to understand and a good object to grasp core concepts in programming. The more practically useful, the less self-evident a program language might have presented by itself because of too many trivial concerns about problems in the real world to shape a fine body in a pleasant way as what laboriously happens when people keep doing fitness daily. I used to be a strong believer in what Albert Einstein says: the truth must be the harmony between simplicity and righteousness. But I have been gradually conquered by the world that is full of trivial technologies and implementations. Am I right? I'm more than blurred at this time.
> The above-referenced paper self-identifies as a somewhat superficial overview, > and while it has some interesting material, it's not remarkably to-the-point.
> Here are some things I think are key differences between Lisp and Scheme:
> (1) They have different goals.
> Scheme values aesthetics over virtually all else. > Common Lisp places aesthetics low on the totem pole.
> Common Lisp assumes that it's ok for the base language to be large and > to take a while to implement, and that it's small size-of-program > and ease-of-program-implementation that matters.
> Scheme abhors redundancy of expression, so tends not to offer more than > one way to do a particular thing. > Common Lisp assumes it serves a varied community with a variety of > programming styles and provides numerous options to allow the coresidence > of people with varied tastes.
> Scheme doesn't focus on implementation compatibility, and has > historically virtually ignored "small differences" that might make > for porting problems. > Common Lisp focuses a great deal on language portability, specifying > numerous ways of detecting subtle differences between implementation > for ported programs trying to "get a foothold".
> (2) They are specified differently.
> Scheme has both an English text description of its semantics and > a formal semantics. > CL is specified in English text only.
> (3) They have several highly visible differenes in the core language.
> Scheme has call-with-current-continuation. Common Lisp does not. > UNWIND-PROTECT enjoys a clear semantics in Common Lisp but is beyond > the scope of the language in Scheme, at least partly becuase its > semantics would be problematic in Scheme in the presence of > call-with-current-continuation (and the first class continuations > resulting from it).
> Order of argument evaluation in Scheme is generally unspecified, > whereas it is specified in Common Lisp.
> Scheme function argument notations provide primitively only for > "required" and "rest" arguments. There is no provision for individual > "optional" arguments, nor for "keyword" arguments, both provided by > Common Lisp.
> Scheme has mandatory tail call elimination. Common Lisp does not.
> Common Lisp separates programming units by "package" and Scheme by > "module". Though these are often contrasted as if they attempt to > solve the same problem, the two are in fact orthogonal. CL could have > a module system, but chooses not to. Scheme could have a package system > but chooses not to. Package systems separate references at the data > level, independent of attached semantics. For example, the program > (eq 'x:foo 'y:foo) > illustrates a use of symbols that are not variables in a way that > exploits the package system.
> Scheme is a "Lisp1" (single variable namespace); Common Lisp has > several namespaces, though is commonly called merely a "Lisp2" because > of the focus on separation of function cells and value cells; in fact, > Common Lisp also has separated namespaces for block tags and go tags. > A consequence of the distinction in namespaces is the presence of > (FUNCALL f ...) and (FUNCTION f) notations in Common Lisp, which are > not present in Scheme. Another consequence of this is the need for a > much more complicated macro system in Scheme, using macro hygiene to > avoid problems that would otherwise be introduced by name clashes; > largely these problems do not occur in Common Lisp because of the > combined presence of its multiple namespaces and its package system, > so a macro hygiene system, while it would be possible in CL is not > in practice needed. Some also find the Scheme macro system elegant, > although most admit it is less computationally powerful than the > Common Lisp macro system.
> A class system and condition system are well-integrated with Common > Lisp, and are largely absent in Scheme.
> (4) CL has a much larger library of functions and classes as part of > the core language than does Scheme. The Scheme language intends > such libraries to be optional add-ons. Whether this is a bug or a > feature in either case appears to be a largely religious/political > issue rather than a technical one.
Kent M Pitman wrote in message ... >I don't mind that people teach people the relation between recursion and >iteration, but I do mind a LOT that they try to untrain them to think in >terms of standard iteration constructs and to think such things are dirty >in some way that tail recursion is blessed not to be. College courses should >teach "alternatives", not "dogma". And the Scheme community is, for whatever >reason, rich with dogma.
Kent, I am intruiged by your comment here. Don't you find that many of the conventional iteration techniques force the user to invent internal state variables that detract from the simplicity of what is being computed? I am coming at this question from the standpoint of the ML languages in which data are largely immutable, tail recursion is optimized and explicitly encouraged over iteration. OCaml allows conventional iteration but does not encourage its use.
"Frankque" <frank...@infinet.net> writes: > ... Why do most universities in North America choose Scheme as their > introduction course for computer science students?
It was specifically designed with teaching in mind. It doesn't have a lot of odd details to explain and is especially useful if you're teaching languages in broad brush strokes rather than at the fine detail. For example, if your goal is to teach "algorithms", it hardly matters which language you use other than in terms of grace of presentation. If your goal is to produce commercial quality code, what signals what error or where the branch cuts are drawn or details like that matter a lot more.
I know in particular at MIT when I was there (which is now 20 years ago), there was an explicit goal of NOT teaching any programming language but merely assuming you knew them or could learn them as needed. The idea was, again, to teach concepts not details. I think the design of Scheme and Structure and Interpetation of Computer Programs (S&ICP, the common teaching text) reflect this.
Note well that some implementations of Scheme are as detailed and commercial oriented as CL. However, I would personally say that this is due more to the individual commitment of the implementor than the language; I would almost go so far as to say these implementations succeed in spite of the basic spartan design of Scheme, rather than due to it. Of course, the Scheme designers will claim that it follows from their spartan design that such good implementations arise, but I doubt that is really true. Nothing about the Scheme spec especially suports a vendor in the creation of an efficient implementation. And, if I remember right, Steele at some point early on wrote a compiler for Scheme called "Cheapy", which turned out to produce code that ran slower compiled than interpreted... something that we might naively think of as "not possible" until we think about it, but that is in fact not a property of the universe, so much as a property of which product results people are willing to actually show their friends...
> Of my understanding, it is the > semantic simplicity and syntactical focus on aesthetics that makes Scheme > easier to understand and a good object to grasp core concepts in > programming.
Yes. And fortunately or unfortunately, really depending on how you look at it, these concepts it teaches you don't really map neatly onto what you can get in any other language. It stretches your thinking in interesting ways, and then the question of whether you can apply that usefully later is an open one. But then Lisp has some of that same character, just in different places. So I won't say that's an automatic negative. Just something to ponder.
> The more practically useful, the less self-evident a program > language might have presented by itself because of too many trivial concerns > about problems in the real world to shape a fine body in a pleasant way as > what laboriously happens when people keep doing fitness daily.
Hmm. I didn't quite resonate with that analogy, but I will say that it's really a personal preference issue what is aesthetic. The Scheme people often speak as if it's self-obvious that the smallest language is the most elegant, but I don't think that's really true. I think each language is like a set of axioms, arbitrarily chosen, and that the programs are like proofs--their nature follows from the axioms in search of a given goal.
I don't mind that people teach people the relation between recursion and iteration, but I do mind a LOT that they try to untrain them to think in terms of standard iteration constructs and to think such things are dirty in some way that tail recursion is blessed not to be. College courses should teach "alternatives", not "dogma". And the Scheme community is, for whatever reason, rich with dogma.
> I used to be > a strong believer in what Albert Einstein says: the truth must be the > harmony between simplicity and righteousness. But I have been gradually > conquered by the world that is full of trivial technologies and > implementations. Am I right? I'm more than blurred at this time.
I go with Aristotle and virtue ethics. That the virtues are the mid-points between extremes. In other terms, he was saying that if you just take a given design axis with negative infinity on one end and infinity on the other end, you just need to find the midpoint between those two infinities to be happy. The funny thing about infinities is that the midpoint doesn't have to be zero, and it's more the search for the midpoint than the fact of the midponit that is itself noble. Put another way, at the point where you stop seeking new ways to look at things and new values and ideas to accomodate, thinking you have the answer, it's at that point that you probably are starting to finally lose.
One of the things I like about CL's rough edges is how it accomodates multiple points of view without breaking the mold. There are some standard analogies which I'll misquote and someone will correct me on about APL being like a diamond--if you try to change it, it will shatter. Was it Perlis who said this? Lisp has been called (by Joel Moses?) a ball of mud--you can stick more mud to it and it will still be a ball of mud. There's some virtue in that, I think. Where you think Scheme sits in that space I suppose is open to interpretation...
"David McClain" <dmccl...@azstarnet.com> writes: > Kent M Pitman wrote in message ... > >I don't mind that people teach people the relation between recursion and > >iteration, but I do mind a LOT that they try to untrain them to think in > >terms of standard iteration constructs and to think such things are dirty > >in some way that tail recursion is blessed not to be. College courses > should > >teach "alternatives", not "dogma". And the Scheme community is, for > whatever > >reason, rich with dogma.
> Kent, I am intruiged by your comment here. Don't you find that many of the > conventional iteration techniques force the user to invent internal state > variables that detract from the simplicity of what is being computed?
Certainly it's true that sometimes they force the creation of extra syntax but my point is that linguistically, people already do that before they come to any computer language. Even non-programmers know what it means to say "For every setting at the table, make sure the napkin is arranged right". People are not taught "To set the table for some number of settings, first check if you are done and if not then check the first napkin is arranged right and then set the table for the rest of the settings." There are situations where recursion is good, and adds a lot. It should be in everyone's repertoire. But there are places where it's just unnatural, in that it does not mirror the way people talk.
> I am coming at this question from the standpoint of the ML languages > in which data are largely immutable, tail recursion is optimized and > explicitly encouraged over iteration.
The issue should just be syntactic. There should be no semantic issue here, and hence no speed issue.
> OCaml allows conventional iteration but does not encourage its use.
CL allows implementations to allow tail recursion, but does not require it work nor encourage its use.
In one way, it saddens me that CL doesn't require the optimization because I'd really like people to be able to use it when they can.
But on the other hand, I regard it almost as "remedial Scheme", snapping people out of barouque notations they have learned in Scheme class and forcing them to realize there are other ways of saying the same thing. Had they been taught the fact of "choice" in Scheme class, I'd gladly allow them that choice. But since they were taught dogma, it just pisses me off that they walk into a CL shop with a deathwish for perfectly perspicuous iteration constructs like dotimes and dolist, and even for some forms of loop (which I defend these days to a limited degree, though I recognize can sometimes get syntactically out of hand; for years I railed against LOOP because its syntax is idiosyncratic and it is sometimes opaque to debugging, but ultimately I could not argue with its abillity to capture and combine many useful idioms that were not made perspicuous in other syntaxes.)
* "Frankque" <frank...@infinet.net> | I know Scheme is a dialect of Lisp.
The Lisp that Scheme is a "dialect" of is akin to the Indo-European that both English and Swahili could be described as "dialects" of. These "dialects" have diverged so much it is now useless to think of the Lisp of which Scheme was supposedly a dialect as something that still exists. The Lisp community continued to evolve after Scheme split off to go their own way. Scheme is in my view much closer to a dialect of Algol with some Lisp heritage.
#:Erik -- "When you are having a bad day and it seems like everybody is trying to piss you off, remember that it takes 42 muscles to produce a frown, but only 4 muscles to work the trigger of a good sniper rifle." -- Unknown
Erik Naggum <e...@naggum.net> writes: > The Lisp that Scheme is a "dialect" of is akin to the Indo-European > that both English and Swahili could be described as "dialects" of.
For some value of Indo-European. Swahili is a Niger-Congo language that noone I'm familiar with has ever claimed any relationship to Indo-European for.
-- Lieven Marchand <m...@bewoner.dma.be> Lambda calculus - Call us a mad club
* Lieven Marchand <m...@bewoner.dma.be> | For some value of Indo-European. Swahili is a Niger-Congo language | that noone I'm familiar with has ever claimed any relationship to | Indo-European for.
Hence the last sentence, as in "dialect of Algol".
#:Erik -- "When you are having a bad day and it seems like everybody is trying to piss you off, remember that it takes 42 muscles to produce a frown, but only 4 muscles to work the trigger of a good sniper rifle." -- Unknown
> >I don't mind that people teach people the relation between recursion and > >teach "alternatives", not "dogma". And the Scheme community is, for > whatever > >reason, rich with dogma.
> And *this* in comp.lang.lisp! I just can't stop laughing! ;-)
> felix
> Laughing might be the side effect of the establishment of this forum;-(
Kent M Pitman wrote in message ... >allow them that choice. But since they were taught dogma, it just pisses >me off that they walk into a CL shop with a deathwish for perfectly >perspicuous iteration constructs like dotimes and dolist, and even for >some forms of loop (which I defend these days to a limited degree, though
Yes, I had forgotten about dolist and dotimes. I use these all the time, and they don't explicitly pepper the code with intermediate state variables. In this sense of iterative construct, I can definitely agree with their use as more direct and less opaque than accumulating tail recursive routines.
I work mostly with the code of other physicists and engineers... I wish more were taught in early programming courses about recursion, simply because the code I run into most that is absolutely nighmarish, is that where control vars are peppered throughout the code, and these are globals. In typical Fortran style, even Lisp produced by these folks has the same nightmarish quality. I would venture to say that most of the industrial and scientific community uses these poor practices and this is what accounts for their abysmal records with cost and schedule overruns on software projects.
I recently had the dubious pleasure of editing another scientist's Lisp code and porting it to a more modern dialect of Lisp. His penchant for using globals containing local state information makes it almost impossible to reproduce simply because it is difficult to track which functions step on these shared variables across the two-dozen or so modules of Lisp. Yechh!
Please, let's stop teaching Fortran as a first and only language, and start passing along a little more abstract reasoning, like functional closures, recursion, immutable global data, and so forth. Most scientists feel that they don't need to learn anything more about programming than what they learned as college freshmen. I find that a lot of Pysiciains and Attorneys also think this way. Hey, after all they got their Doctorates in whatever, what more is there worth learning?
>I don't mind that people teach people the relation between recursion and >teach "alternatives", not "dogma". And the Scheme community is, for whatever >reason, rich with dogma.
And *this* in comp.lang.lisp! I just can't stop laughing! ;-)
"felix" <fe...@anu.ie> writes: > Kent M Pitman wrote in message ...
> >I don't mind that people teach people the relation between > >recursion and teach "alternatives", not "dogma". And the > >Scheme community is, for whatever reason, rich with dogma.
> And *this* in comp.lang.lisp! I just can't stop laughing! ;-)
I'm afraid I'm missing a joke here. Is there some major piece of dogma being routinely pushed here that I'm not aware of? As with any community made of human beings, it's hard to generalize fully to say we always or never do a thing, but overall I'd say that this community is rich in tolerance for multiple ways to do a thing... certainly compared to most other language communities I can think of. If you disagree, I'd be fascinated to hear why.
>>>>> On 03 Dec 2000 17:57:44 +0100, Lieven Marchand ("Lieven") writes:
Lieven> Erik Naggum <e...@naggum.net> writes: >> The Lisp that Scheme is a "dialect" of is akin to the Indo-European >> that both English and Swahili could be described as "dialects" of.
Lieven> For some value of Indo-European. Swahili is a Niger-Congo language Lieven> that noone I'm familiar with has ever claimed any relationship to Lieven> Indo-European for.
Yes, Kiswahili is basically Bantu with some Arabic words (such as "Swahili", derived from the Arabic word for "coastal"!)
"David McClain" <dmccl...@azstarnet.com> writes: > I work mostly with the code of other physicists and engineers... I wish more > were taught in early programming courses about recursion, simply because the > code I run into most that is absolutely nighmarish
I guess my point is that some things "feel" recursive and should be expressed recursively. But some things "feel" iterative, and I don't see anything wrong with:
(loop for entry in some-list for name = (person-name entry) for age = (person-age entry) collect (list name age))
You can express this and many other things in terms of tail recursion, but I don't personally see the value of doing so. Even so, my point is that students should be taught that this kind of breakdown is just as acceptable as tail recursion. I do so tire of having to de-program Scheme converts from believing that only the Scheme-style
is acceptably clear. Among other things, this contains a lot of verbiage which is subprimitive to what's being accomplished, such as the need to maintain an extra loop variable for the list being traversed, and another for the result being accumulated, not to mention the programmer having to know the stupid trick about consing up a list backward and then reversing it, which though good "world knowledge" for a programmer to have really isn't relevant to the domain task at hand. And, of course, Common Lisp doesn't have tail recursion elimination, so to avoid possible stack overflow in the case of long lists, the Scheme loop above would have to at least be rewritten using DO (which is effectively a sugaring of a tail recursive loop). But LOOP hides these "implementation level" extra variables, the knowledge of accumulation tricks, and certain potential "stack" issues and other traversal strategy issues in a way that I have over time come to agree with LOOP proponents is expressionally important.
So in a sense, I think Lisp is closer than Scheme to your stated goal of avoiding places where "where control vars are peppered throughout the code".
* "David McClain" <dmccl...@azstarnet.com> | I recently had the dubious pleasure of editing another scientist's | Lisp code and porting it to a more modern dialect of Lisp. His | penchant for using globals containing local state information makes it | almost impossible to reproduce simply because it is difficult to track | which functions step on these shared variables across the two-dozen or | so modules of Lisp. Yechh!
Some Common Lisp environments come with a cross referencing facility that allows you to query the system for all such references, such as Allegro CL from Franz Inc. It doesn't take the pain of dealing with such code away, but you can at least retain control over it.
#:Erik -- "When you are having a bad day and it seems like everybody is trying to piss you off, remember that it takes 42 muscles to produce a frown, but only 4 muscles to work the trigger of a good sniper rifle." -- Unknown
In article <sfwk89gsjti....@world.std.com>, Kent M Pitman <pit...@world.std.com> wrote:
>Among other things, this contains a lot of verbiage >which is subprimitive to what's being accomplished, such as the need >to maintain an extra loop variable for the list being traversed, and another >for the result being accumulated, not to mention the programmer having to >know the stupid trick about consing up a list backward and then reversing it, >which though good "world knowledge" for a programmer to have really isn't >relevant to the domain task at hand.
There is a quite antient technique that allows one to build up a list left-to-right in one pass, at the constant overhead of just a couple of extra conses. Nobody seems to use it though and it isn't even mentioned in textbooks anymore. I think I saw it in an old book by Wilensky or Touretzky?
> There is a quite antient technique that allows one to > build up a list left-to-right in one pass, at the > constant overhead of just a couple of extra conses. > Nobody seems to use it though and it isn't even > mentioned in textbooks anymore. I think I saw it in an > old book by Wilensky or Touretzky?
* Dorai Sitaram | There is a quite antient technique that allows one to | build up a list left-to-right in one pass, at the | constant overhead of just a couple of extra conses.
| Nobody seems to use it though and it isn't even mentioned in textbooks | anymore.
Well, it has naturally become macrofied because it _is_ quite hairy and intrusive to write manually every time. Software patterns notwithstanding, some things are just better off being macros.
| I think I saw it in an old book by Wilensky or Touretzky?
I have only seen it explained. The coding seems to vary according to the specific needs of the body of the loop.
#:Erik -- "When you are having a bad day and it seems like everybody is trying to piss you off, remember that it takes 42 muscles to produce a frown, but only 4 muscles to work the trigger of a good sniper rifle." -- Unknown
> Even non-programmers know > what it means to say "For every setting at the table, make sure the > napkin is arranged right".
This can be expressed functionally in Scheme using map (like mapcar in CL). It's not necessary to use iteration.
Harvey and Wright's textbook Simply Scheme makes this point. They introduce higher-order functions before recursion.
--
Jonathan Jacky j...@radonc.washington.edu Radiation Oncology, Box 356043 voice: (206)-598-4117 University of Washington FAX: (206)-598-6218 Seattle, Washington 98195-6043 USA
> Indeed, the Scheme community has outright shunned the creation of standard > terminology in the language, preferring that it be added elsewhere. In so > doing, and in not creating itself a useful library that is part of the > standard, it must stand the criticism that comes from not including this > stuff, just as we must stand the criticism that they levy for our having > included it.
That is a valid criticism. But most of the `industrial' Scheme implementations (like MIT Scheme, T, or MzScheme) provided a much richer set of tools. They didn't think such tools should be part of the language spec for Scheme in general.
> I think one of the greatest strengths of CL is not that it makes in any way > the best decision of how to standardize certain facilities, since there can > be no uniquely determined best (and this is why Scheme is forever at an > impassible barrier, waiting for consensus on the "right" way to do things, > when no right way can ever exist), but rather the strength of CL is that > it has the guts to recognize the need for arbitrary choices as a way of forging > forward. It's the willingness to suffer the slings and arrows that come > from having to defend what cannot be defended that allows programmers on a > dailiy basis to consider numerous issues settled in CL, while those same > issues continue to occupy many Scheme programmers' time just because the > language wouldn't take a stand.
Scheme is mostly a `research' and `teaching' language. It isn't so much that Scheme people are afraid of taking a stand, or can't come to a consensus, but more that by excising minutae from the language, it becomes easier to reason about it, redesign it, and experiment.
These are not the goals of Common Lisp.
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =-----
>> I work mostly with the code of other physicists and >> engineers... I wish more were taught in early programming >> courses about recursion, simply because the code I run into >> most that is absolutely nighmarish
Kent> I guess my point is that some things "feel" recursive and should Kent> be expressed recursively. But some things "feel" iterative, and Kent> I don't see anything wrong with:
Kent> (loop for entry in some-list Kent> for name = (person-name entry) Kent> for age = (person-age entry) Kent> collect (list name age))
Kent> You can express this and many other things in terms of tail Kent> recursion, but I don't personally see the value of doing so. Kent> Even so, my point is that students should be taught that this Kent> kind of breakdown is just as acceptable as tail recursion. I do Kent> so tire of having to de-program Scheme converts from believing Kent> that only the Scheme-style
Kent> Among other things, this contains a lot of verbiage which is Kent> subprimitive to what's being accomplished, such as the need to Kent> maintain an extra loop variable for the list being traversed, Kent> and another for the result being accumulated, not to mention the Kent> programmer having to know the stupid trick about consing up a Kent> list backward and then reversing it, which though good "world Kent> knowledge" for a programmer to have really isn't relevant to the Kent> domain task at hand. And, of course, Common Lisp doesn't have Kent> tail recursion elimination, so to avoid possible stack overflow Kent> in the case of long lists, the Scheme loop above would have to Kent> at least be rewritten using DO (which is effectively a sugaring Kent> of a tail recursive loop). But LOOP hides these "implementation Kent> level" extra variables, the knowledge of accumulation tricks, Kent> and certain potential "stack" issues and other traversal Kent> strategy issues in a way that I have over time come to agree Kent> with LOOP proponents is expressionally important.
Kent> So in a sense, I think Lisp is closer than Scheme to your stated Kent> goal of avoiding places where "where control vars are peppered Kent> throughout the code".
I certainly agree with you that the "feel" of the LOOP-based version of this is _vastly_ nicer than the "hand-coded tail recursion."
I would suggest the thought that the popularity of the latter falls out of three considerations:
a) Scheme is presented as an academic language, and the quality of teaching will not be uniformly wonderful.
It is *certainly* going to be used as a tool for teaching recursion; a _good_ course might move on to present iteration, but would do so as a secondary matter. "Questionable" courses may never get around to indicating that you can represent structures in an iterative way. Only an *excellent* course would promote the equality of iteration and recursion.
b) Presentation of _both_ iteration and recursion and the "software engineering" side requires more time than may get devoted to Scheme.
In a brief two week module on "Lisp," it's hard to get past the prejudices of Lisp being basically about recursion and lists.
Moving on to a _truly_ fuller view takes further time.
c) Macros aren't crucial to Scheme the same way they are to Common Lisp.
This too is related to a) and b); a shallow examination of "Lisp," in _whatever_ form, won't get around to the relatively advanced topic of macros.
Schemely support for macros is not uniform, and there are a couple of competing macro systems. On the one hand, this does not encourage their use. On the other hand, it does not encourage usage of facilities that _require_ their use. [LOOP being the "pathological" example of this...]
In contrast, CL implements a considerable chunk of the language via macros, and the notion of the language being extensible comes from this.
It's only the most ambitious of academic presentations that would get into macros in either Lisp variation; the lack of extensive extensions in Scheme that use macros have the result that there's a fair bit of "starting from scratch" that would result. -- (concatenate 'string "cbbrowne" "@hex.net") <http://www.ntlug.org/~cbbrowne/macros.html> All ITS machines now have hardware for a new machine instruction -- XOI Execute Operator Immediate. Please update your programs.
> Btw, didn't Interlisp have some operator that encapsulated this better > linguistically? I never programmed in Interlisp, but vaguely recall > something called TCONC or something ("tail conc") which I think required > some kind of setup in order to be used. No manual here so can't check.
Interlisp had two such functions. There was TCONC which would listify and NCONC an item to the end of a TCONC structure, and LCONC which would NCONC lists to the end of a TCONC structure. Calling TCONC (and IIRC, LCONC) with no arguments would initialize a the structure.