From: javuchi
Subject: Free book for converting my C mind?
Date: 
Message-ID: <m2smhbrbc5.fsf@servidor.kalandra>
I'm wondering if there is somewhere a book which teaches me how to write
correct Lisp code, taking in consideration that I have used C/C++ for years.

I have found these ones, but none of them really helped me to transform my
mind:

http://www-2.cs.cmu.edu/~dst/LispBook/index.html
http://psg.com/~dlamkins/sl/contents.html

I'm looking for something more concrete, with lot of examples showing the
true difference between implementing algorithms/problems in C and Lisp.

Perhaps what I need is to actually start coding in Lisp, but I'm afraid of
doing it incorrectly, as I'm still thinking about for, while, pointers, etc.
Perhaps somebody here could tell me how he/she made his/her transition to
Lisp, just to take note and apply myself.

Note: I'm not interested in non free books, as I don't pretend (yet) to use
Lisp at work.

-- 
�� javuchi ��

From: Artie Gold
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <c0pi1m$16es5d$1@ID-219787.news.uni-berlin.de>
javuchi wrote:
> I'm wondering if there is somewhere a book which teaches me how to write
> correct Lisp code, taking in consideration that I have used C/C++ for years.
> 
> I have found these ones, but none of them really helped me to transform my
> mind:
> 
> http://www-2.cs.cmu.edu/~dst/LispBook/index.html
> http://psg.com/~dlamkins/sl/contents.html
> 
> I'm looking for something more concrete, with lot of examples showing the
> true difference between implementing algorithms/problems in C and Lisp.
> 
> Perhaps what I need is to actually start coding in Lisp, but I'm afraid of
> doing it incorrectly, as I'm still thinking about for, while, pointers, etc.
> Perhaps somebody here could tell me how he/she made his/her transition to
> Lisp, just to take note and apply myself.
> 
> Note: I'm not interested in non free books, as I don't pretend (yet) to use
> Lisp at work.
> 
http://lib1.store.vip.sc5.yahoo.com/lib/paulgraham/onlisp.pdf

Enjoy.

HTH,
--ag

-- 
Artie Gold -- Austin, Texas

"Yeah. It's an urban legend. But it's a *great* urban legend!"
From: Mario S. Mommer
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <fzfzdbp11y.fsf@germany.igpm.rwth-aachen.de>
Artie Gold <·········@austin.rr.com> writes:
> http://lib1.store.vip.sc5.yahoo.com/lib/paulgraham/onlisp.pdf

That one is good, but not for a newbie. It has the potential of
confusing people.
From: Ari Johnson
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <Eu8Yb.62396$P17.48942@fed1read03>
Mario S. Mommer wrote:
> Artie Gold <·········@austin.rr.com> writes:
> 
>>http://lib1.store.vip.sc5.yahoo.com/lib/paulgraham/onlisp.pdf
> 
> 
> That one is good, but not for a newbie. It has the potential of
> confusing people.

I beg to differ.  I'm somewhat new to Lisp (I know the syntax and know 
functional programming, but have not used Lisp a whole lot) and am 
currently halfway through On Lisp.  Even the introduction was helpful on 
the road to thinking in Lisp.  Then again, I am fluent in oodles of 
other languages and several programming paradigms, so maybe that helps 
make the switch into Lisp mindset easier. :)
From: javuchi
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <m2d68fhv6j.fsf@servidor.kalandra>
Mario S. Mommer <········@yahoo.com> writes:

> Artie Gold <·········@austin.rr.com> writes:
> > http://lib1.store.vip.sc5.yahoo.com/lib/paulgraham/onlisp.pdf
> 
> That one is good, but not for a newbie. It has the potential of
> confusing people.

I'll try to read it anywhere, after reading the Peter's one.
Thanks.

-- 
�� javuchi ��
From: Peter Seibel
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <m3smhbtwjw.fsf@javamonkey.com>
javuchi <······@nospam.com> writes:

> I'm wondering if there is somewhere a book which teaches me how to
> write correct Lisp code, taking in consideration that I have used
> C/C++ for years.

While I don't intend to actually offer side-by-side Lisp vs X
comparisons, my book-in-progress is targeted at folks like you: people
who are already competent programmers in some other language. The
first dozen chapters are available at:

  <http://www.gigamonkeys.com/book/>

I'd be interested in any feedback you have about whether this is
useful to you or not.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Billy O'Connor
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <873c9bttpz.fsf@dps11.gnuyork.org>
Peter Seibel <·····@javamonkey.com> writes:

> javuchi <······@nospam.com> writes:
>
>> I'm wondering if there is somewhere a book which teaches me how to
>> write correct Lisp code, taking in consideration that I have used
>> C/C++ for years.
>
> While I don't intend to actually offer side-by-side Lisp vs X
> comparisons, my book-in-progress is targeted at folks like you: people
> who are already competent programmers in some other language. The
> first dozen chapters are available at:
>
>   <http://www.gigamonkeys.com/book/>
>
> I'd be interested in any feedback you have about whether this is
> useful to you or not.

I really like your "3. PRACTICAL: A Simple Database" chapter.  Very
cool stuff.
From: javuchi
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <m2hdxrhxbb.fsf@servidor.kalandra>
Billy O'Connor <·······@gnuyork.org> writes:

> > I'd be interested in any feedback you have about whether this is
> > useful to you or not.
> 
> I really like your "3. PRACTICAL: A Simple Database" chapter.  Very
> cool stuff.

Me too. I'm just starting to read it, although I have visited some chapters at
a glance and find really interesting.
Peter, I'll send you my feedback once I sit down and start to read the book and
try the examples. (Elsewhere, take in consideration that my English is not
perfect and I wont be able to recognize writing correctness).

-- 
�� javuchi ��
From: Rob Giardina
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <I5cYb.36$Wp3.224@news.oracle.com>
>   <http://www.gigamonkeys.com/book/>


Is this available in PDF format? I'd like to dig in but staying online is a
bother.
From: Peter Seibel
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <m3ptcesj32.fsf@javamonkey.com>
"Rob Giardina" <········@oracle.com> writes:

> >   <http://www.gigamonkeys.com/book/>
> 
> 
> Is this available in PDF format? I'd like to dig in but staying
> online is a bother.

I'm working on it, using cl-typesetting. Unfortunately there are still
a few things to straighten out relative to the HTML version. In the
meantime, the HTML prints fairly well (if you want paper) and you can
always save the pages locally if you just want to read it offline.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Bruce Stephens
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <87r7wu32mw.fsf@cenderis.demon.co.uk>
Peter Seibel <·····@javamonkey.com> writes:

[...]

> I'm  working on  it, using  cl-typesetting. Unfortunately  there are
> still  a  few  things  to   straighten  out  relative  to  the  HTML
> version. In the  meantime, the HTML prints fairly  well (if you want
> paper) and you can always save the pages locally if you just want to
> read it offline.

HTMLDOC, <http://www.easysw.com/htmldoc/>, can produce PDF from html
files.  Doubtless there are other programs that can do this too.
From: Robert St. Amant
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <lpn7jyleo5z.fsf@haeckel.csc.ncsu.edu>
Bruce Stephens <············@cenderis.demon.co.uk> writes:

> Peter Seibel <·····@javamonkey.com> writes:
> 
> [...]
> 
> > I'm  working on  it, using  cl-typesetting. Unfortunately  there are
> > still  a  few  things  to   straighten  out  relative  to  the  HTML
> > version. In the  meantime, the HTML prints fairly  well (if you want
> > paper) and you can always save the pages locally if you just want to
> > read it offline.
> 
> HTMLDOC, <http://www.easysw.com/htmldoc/>, can produce PDF from html
> files.  Doubtless there are other programs that can do this too.

Here's a link that lets you give it a try, without downloading any
software:

           <http://www.easysw.com/htmldoc/pdf-o-matic.php>

-- 
Rob St. Amant
http://www4.ncsu.edu/~stamant
From: javuchi
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <m2vfm68si4.fsf@servidor.kalandra>
"Rob Giardina" <········@oracle.com> writes:

> >   <http://www.gigamonkeys.com/book/>
> Is this available in PDF format? I'd like to dig in but staying online is a
> bother.

You can download the entire book in html:

http://www.gigamonkeys.com/book/book.html


-- 
�� javuchi ��
From: chairam
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <pfo4305dskhcrno7is0kqmaj3phn0up60g@4ax.com>
>> I'm wondering if there is somewhere a book which teaches me how to
>> write correct Lisp code, taking in consideration that I have used
>> C/C++ for years.
>
>While I don't intend to actually offer side-by-side Lisp vs X
>comparisons, my book-in-progress is targeted at folks like you: people
>who are already competent programmers in some other language. The
>first dozen chapters are available at:
>
>  <http://www.gigamonkeys.com/book/>
>
>I'd be interested in any feedback you have about whether this is
>useful to you or not.

I'm reading it

VERY interesting!!

Bye
Chairam
From: Steven M. Haflich
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <JRYXb.25875$7j2.9810@newssvr25.news.prodigy.com>
javuchi wrote:

> I'm looking for something more concrete, with lot of examples showing the
> true difference between implementing algorithms/problems in C and Lisp.
> 
> Perhaps what I need is to actually start coding in Lisp, but I'm afraid of
> doing it incorrectly, as I'm still thinking about for, while, pointers, etc.
> Perhaps somebody here could tell me how he/she made his/her transition to
> Lisp, just to take note and apply myself.

To become proficient in a language it probably is necessary to learn the
details of the language the way typically taught by a programming text,
but this isn't sufficient to become a natural speaker of that language,
one who can express himself idiomatically in that language.  In other
words, it is dangerously easy to learn to write C programs in Lisp.

In olden days one would learn a new skill by apprenticing to a master,
or at least studying with one.  This still works, but for computing
languages shortcuts are possible.  The best way to learn a language
(after the rote basics) is by learning some existing, large program and
extending it in some way.  There is a whole generation of Unix/C
programmers (I was one) who learned Unix and C by adding sometimes-silly
features or extensions to Unix commands, or even to the kernel.  That
way one is automatically working with medium or large programs, programs
that usually start as well written examples of their programming idiom.

There is a whole new generation of Linux hackers who learned this same
way.

It is possible to do the same in Common Lisp by finding some large,
well-written program of interest, learning it, and extending it in
some way.  That automatically teaches you to use idiomatic macrology
or CL OOP in ways that one-page examples in a book can never teach.

Unfortunately, this available candidate systems are much fewer than
for the *nix/C world, but there exist examples.  I imagine one could
even learn a lot playing with the insides of the CMUCL implementation.
From: Raymond Tam
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <19828935.0402162212.291573d2@posting.google.com>
"Steven M. Haflich" <·················@alum.mit.edu> wrote in message 
>   The best way to learn a language
> (after the rote basics) is by learning some existing, large program and
> extending it in some way. 


could your recommend some large system for study/extends purpose ?
From: Tayssir John Gabbour
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <866764be.0402160912.1bc507c0@posting.google.com>
javuchi <······@nospam.com> wrote in message news:<··············@servidor.kalandra>...
> I'm wondering if there is somewhere a book which teaches me how to write
> correct Lisp code, taking in consideration that I have used C/C++ for years.
> 
> I have found these ones, but none of them really helped me to transform my
> mind:
[...]
> Perhaps what I need is to actually start coding in Lisp, but I'm afraid of
> doing it incorrectly, as I'm still thinking about for, while, pointers, etc.
> Perhaps somebody here could tell me how he/she made his/her transition to
> Lisp, just to take note and apply myself.

I'll go out on a limb and suggest the lectures and book at:
http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/

Other video lectures at:
http://www.aduni.org/courses/sicp/

It's not Common Lisp.  It's Scheme, without macros or i/o.  However it
is a way to break out of C-like mindset.  I might have preferred to
recommend Norvig's PAIP, because there you do learn "lisp", but that
fails your requirement of being free.

Basically what you'll learn is functional programming and some models
of how a lisp works.  Intro compsci stuff.  It's how I learned lisp,
and you should be warned that they present a beautiful Scheme, but a
castrated one.  You have about zero control over syntax.  (Except when
you extend their 20-line Scheme.)  When they talk about "building a
language", they're talking about doing it with just functions and not
syntactic transformations.

Still, I think people are going to find all sorts of opinions and
potholes, so that's no reason to dismiss information.  After all, one
big problem is apparently lispers who use macros for every little
thing.  And macro writers need to learn about variable capture.  So
it's useful to learn how to use functions.  And the discussion of lisp
models is second to no other intro.  Just be warned that while the
Scheme you see is pretty and seems deep, it has none of the at times
insane depth and beauty of a real lisp.
From: Pascal Bourguignon
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <87znbikj1r.fsf@thalassa.informatimago.com>
···········@yahoo.com (Tayssir John Gabbour) writes:
> I'll go out on a limb and suggest the lectures and book at:
> http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/
> 
> Other video lectures at:
> http://www.aduni.org/courses/sicp/
> 
> It's not Common Lisp.  It's Scheme, without macros or i/o.  However it
> is a way to break out of C-like mindset.  I might have preferred to
> recommend Norvig's PAIP, because there you do learn "lisp", but that
> fails your requirement of being free.
> 
> Basically what you'll learn is functional programming and some models
> of how a lisp works.  Intro compsci stuff.  It's how I learned lisp,
> and you should be warned that they present a beautiful Scheme, but a
> castrated one.  You have about zero control over syntax.  (Except when
> you extend their 20-line Scheme.)  When they talk about "building a
> language", they're talking about doing it with just functions and not
> syntactic transformations.
> 
> Still, I think people are going to find all sorts of opinions and
> potholes, so that's no reason to dismiss information.  After all, one
> big problem is apparently lispers who use macros for every little
> thing.  And macro writers need to learn about variable capture.  So
> it's useful to learn how to use functions.  And the discussion of lisp
> models is second to no other intro.  Just be warned that while the
> Scheme you see is pretty and seems deep, it has none of the at times
> insane depth and beauty of a real lisp.

I recommend it too.  Of  course, scheme, like pascal, is a pedagogical
gimmick,  but that  should  not  prevent anybody  to  learn from  this
course.  A  good exercice would  be to translate all  scheme exercices
into Common-Lisp :-)

-- 
__Pascal_Bourguignon__                     http://www.informatimago.com/
There is no worse tyranny than to force a man to pay for what he doesn't
want merely because you think it would be good for him.--Robert Heinlein
http://www.theadvocates.org/
From: Rahul Jain
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <87n07i5key.fsf@nyct.net>
Pascal Bourguignon <····@thalassa.informatimago.com> writes:

> I recommend it too.  Of  course, scheme, like pascal, is a pedagogical
> gimmick,  but that  should  not  prevent anybody  to  learn from  this
> course.  A  good exercice would  be to translate all  scheme exercices
> into Common-Lisp :-)

From the footnotes, that seems to be exactly what PAIP does. (Of course,
the implementation goals in PAIP are also translated into more
CL-oriented ones.)

:)

-- 
Rahul Jain
·····@nyct.net
Professional Software Developer, Amateur Quantum Mechanicist
From: javuchi
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <m2smhae2ml.fsf@servidor.kalandra>
Pascal Bourguignon <····@thalassa.informatimago.com> writes:

> I recommend it too.  Of  course, scheme, like pascal, is a pedagogical
> gimmick,  but that  should  not  prevent anybody  to  learn from  this
> course.  A  good exercice would  be to translate all  scheme exercices
> into Common-Lisp :-)


A translation:

(define (a) (+ 5 5))  ->   (defun a () (+ 5 5))

but what is the translation for:

(define a (+ 5 5))


-- 
�� javuchi ��
From: Rob Warnock
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <E7mdnSv3fLlAma_dXTWc-g@speakeasy.net>
javuchi  <······@nospam.com> wrote:
+---------------
| A translation:
|  (define (a) (+ 5 5))  ->   (defun a () (+ 5 5))
| but what is the translation for:
|  (define a (+ 5 5))
+---------------

Depending on the context in which you're asking, the answer is either:

1. Pick one of these, depending on how it's going to be used, and
   what you want to happen when the statement is executed again
   (e.g., if the source file is reloaded):

      (defvar *a* (+ 5 5))
      (defparameter *a* (+ 5 5))
      (defconstant +a+ (+ 5 5))

2. There isn't any translation, not directly, since ANSI Common Lisp
   doesn't provide global lexical variables, though from time to time
   suggestions have been voiced[1] about using a DEFINE-SYMBOL-MACRO hack
   to get the same effect. In the latter case, one translation might be:

      (deflexical a (+ 5 5))


-Rob

[1] Including me, but lately I've been having some problems with
    my DEFLEX macro in CMUCL. I need to investigate a bit further,
    but it looks like the symbol macro isn't being properly shadowed
    in some cases by a subsequent lexical binding. [The problem seems
    to arise when the inner lexical variable is used by a SETF-expander
    such as INCF.] "Film at 11..."

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Joe Marshall
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <lln29jmu.fsf@comcast.net>
javuchi <······@nospam.com> writes:

> Pascal Bourguignon <····@thalassa.informatimago.com> writes:
>
>> I recommend it too.  Of  course, scheme, like pascal, is a pedagogical
>> gimmick,  but that  should  not  prevent anybody  to  learn from  this
>> course.  A  good exercice would  be to translate all  scheme exercices
>> into Common-Lisp :-)
>
>
> A translation:
>
> (define (a) (+ 5 5))  ->   (defun a () (+ 5 5))
>
> but what is the translation for:
>
> (define a (+ 5 5))

Very roughly:  (defvar *a* (+ 5 5))

-- 
~jrm
From: Marco Antoniotti
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <YhqYb.36$IJ5.6191@typhoon.nyu.edu>
javuchi wrote:
> Pascal Bourguignon <····@thalassa.informatimago.com> writes:
> 
> 
>>I recommend it too.  Of  course, scheme, like pascal, is a pedagogical
>>gimmick,  but that  should  not  prevent anybody  to  learn from  this
>>course.  A  good exercice would  be to translate all  scheme exercices
>>into Common-Lisp :-)
> 
> 
> 
> A translation:
> 
> (define (a) (+ 5 5))  ->   (defun a () (+ 5 5))
> 
> but what is the translation for:
> 
> (define a (+ 5 5))
> 

	(defvar a (+ 5 5))

or

	(defparameter a (+ a a))

There is a difference between the two that appears only when you take 
into account file loading.  The semantics of DEFVAR and DEFPARAMETER is 
also different from Scheme: they define `special' variables, i.e. 
dynamically scoped variables.  It is a reflection of the fact that 
Common Lisp is a full blown language and not a toy (albeit a very 
interesting one) :)

Cheers
--
Marco
From: Marco Antoniotti
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <9jqYb.37$IJ5.6191@typhoon.nyu.edu>
javuchi wrote:

> Pascal Bourguignon <····@thalassa.informatimago.com> writes:
> 
> 
>>I recommend it too.  Of  course, scheme, like pascal, is a pedagogical
>>gimmick,  but that  should  not  prevent anybody  to  learn from  this
>>course.  A  good exercice would  be to translate all  scheme exercices
>>into Common-Lisp :-)
> 
> 
> 
> A translation:
> 
> (define (a) (+ 5 5))  ->   (defun a () (+ 5 5))
> 
> but what is the translation for:
> 
> (define a (+ 5 5))
> 

Since we are at it... :)

What is the translation in Scheme of the Common Lisp

	(defstruct foo
	   (a 42 :type integer)
	   (b "foo" :type string))

Cheers
--
Marco
From: Joe Marshall
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <1xotg0cp.fsf@ccs.neu.edu>
Marco Antoniotti <·······@cs.nyu.edu> writes:

> Since we are at it... :)
>
> What is the translation in Scheme of the Common Lisp
>
> 	(defstruct foo
> 	   (a 42 :type integer)
> 	   (b "foo" :type string))

Very roughly:

In MzScheme:
  (define-struct foo
    (a
     b))


In MIT Scheme:
  (define-structure foo
    (a 42)
    (b "foo"))
From: Kaz Kylheku
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <cf333042.0402181250.6ed99876@posting.google.com>
Joe Marshall <···@ccs.neu.edu> wrote in message news:<············@ccs.neu.edu>...
> Marco Antoniotti <·······@cs.nyu.edu> writes:
> 
> > Since we are at it... :)
> >
> > What is the translation in Scheme of the Common Lisp
> >
> > 	(defstruct foo
> > 	   (a 42 :type integer)
> > 	   (b "foo" :type string))
> 
> Very roughly:
> 
> In MzScheme:
>   (define-struct foo
>     (a
>      b))
> 
> 
> In MIT Scheme:
>   (define-structure foo
>     (a 42)
>     (b "foo"))

Which brings up more questions: what is the translation in Scheme of
the Common Lisp:

  #+foo (expr ...)
  
  #+bar (expr ...)

Such a thing could be used to write both versions in one source file
so that it works with MzScheme or MIT Scheme.

I see that Kawa Scheme has a cond-expand syntax for this, but that
doesn't do you any good if you want to target other Schemes.
From: Jens Axel Søgaard
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <4033fcc4$0$243$edfadb0f@dread12.news.tele.dk>
Kaz Kylheku wrote:

> Which brings up more questions: what is the translation in Scheme of
> the Common Lisp:
> 
>   #+foo (expr ...)
>   
>   #+bar (expr ...)
> 
> Such a thing could be used to write both versions in one source file
> so that it works with MzScheme or MIT Scheme.
> 
> I see that Kawa Scheme has a cond-expand syntax for this, but that
> doesn't do you any good if you want to target other Schemes.

Perhaps SRFI 0

     <http://srfi.schemers.org/srfi-0/srfi-0.html>

or SRFI 7:

     <http://srfi.schemers.org/srfi-7/srfi-7.html>

-- 
Jens Axel S�gaard
From: Kenny Tilton
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <E3rYb.42687$Lp.41715@twister.nyc.rr.com>
Marco Antoniotti wrote:

> 
> 
> javuchi wrote:
> 
>> Pascal Bourguignon <····@thalassa.informatimago.com> writes:
>>
>>
>>> I recommend it too.  Of  course, scheme, like pascal, is a pedagogical
>>> gimmick,  but that  should  not  prevent anybody  to  learn from  this
>>> course.  A  good exercice would  be to translate all  scheme exercices
>>> into Common-Lisp :-)
>>
>>
>>
>>
>> A translation:
>>
>> (define (a) (+ 5 5))  ->   (defun a () (+ 5 5))
>>
>> but what is the translation for:
>>
>> (define a (+ 5 5))
>>
> 
> Since we are at it... :)
> 

This gives me an idea. I haven't added a new library to Cello in a 
couple of weeks now. I could brag about Cello supporting Supercollider, 
but first I have to port a PLT Scheme/Linux project to ANSI CL. Now I 
see that all I have to do is post the Scheme project to CL and ask for 
its translation!

Now if only I could unpack that frickin BZ2 distro with one of my win32 
zip utils. Hang on, why should I do all the work?

What is the CL translation for this Scheme code?:

     http://www.alphalink.com.au/~rd/

You know, I should look at Rick Taube's project. It ships as Scheme, but 
if you want to load it into CL there is some macrology available to 
handle that. Hmmm....

kenny



-- 
http://tilton-technology.com

Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film

Your Project Here! http://alu.cliki.net/Industry%20Application
From: Rob Warnock
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <Ts6dne2ZXIJtuK7dXTWc-g@speakeasy.net>
Marco Antoniotti  <·······@cs.nyu.edu> wrote:
+---------------
| Since we are at it... :)
| What is the translation in Scheme of the Common Lisp
| 	(defstruct foo
| 	   (a 42 :type integer)
| 	   (b "foo" :type string))
+---------------

As in the other example, it depends on what you restrict yourself to:

1. For either IEEE Scheme [IEEE Std. 1178-1990 (R2002)] or
   R5RS Scheme (1998): There is no translation. Standard Schemes
   do not include structures.

2. Specific implementation extensions: Many, various, idiosyncratic,
   some with typing and some not.

   For example, PLT DrScheme/MzScheme provides both simple untyped-slot
   structures <URL:http://download.plt-scheme.org/doc/206p1/html/mzscheme/
   mzscheme-Z-H-4.html>, for which the translation would be as follows
   [not shown is the single-inheritance case, where the first arg is a
   two-element list]:

	(define-struct foo a b)

   and typed-slot structures <URL:http://download.plt-scheme.org/doc/
   206p1/html/mzscheme/mzscheme-Z-H-4.html> with some "property" stuff
   I really don't understand, but if you define your own accessors you
   can associate an optional "guard-proc", which:

	...is called by make-struct-type before attaching the property
	to a new structure type. ... To reject a property association
	(e.g., because the value supplied to make-struct-type is
	inappropriate for the property), the guard can raise an exception.
	...

   Maybe that can be used to enforce slot value typing, I dunno...


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Rob Warnock
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <Ts6dne-ZXIJyta7dXTWc-g@speakeasy.net>
Marco Antoniotti  <·······@cs.nyu.edu> wrote:
+---------------
| Since we are at it... :)
| What is the translation in Scheme of the Common Lisp
| 	(defstruct foo
| 	   (a 42 :type integer)
| 	   (b "foo" :type string))
+---------------

As in the other example, it depends on what you restrict yourself to:

1. For either IEEE Scheme [IEEE Std. 1178-1990 (R2002)] or
   R5RS Scheme (1998): There is no translation. Standard Schemes
   do not include structures.

2. Specific implementation extensions: Many, various, idiosyncratic,
   some with typing and some not.

   For example, PLT DrScheme/MzScheme provides both simple untyped-slot
   structures <URL:http://download.plt-scheme.org/doc/206p1/html/mzscheme/
   mzscheme-Z-H-4.html>, for which the translation would be as follows
   [not shown is the single-inheritance case, where the first arg is a
   two-element list]:

	(define-struct foo
	  (a
	   b))

   and typed-slot structures <URL:http://download.plt-scheme.org/doc/
   206p1/html/mzscheme/mzscheme-Z-H-4.html> with some "property" stuff
   I really don't understand, but if you define your own accessors you
   can associate an optional "guard-proc", which:

	...is called by make-struct-type before attaching the property
	to a new structure type. ... To reject a property association
	(e.g., because the value supplied to make-struct-type is
	inappropriate for the property), the guard can raise an exception.
	...

   Maybe that can be used to enforce slot value typing, I dunno...


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Grzegorz =?UTF-8?B?Q2hydXBhxYJh?=
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <c0vvhl$vsv$1@news.ya.com>
Rob Warnock wrote:

> Marco Antoniotti  <·······@cs.nyu.edu> wrote:
> +---------------
> | Since we are at it... :)
> | What is the translation in Scheme of the Common Lisp
> | (defstruct foo
> | (a 42 :type integer)
> | (b "foo" :type string))
> +---------------
> 
> As in the other example, it depends on what you restrict yourself to:
> 
> 1. For either IEEE Scheme [IEEE Std. 1178-1990 (R2002)] or
>    R5RS Scheme (1998): There is no translation. Standard Schemes
>    do not include structures.
> 
> 2. Specific implementation extensions: Many, various, idiosyncratic,
>    some with typing and some not.
> 
>    For example, PLT DrScheme/MzScheme provides both simple untyped-slot
>    structures <URL:http://download.plt-scheme.org/doc/206p1/html/mzscheme/
>    mzscheme-Z-H-4.html>, for which the translation would be as follows
>    [not shown is the single-inheritance case, where the first arg is a
>    two-element list]:
> 
> (define-struct foo
> (a
> b))

3. SRFI-9 (Defining record types) This could be used instead of 
   implementation-specific structures for portability:

   (define-record-type foo
          (make-foo a b)
          foo?
          (a foo-a set-foo-a!)
          (b foo-b set-foo-b!))

-- 
Grzegorz Chrupała | http://pithekos.net | ·········@jabber.org
gosh -bE "begin (print \
(map (cut number->string <> 36) '(18 806564 1714020422))) (exit)"
From: javuchi
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <m21xoua7fc.fsf@servidor.kalandra>
···········@yahoo.com (Tayssir John Gabbour) writes:

> I'll go out on a limb and suggest the lectures and book at:
> http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/
> Other video lectures at: http://www.aduni.org/courses/sicp/
> 
> It's not Common Lisp.  It's Scheme, without macros or i/o.  However
> it is a way to break out of C-like mindset.  I might have preferred
> to recommend Norvig's PAIP, because there you do learn "lisp", but
> that fails your requirement of being free.
> 
> Basically what you'll learn is functional programming and some
> models of how a lisp works.  Intro compsci stuff.  It's how I
> learned lisp, and you should be warned that they present a beautiful
> Scheme, but a castrated one.  You have about zero control over
> syntax.  (Except when you extend their 20-line Scheme.)  When they
> talk about "building a language", they're talking about doing it
> with just functions and not syntactic transformations.

Well, I think you're right. I have never tried to learn Scheme before,
but it is the functional part of Lisp the one that I have most of the
problems. I think I have not problem with its syntax, I can even read
all those parenthesis fine.

> Still, I think people are going to find all sorts of opinions and
> potholes, so that's no reason to dismiss information.  After all,
> one big problem is apparently lispers who use macros for every
> little thing.  And macro writers need to learn about variable
> capture.  So it's useful to learn how to use functions.  And the
> discussion of lisp models is second to no other intro.  Just be
> warned that while the Scheme you see is pretty and seems deep, it
> has none of the at times insane depth and beauty of a real lisp.

Once you have used C++ templates and C #defines, Lisp macros are not
so difficult to understand. They are of course much more complete, and
at the same time does have a clearer syntax.  So the problem is not to
understand them. The problem is when and how to apply them. I have
read some source code in Lisp and read some API implementations and
have fascinated about the incredible power of the combination of
functional + imperative(when convenient) + macros of Lisp. I just want
to learn it for me being able to do such a quality implementation of
any algorithm / computational problem.

I take your advise of not /abusing/ about macros.

Thanks for the videos, I'll see them, when I finish to download them,
of course (they are big).

-- 
�� javuchi ��
From: Jens Axel Søgaard
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <40316ddc$0$254$edfadb0f@dread12.news.tele.dk>
javuchi wrote:

> Well, I think you're right. I have never tried to learn Scheme before,
> but it is the functional part of Lisp the one that I have most of the
> problems. I think I have not problem with its syntax, I can even read
> all those parenthesis fine.

If you want to get into the mindset of Scheme/Lisp programming,
I'll recommend that you start by reading "How to Design Programs":

     <http://www.htdp.org>

(You'll probably think it's a bit too easy in the beginning,
but don't worry - you'll learn how to think)

Then read SICP:

     <http://mitpress.mit.edu/sicp/full-text/book/book.html

However - remember that both book concentrate on a subset
of Scheme/Lisp. Namely the subset that allows them to teach
you the all concepts they need. The full languages offer everything
"missing".

-- 
Jens Axel S�gaard
From: javuchi
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <m2y8r2e2w9.fsf@servidor.kalandra>
Jens Axel S�gaard <······@jasoegaard.dk> writes:

> If you want to get into the mindset of Scheme/Lisp programming, I'll
> recommend that you start by reading "How to Design Programs":
> 
>      <http://www.htdp.org>

Nice. I bookmarked it.

> (You'll probably think it's a bit too easy in the beginning, but
> don't worry - you'll learn how to think)
> 
> Then read SICP:
> 
>      <http://mitpress.mit.edu/sicp/full-text/book/book.html


I knew this. It comes with nice videos, so I prefer to see them.

> However - remember that both book concentrate on a subset of
> Scheme/Lisp. Namely the subset that allows them to teach you the all
> concepts they need. The full languages offer everything "missing".

Thanks.  Now I have a lot of books bookmarked... ummm, I have to
decide for which one to start.  I probably choose the one which I feel
is more concise, as I don't want to learn to program again, just to
adapt my mind.

-- 
�� javuchi ��
From: mikel evins
Subject: Re: Free book for converting my C mind?
Date: 
Message-ID: <40310d39_7@news.athenanews.com>
javuchi wrote:

> I'm wondering if there is somewhere a book which teaches me how to write
> correct Lisp code, taking in consideration that I have used C/C++ for years.
> 
> I have found these ones, but none of them really helped me to transform my
> mind:
> 
> http://www-2.cs.cmu.edu/~dst/LispBook/index.html
> http://psg.com/~dlamkins/sl/contents.html
> 
> I'm looking for something more concrete, with lot of examples showing the
> true difference between implementing algorithms/problems in C and Lisp.

Why don't we do it cooperatively? You post an idiom in C or C++ that 
seems natural to you, and I'll post a way to do it in Lisp that feels 
natural to me. My poor code will irritate much-smarter-than-me Lisp 
programmers into posting better code, and everybody wins.

:-)

(Though I am a Lisp hacker, like most Lisp hackers I've had to write C, 
C++, and Java code for years to pay the bills, so I expect your chosen 
idioms will not be entirely alien to me.)
From: javuchi
Subject: Some code for converting my C mind: machines and music.
Date: 
Message-ID: <m2ekstv9xf.fsf_-_@servidor.kalandra>
mikel evins <·····@evins.net> writes:

> Why don't we do it cooperatively? You post an idiom in C or C++ that
> seems natural to you, and I'll post a way to do it in Lisp that
> feels natural to me. My poor code will irritate much-smarter-than-me
> Lisp programmers into posting better code, and everybody wins.


Ok, lets do it. I warn you that it is probably a big issue.  I'm going
to present a problem for which I have a clear (but large) solution in
C. I even wrote some code.  Let examine, for example, Octal:

http://www.gnu.org/software/octal/ox_api_main/index.html

Octal is, basically, an API for creating and using music instruments
(samples, synthesizers, etc) and sound effects (reverb, echo, chorus,
etc), and a way to let them intercommunicate to each other, following
the indications of the programmer.  It is clearly an OOP application,
made in C (not C++).

The algorithm I pretend to implement in Lisp is very similar to
Octal. This is more or less, how it works: You define a new *machine*
using /machine_type/ structure. A machine, is a kind of sound
generator, which can be an effect or an instrument.  Each machine does
have an input and an output. The input comes from *other machines*
connected to its input if it is an /effect/, and have no input if it
is a /generator/.  Each machine does have an output. The output goes
to *other machines* which might process the sound data in any way
(the DSP machine outputs its inputs to the speakers).

The data who travels through all of these machines is buffered and it
is continuous. It needs to work in real time, and there might be a way
to take track of the time.  This "time" is needed because because we
are pretending to have a way of storing /events/. Each event stores a
value for a machine, and a time. When the global time is equal to the
event time, the event must be send to the machine.

In my C code, this is the structure for a machine definition:

#define SELF gpointer

typedef enum MEventType {
	EVENT_VALUE = 0,
	EVENT_COUNT,
	EVENT_TEXT,
	EVENT_STATE,
	EVENT_POINTER
} MEventType;

typedef struct MMachine {
	GString *name;
	gchar short_name[3-1];
	GString *description;

	MSong *song;	

	MEventType event_type;
	GArray *event_id_short_names;
	GArray *event_type_per_id; /* MEventType list */
	
	GList *connections; /* input machines */

	void (*process_event) (SELF, gpointer /*event*/)
	gdouble *(*get_buffer) (SELF); /* output the buffer */

	void (*init) (SELF);
	void (*free) (SELF);
	void (*reset) (SELF);
	void (*save) (SELF, GIOChannel*);
	void (*load) (SELF, GIOChannel*);
	
	gpointer data; /* additional data */
	
} MMachine;

(Note: I use glib)
(Note2: *song* is where we store the events. It is here only for convenience.)


So, the basic question is: is there a better way to implement this is Lisp?

-- 
�� javuchi ��