From: Vityok
Subject: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <4c1a0992-0a4e-4ad5-8ea0-ec568afde840@p69g2000hsa.googlegroups.com>
Greetings,

I would like to ask if there is some tutorial or an introductory
manual describing Common Lisp concepts and CLOS in particular to Java
developers.

A manual describing how do well-known things and concepts of the Java
world look like in Common Lisp?

I do not mean the very basics, like what a list is, but a little bit
more advanced like how do object constructors look like, how to
declare private methods and object properties (aka slots), whether the
strings are immutable or not, etc.

With best regards,

Victor

From: Slobodan Blazeski
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <7a49dcbb-57d0-4781-9eb8-9b0089e206d9@l32g2000hse.googlegroups.com>
On Dec 28, 12:43 pm, Vityok <······@ua.fm> wrote:
> Greetings,
>
> I would like to ask if there is some tutorial or an introductory
> manual describing Common Lisp concepts and CLOS in particular to Java
> developers.
>
> A manual describing how do well-known things and concepts of the Java
> world look like in Common Lisp?
>
> I do not mean the very basics, like what a list is, but a little bit
> more advanced like how do object constructors look like, how to
> declare private methods and object properties (aka slots), whether the
> strings are immutable or not, etc.
>
> With best regards,
>
> Victor

I recommend to learn lisp way from a good book before jumping into
CLOS (common lisp object system)
here's some examples in this thread
http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/9d0080bd3be9ddea/9e0ab129d28fb21b?hl=en&lnk=gst&q=slobodan+shameless+selfquoting#9e0ab129d28fb21b
afterward you should learn clos more deeply

Tutorials:
http://cl-cookbook.sourceforge.net/clos-tutorial/index.html
http://eval.apply.googlepages.com/guide.html
http://www.dreamsongs.com/CLOS.html
http://www.aiai.ed.ac.uk/~jeff/clos-guide.html
http://cl-cookbook.sourceforge.net/clos-tutorial/index.html
http://www.apl.jhu.edu/~hall/AI-Programming/CLOS.html
Book
Sonya Keene's Object-Oriented Programming in Common Lisp.

cheers
Slobodan
From: Vityok
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <e92fb07c-ac32-47ea-b309-9358921ffbac@l1g2000hsa.googlegroups.com>
On 28 çÒÄ, 15:01, Slobodan Blazeski <·················@gmail.com>
wrote:
> On Dec 28, 12:43 pm, Vityok <······@ua.fm> wrote:
>
> I recommend to learn lisp way from a good book before jumping into
> CLOS (common lisp object system)

Thank you Slobodan, thank you Joost,

Of course I've seen the Siebel's book, various CLOS tutorials and so
on.

But, they all explain Common Lisp and CLOS in terms of Common Lisp and
CLOS.  They explain packages as Common Lisp packages, objects and
classes are explained using CLOS and Lisp terminology.

The manual I would like to find would explain how concepts common to a
Java developer (java packages, imports, classes,
public/private/protected methods, object properties, and so on) are
mapped to Common Lisp and CLOS.

Probably, some Java concepts have no sense in Common Lisp, whereas
some of them have a corresponding concept in Lisp.

IMHO, such a tutorial (or an overview) could help a Java developer to
adapt to the Lisp way of thinking.

Nevertheless, thank you for your replies and provided links,

With best regards,

Victor
From: Slobodan Blazeski
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <4d9ac0f2-4ae7-4523-a499-eea6bdb623b5@s27g2000hsb.googlegroups.com>
On Dec 28, 3:19 pm, Vityok <······@ua.fm> wrote:
> On 28 çÒÄ, 15:01, Slobodan Blazeski <·················@gmail.com>
> wrote:
>
> > On Dec 28, 12:43 pm, Vityok <······@ua.fm> wrote:
>
> > I recommend to learn lisp way from a good book before jumping into
> > CLOS (common lisp object system)
>
> Thank you Slobodan, thank you Joost,
>
> Of course I've seen the Siebel's book, various CLOS tutorials and so
> on.
>
> But, they all explain Common Lisp and CLOS in terms of Common Lisp and
> CLOS.  They explain packages as Common Lisp packages, objects and
> classes are explained using CLOS and Lisp terminology.
>
> The manual I would like to find would explain how concepts common to a
> Java developer (java packages, imports, classes,
> public/private/protected methods, object properties, and so on) are
> mapped to Common Lisp and CLOS.
>
> Probably, some Java concepts have no sense in Common Lisp, whereas
> some of them have a corresponding concept in Lisp.
>
> IMHO, such a tutorial (or an overview) could help a Java developer to
> adapt to the Lisp way of thinking.
>
> Nevertheless, thank you for your replies and provided links,
>
> With best regards,
>
> Victor

I never used Java, you better check someone who come from java to lisp
or used like http://www.findinglisp.com/papers/case_study_java_lisp_dns.html
(google java common lisp etc)
Assuming java it's pretty close to c# , here's some short summary of
differences with cl:
1. java/c# are OO languages while lisp is multiparadigm, objects are
only part of the program  most of the job is usually done with
functions, most of the  code in lisp programs are function
definitions.
2. c# methods belongs to class, clos methods belong to generic
functions
Just imagine that you're writing code that calculates interest rate:
You have types of loans represented by corrsponding objects :
unsecured-loan , mortgage, collateral-car, collateral-gold, collateral-
stocks
objects of creditor : first-class-borrower , second-class-borrower ,
unclassified
and objects for lender  :goverment, bank, person etc
in lisp you will write a generic function like this:
(defegeneric calculate-interest-rate (loan  borrower lender))
And now you specialize method for example
(defmethod calculate-interest-rate ((loan unsecured-loan) (borrower
unclassified) (lender bank))
   (error "Conditions are unacceptable))
but if borrower with bad record has some collateral than we're not
interested anymore in borrower we only care about collateral, so if
any type of borrower wants to apply for mortgage than we
(defmethod calculate-interest-rate ((loan mortagge) borrower lender)
  12.7%)
What will happen if a poor guy (unclassified) doesn't have any kind of
collateral but there's a goverment program aimed to help him, than we
specialize methods on type of loan , unsecured-loan,  borrower as
unclassified (as only poor people could apply for this lones ) and
borrower will be the goverment
(defmethod calculate-interest-rate ((loan unsecured-loan) (borrower
unclassified) (lender goverment))
  4.3%)

How you gonna write this code in Java/c# ?
3. Lisp has functions as first class citizens it's normal to pass
function as argument or return one as value
(mapcar #'(lambda (x) (if (evenp x) (* x 3) (- x))) '(1 2 3 4 5))

4. Lisp has macros that could write code for you so you can catch
patterns and use them to remove the boilerplate code

5. Lisp is very good for bottom up programming, download Paul Graham
On lisp and read chapter one
to have a hint what I mean http://www.paulgraham.com/onlisp.html he
writes better than I do.

6. Lisp is extensible langauge. You can use it for imperative ,
functional , OO, contex http://common-lisp.net/project/closer/contextl.html
, aspect http://common-lisp.net/project/closer/aspectl.html ,    or
whatever style you need. Lisp will bend to it. See chapter 25 of On
Lisp how CLOS could be implemeted if it wasn't alredy prewrittem.

Lisp is a different world Victor , you migh like it or not , but if
you want to understand, try to  learn it the proper way.

cheers
Slobodan
From: Vityok
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <7bf18582-c510-4fe0-9bc8-2e9cba59bdbb@s8g2000prg.googlegroups.com>
On 28 çÒÄ, 17:46, Slobodan Blazeski <·················@gmail.com>
wrote:

> I never used Java, you better check someone who come from java to lisp
....

Thanks!  The set tasks from the TIJ solved in Lisp look like pretty
much what I've been looking for.

With best regards,

Victor
From: Alex Mizrahi
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <47751eff$0$90266$14726298@news.sunsite.dk>
 SB> Assuming java it's pretty close to c# , here's some short summary of
 SB> differences with cl:

it seems you've forgot dynamic types and REPL style of development --  
(arguably) that's biggest differences. 
From: Terrence Brannon
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <caaab203-b7d8-4e42-812d-16106c9df952@21g2000hsj.googlegroups.com>
On Dec 28, 10:46 am, Slobodan Blazeski <·················@gmail.com>
wrote:

> 2. c# methods belongs to class, clos methods belong to generic
> functions
...
>
> How you gonna write this code in Java/c# ?

Slobodan, you write some deep and insightful posts man... what you
wrote here reminded me of Seibel's talk (which I had forgotten) at
Google where he discussed single, double and multiple dispatch and how
CLOS excelled in this area.

Thanks for putting so much energy into making things clear for us.
From: Slobodan Blazeski
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <1355cb10-2dc2-4489-994d-3ba0fa701439@s19g2000prg.googlegroups.com>
On Dec 31 2007, 8:50 pm, Terrence Brannon <········@gmail.com> wrote:
> On Dec 28, 10:46 am, Slobodan Blazeski <·················@gmail.com>
> wrote:
>
>
>
> > 2. c# methods belongs to class, clos methods belong to generic
> > functions
> ...
>
> > How you gonna write this code in Java/c# ?
>
> Slobodan, you write some deep and insightful posts man... what you
> wrote here reminded me of Seibel's talk (which I had forgotten) at
> Google where he discussed single, double and multiple dispatch and how
> CLOS excelled in this area.
>
> Thanks for putting so much energy into making things clear for us.

Thanks but it was jkust a quick rant. If you want to understand CLOS
you need to work with some programm that make use of it. Whenever I
said that CLOS methods could be specialized at multiple objects as
arguments people asked me where's that going to be useful, and I
couldn't give them good example of my own . Now after working few
months with weblocks http://trac.common-lisp.net/cl-weblocks/  that's
something that I couldn't live without.

cheers and happy new year
Slobodan
From: Ken Tilton
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <4774cf45$0$9074$607ed4bc@cv.net>
Vityok wrote:
> On 28 ���, 15:01, Slobodan Blazeski <·················@gmail.com>
> wrote:
> 
>>On Dec 28, 12:43 pm, Vityok <······@ua.fm> wrote:
>>
>>I recommend to learn lisp way from a good book before jumping into
>>CLOS (common lisp object system)
> 
> 
> Thank you Slobodan, thank you Joost,
> 
> Of course I've seen the Siebel's book, various CLOS tutorials and so
> on.
> 
> But, they all explain Common Lisp and CLOS in terms of Common Lisp and
> CLOS.  They explain packages as Common Lisp packages, objects and
> classes are explained using CLOS and Lisp terminology.
> 
> The manual I would like to find would explain how concepts common to a
> Java developer (java packages, imports, classes,
> public/private/protected methods, object properties, and so on) are
> mapped to Common Lisp and CLOS.

This definitely rings a bell -- some Lisp noob started recording such 
comparisons on some web page. Maybe this?:

   http://bc.tech.coop/blog/040430.html

I googled "Lisp for Java", btw.

kt

-- 
http://www.theoryyalgebra.com/

"In the morning, hear the Way;
  in the evening, die content!"
                     -- Confucius
From: Alex Mizrahi
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <47751170$0$90272$14726298@news.sunsite.dk>
 V> The manual I would like to find would explain how concepts common to a
 V> Java developer are
 V> mapped to Common Lisp and CLOS.

if you'll just look through few CLOS examples you'll undestand how they are 
mapped.

description of what maps where would be too general to be meaningful.

how useful it would be if i'll tell you that packages in Lisp a called 
packages, classes -- classes, methods -- methods, but they work in quite 
different way from Java ones, so you'll need to read docs anyway even 
knowing the names? 
From: Rainer Joswig
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <joswig-6F85BB.18132928122007@news-europe.giganews.com>
In article 
<····································@l1g2000hsa.googlegroups.com>,
 Vityok <······@ua.fm> wrote:

> On 28 ���, 15:01, Slobodan Blazeski <·················@gmail.com>
> wrote:
> > On Dec 28, 12:43 pm, Vityok <······@ua.fm> wrote:
> >
> > I recommend to learn lisp way from a good book before jumping into
> > CLOS (common lisp object system)
> 
> Thank you Slobodan, thank you Joost,
> 
> Of course I've seen the Siebel's book, various CLOS tutorials and so
> on.
> 
> But, they all explain Common Lisp and CLOS in terms of Common Lisp and
> CLOS.  They explain packages as Common Lisp packages, objects and
> classes are explained using CLOS and Lisp terminology.
> 
> The manual I would like to find would explain how concepts common to a
> Java developer (java packages, imports, classes,
> public/private/protected methods, object properties, and so on) are
> mapped to Common Lisp and CLOS.
> 
> Probably, some Java concepts have no sense in Common Lisp, whereas
> some of them have a corresponding concept in Lisp.
> 
> IMHO, such a tutorial (or an overview) could help a Java developer to
> adapt to the Lisp way of thinking.
> 
> Nevertheless, thank you for your replies and provided links,
> 
> With best regards,
> 
> Victor

Make sure you read also some of these papers:

  http://www.dreamsongs.com/CLOS.html

They are not too long and give a good introduction.

Also interesting, the Dylan competitive analysis.
Dylan has a similar object system.
http://www.cs.dartmouth.edu/~brd/cs212/handouts/comparison.htm
 
Old:
CLOS/Eiffel/Sather:
http://www.icsi.berkeley.edu/~sather/Publications/tr-91-047/

Languages vs. D
http://www.prowiki.org/wiki4d/wiki.cgi?LanguagesVersusD

Ruby vs. ...
http://www.approximity.com/ruby/Comparison_rb_st_m_java.html

-- 
http://lispm.dyndns.org/
From: Matthias Buelow
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <5tktajF1dr57vU1@mid.dfncis.de>
Vityok wrote:

> IMHO, such a tutorial (or an overview) could help a Java developer to
> adapt to the Lisp way of thinking.

Have you seen the source code of the Bourne shell?
From: Andreas Davour
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <cs9k5my8x32.fsf@Psilocybe.Update.UU.SE>
Matthias Buelow <···@incubus.de> writes:

> Vityok wrote:
>
>> IMHO, such a tutorial (or an overview) could help a Java developer to
>> adapt to the Lisp way of thinking.
>
> Have you seen the source code of the Bourne shell?

No, go look! It's worth it. 

/Andreas

-- 
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
From: Pascal Bourguignon
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <871w961j6p.fsf@thalassa.informatimago.com>
Vityok <······@ua.fm> writes:

> On 28 Грд, 15:01, Slobodan Blazeski <·················@gmail.com>
> wrote:
>> On Dec 28, 12:43 pm, Vityok <······@ua.fm> wrote:
>>
>> I recommend to learn lisp way from a good book before jumping into
>> CLOS (common lisp object system)
>
> Thank you Slobodan, thank you Joost,
>
> Of course I've seen the Siebel's book, various CLOS tutorials and so
> on.
>
> But, they all explain Common Lisp and CLOS in terms of Common Lisp and
> CLOS.  They explain packages as Common Lisp packages, objects and
> classes are explained using CLOS and Lisp terminology.

Ah, but "Lisp is different", google for it, and watch the logo:
http://www.lisperati.com/lisplogo_fancy_256.png 



> The manual I would like to find would explain how concepts common to a
> Java developer (java packages, imports, classes,
> public/private/protected methods, object properties, and so on) are
> mapped to Common Lisp and CLOS.

If you really want to see a mapping of CL concept in Java terms,  have
a look at this: http://armedbear.org/abcl-0.0.10.tar.gz

But if what you want is to see a mapping of java concepts to Common
Lisp, then what you need is Linj. http://www.evaluator.pt/linj.html


Another way to see what I mean, (and why you should just read
Practical Common Lisp, and perhaps forget the Java you know), is to
use http://www.google.com/language_tools and to translate back and
forth a sentence in a couple of languages you know and see the
result...


> Probably, some Java concepts have no sense in Common Lisp, whereas
> some of them have a corresponding concept in Lisp.
>
> IMHO, such a tutorial (or an overview) could help a Java developer to
> adapt to the Lisp way of thinking.




-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

READ THIS BEFORE OPENING PACKAGE: According to certain suggested
versions of the Grand Unified Theory, the primary particles
constituting this product may decay to nothingness within the next
four hundred million years.
From: Dan Bensen
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <fl4emj$udr$1@wildfire.prairienet.org>
> Vityok <······@ua.fm> writes:
>> But, they all explain Common Lisp and CLOS in terms of Common Lisp and
>> CLOS.  They explain packages as Common Lisp packages, objects and
>> classes are explained using CLOS and Lisp terminology.

Pascal Bourguignon wrote:
> Ah, but "Lisp is different", google for it, and watch the logo:
> http://www.lisperati.com/lisplogo_fancy_256.png 

Everything is different, but everything also has parallels with
other things.  If you really understand OO clearly, you should
be able to explain CLOS to a Java programer starting with Java
terms and introducing new ones as needed.

For example, what does it mean that a Java method lives "inside" an
object?  It means the method's scope is surrounded by the object's
scope.  That's not true in CLOS, so you can say the method lives
"outside" of the object, sort of like a regular function.

Why is that good?  Even though a Java object doesn't *appear*
syntactically to be an argument of the method, that's just a
sugary coating, as you can see more easily in Perl.  You can think
of a Java method call as a call to a (generic) function with the
same name as the method, that looks at the object, which is im-
plicitly the function's first argument, and decides which method
to call based on the object's type.  CLOS explicitly uses generic
functions, and two advantages of this are (1) you can pass the
generic function to HOFs, and (2) a generic function can do type
testing, i.e. dispatch, on more than one argument.  I think any
good Java programmer can understand that easily enough.

-- 
Dan
www.prairienet.org/~dsb/
From: Alex Mizrahi
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <477601f9$0$90264$14726298@news.sunsite.dk>
 DB> For example, what does it mean that a Java method lives "inside" an
 DB> object?  It means the method's scope is surrounded by the object's
 DB> scope.  That's not true in CLOS, so you can say the method lives
 DB> "outside" of the object, sort of like a regular function.

 DB> Why is that good?  Even though a Java object doesn't *appear*
 DB> syntactically to be an argument of the method, that's just a
 DB> sugary coating, as you can see more easily in Perl.  You can think
 DB> of a Java method call as a call to a (generic) function with the
 DB> same name as the method, that looks at the object, which is im-
 DB> plicitly the function's first argument, and decides which method
 DB> to call based on the object's type.

virtual method calls are typically implemented via something like:

(object->mangled_fun_name)(object, arg1, arg2);

so at least dispatch is very efficient..

it seems you claim that outer methods are always better than inner ones.
i think that's not true -- just like special variables are not always better 
than lexical ones (or vice versa).

inner methods are better when you need to have different methods on 
per-instance basis -- implementing this with outer methods would be 
cumbersome.
i.e.:

(defclass foo ()
 ((choff :reader choff-of :initarg :choff))
  (bar :reader bar-of :initarg :bar)))

(defmethod choff ((f foo) &rest args)
  (apply (choff-of f) f args))

(defun barf (a b)
 (let ((e (gogo a b)))
  (make-instance 'foo :choff (lambda (f g) (+ a b e g (bar-of f))) :bar 42))

to do this via outer methods only, for each such lambda you need to define a 
class with all parameters that closure captures as slots, and then to define 
a method that works with such slots.

such inner methods can be useful for making some dynamic and flexible 
systems, and roughly give same benefits lambda gives comparing to named 
functions. 
From: Dan Bensen
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <fl5dlg$8dq$1@wildfire.prairienet.org>
Alex Mizrahi wrote:
>  DB> in CLOS, ... the method lives "outside" of the object ...
>  DB> Why is that good? ...

> it seems you claim that outer methods are always better than inner ones.

I don't know what gave you that impression, but it's not what I was
trying to say.  I just wanted to describe some advantages of CLOS
that a Java programmer might not know about.

> inner methods are better when you need to have different methods on 
> per-instance basis -- implementing this with outer methods would be 
> cumbersome.

Efficiency and implementation issues aside, I think the object as an
argument of the method is an important concept to stress in explaining
CLOS to C-family OOPers.

-- 
Dan
www.prairienet.org/~dsb/
From: Victor Anyakin
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <86ve6hw9rt.fsf@victor-mobi.my.domain>
Dan Bensen <··········@cyberspace.net> writes:

>> Vityok <······@ua.fm> writes:
>>> But, they all explain Common Lisp and CLOS in terms of Common Lisp and
>>> CLOS.  They explain packages as Common Lisp packages, objects and
>>> classes are explained using CLOS and Lisp terminology.
>
> Pascal Bourguignon wrote:
>> Ah, but "Lisp is different", google for it, and watch the logo:
>> http://www.lisperati.com/lisplogo_fancy_256.png 
>
> Everything is different, but everything also has parallels with
> other things.  If you really understand OO clearly, you should
> be able to explain CLOS to a Java programer starting with Java
> terms and introducing new ones as needed.
>
> For example, what does it mean that a Java method lives "inside" an
> object?  It means the method's scope is surrounded by the object's
> scope.  That's not true in CLOS, so you can say the method lives
> "outside" of the object, sort of like a regular function.

At least!  Yes exactly, that something like I was looking for.

Consider other examples, like constructors.  There is virtually a
single way to implement a constructor, in CLOS there are two (as far
as I've learned till now): using INITIALIZE-INSTANCE :after method, or
by using a custom function like MAKE-ARTICLE which will take all the
required parameters, process them and instantiate an object as needed.

There are other things a Java developer coming to the Common Lisp
world might want to know.  As far as I've got it till now, CLOS is not
really the "must" thing, since there are other ways to live without
classes in Common Lisp.  And that point might be also worth explaining
for the newbies...

However, thank you all for helping to find valuable sources of
information,

With best regards,

Happy New Year!

Victor
From: Peter Hildebrandt
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <op.t3397cmnx6i8pv@babyfoot>
On Sat, 29 Dec 2007 21:01:10 +0100, Victor Anyakin  
<······@victor-mobi.my.domain> wrote:
> Dan Bensen <··········@cyberspace.net> writes:

> Consider other examples, like constructors.  There is virtually a
> single way to implement a constructor, in CLOS there are two (as far
> as I've learned till now): using INITIALIZE-INSTANCE :after method, or
> by using a custom function like MAKE-ARTICLE which will take all the
> required parameters, process them and instantiate an object as needed.

You can also do initialization stuff in the :initforms of slots or in the  
:default-initargs.  And of course there is :before, :around and :after for  
initialize-instance and shared-initialize.

Those are far from equivalent; they are executed at different times,  
initargs/initforms can be overwritten through parameters for  
make-instance, initialize-instance :before/:after is executed for  
subclasses, even if they have their own specialized methods (whereas  
initforms/initargs are overwritten) etc.

First, decide what you want to do and second, choose the right tool.

> There are other things a Java developer coming to the Common Lisp
> world might want to know.  As far as I've got it till now, CLOS is not
> really the "must" thing, since there are other ways to live without
> classes in Common Lisp.  And that point might be also worth explaining
> for the newbies...

Consider the following:

(defun make-box (width length)
   (let ((w width) (l length))
     (list
       :area #'(lambda () (* w l))
       :set-dimmensions #'(lambda (width length) (setf w width l length))
       :get-dimmensions #'(lambda () (list w l)))))

Create "instances" with

(defparameter *box* (make-box 2 3))

And call "methods" with

(funcall (getf *box* :area))
==> 6

Change a "member"

(funcall (getf *box* :set-dimmensions) 4 5)

And check:

(funcall (getf *box* :area))
==> 20

That is, using closures you can imitate the behavior of classes without  
any OO overhead.  The example above could have been implemented just as  
well using defclass and defmethod -- more a matter of taste than anything  
else.  If you have other situations things might look differently;  for  
instance if you need a large number of instances, and only one "class  
method", it might be preferable to store closures in a hash table.

HTH,
Peter

>
> However, thank you all for helping to find valuable sources of
> information,
>
> With best regards,
>
> Happy New Year!
>
> Victor



-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: Joost Diepenmaat
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <87odcanvp4.fsf@zeekat.nl>
Pascal Bourguignon <···@informatimago.com> writes:

> Ah, but "Lisp is different"

I second this opinion. As I tried to state in my previous post, (but
maybe not too clearly) Lisp is different enough that a direct mapping of
Java -> Lisp is not going to give you a good understanding of what Lisp
is about. That's not to say that you /can't/ port Java code to Lisp more
or less on autopilot, but Lisp can make many things that are either
impossible, ugly or very inefficient in Java easy to use and
quick. And some of the stuff that gets really ugly in Java gets really
easy in Lisp. But those parts you can't usually do by "direct"
translation. You have to know /more/ than just the stuff in Lisp that's
directly equivalent to Java.

I really recommend you read the Practical Common Lisp book. As I said
it's not meant as a Java -> Lisp translation, but it's really focused on
programmers in other languages that want to take up Lisp. You may also
be interested in this presentation by Peter Seibel (the author):

<http://video.google.nl/videoplay?docid=448441135356213813&q=practical+common+lisp&total=2&start=0&num=10&so=0&type=search&plindex=0>

It gets interesting as far as Lisp vs Java diversion goes at around 20:00.

Joost.
From: Xah Lee
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <807b1145-e700-4572-9603-c180d51750d3@d4g2000prg.googlegroups.com>
Vityok <······@ua.fm> wrote:
$B!V(BThe manual I would like to find would explain how concepts common to
a Java developer (java packages, imports, classes, public/private/
protected methods, object properties, and so on) are mapped to Common
Lisp and CLOS.$B!W(B

Read my article:

$B!z(B What are OOP's Jargons and Complexities
http://xahlee.org/Periodic_dosage_dir/t2/oop.html

I think you'll understand OOP from its functional perspective, and
it'll help you understand lisp's or any object-oriented system better
than anything that exists out there.

  Xah
  ···@xahlee.org
$B-t(B http://xahlee.org/
From: Joost Diepenmaat
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <87sl1nnhxi.fsf@zeekat.nl>
Vityok <······@ua.fm> writes:

> Greetings,
>
> I would like to ask if there is some tutorial or an introductory
> manual describing Common Lisp concepts and CLOS in particular to Java
> developers.
>
> A manual describing how do well-known things and concepts of the Java
> world look like in Common Lisp?
>
> I do not mean the very basics, like what a list is, but a little bit
> more advanced like how do object constructors look like, how to
> declare private methods and object properties (aka slots), whether the
> strings are immutable or not, etc.
>
> With best regards,
>
> Victor

Seibel's book is probably the best text /I/ know for this - it assumes you're
already a programmer in some other language(s) and gives an overview of
more or less the whole language in enough detail to get coding straight away.

See http://gigamonkeys.com/book/
Chapters 16 and 17 describe CLOS, though you may want to read the whole
book. Lisp is different enough from Java that directly translating
techniques from one to the other isn't always possible or the right
thing to do.

Cheers,
Joost.
From: Pascal Costanza
Subject: Re: Common Lisp for Java developers tutorial?
Date: 
Message-ID: <5tnv3gF1dk9fhU1@mid.individual.net>
Vityok wrote:
> Greetings,
> 
> I would like to ask if there is some tutorial or an introductory
> manual describing Common Lisp concepts and CLOS in particular to Java
> developers.
> 
> A manual describing how do well-known things and concepts of the Java
> world look like in Common Lisp?
> 
> I do not mean the very basics, like what a list is, but a little bit
> more advanced like how do object constructors look like, how to
> declare private methods and object properties (aka slots), whether the
> strings are immutable or not, etc.

It may not exactly be what you're looking for, but close: When I 
switched from Java to Common Lisp about five years ago, I have written a 
guide, from that perspective. See http://p-cos.net/lisp/guide.html


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/