Re: CLOS a la Java
- From: Javier <javuchi@xxxxxxxxx>
- Date: Thu, 12 Mar 2009 17:18:40 +0100
Marco Antoniotti escribió:
Hello
On Mar 12, 9:03 am, Javier <javu...@xxxxxxxxx> wrote:
I'd like to implement this:
(defmyclass foo1 :extends foo0
"This is documentation for foo1 class"
(:public :static
memberstatic1 :init 'value)
(:protected
member1 :type symbol :init 'member1 :doc "Documentation for member1"
member2)
(:public
method1 :method (((arg1 number) (arg2 number))
(if (< arg1 arg2)
this.member1
this.member2))
method1 :method (() this.member1)
:constructor (() nil)
:constructor (((arg1 symbol))
(setf this.member2 arg1))))
(defvar *foo* (new foo1 'example-arg))
(print *foo*.member2) ;error, it is protected
(foo1.method1) ;error, foo1 is not an instance
(print foo1.memberstatic1) ; 'value
(print (*foo*.method1 2 3)) ; 'member1
So I have a similar object system to Java. I want it to be 100%
compatible with CLOS, so I can interchange classes from one system to
another.
As per my previous responses to you, the first question is "why?" It
simply looks to me that you want to have a surface (or "concrete")
syntax that is the closest possible to Java.
I was a Java moron, but appreciate Lisp interactivity and macros. I'm
not very purist, don't matter to mix different kind of codes, and the
Java (or c++, it doesn't matter) syntax seems to be more compact.
I'm really used to work with objects that way. The way that CLOS is made
doesn't fit very much with my style. But everybody says that Lisp CAN be
modified to adapt to you, so I'm just doing so.
This is the answer for the text you wrote that I'm going to cut down in
order to save space:
My question to you [...]
Will this suffice?
I apreciate it, thank you. But my main concern is not exactly how to
write the macros... I think I can do it, although probably not as fast
as you.
I asked mainly because of the instance.something notation.
[...]
Note that this is a 3 hours hack.
Wuaooo. I just wrote the skeleton in that time. But I'm just learning,
and finding the way to solve the evil instance.method notation...
The number of things that you will
not like is large and the number of ways it *will* fail is larger.
The semantics is not even close to Java, but it *can* be made close ot
it. In many ways the code is ugly CL, and I have not even brought in
the Metaobject Protocol. I have many other aces up my CL sleeve.
Having said that, you should appreciate the power of Communist Lisp
and maybe reconsider your approach to it. I know I am sounding
paternalistic.
Let me finish with a gripe of mine on "syntax". The syntax of Common
Lisp is amazingly simple and regular. It is all atoms or applications
or hash reader macros (which most of the time expand in applications)
or backquotes or quotes (which expand in (QUOTE ...)). Trying to
shoehorn the dot notation into CL is a *bad idea* (TM); the same goes
for other C/C++, SLDJ or Perlish constructs (after all, CLers like to
keep their self-esteem low). That is the reason why over the long CL
history you have seen very very very few libraries which do use
exogenous syntax by defining a slew of reader macros. And those that
do are (1) extremely careful about it and (2) do it for very good
reason; cfr FSet and CL-SQL.
Do not agree very much with that... if I'm doing lisp is because Lisp
allows me to redefine the way the language works... for fixed languages
I already have Java, which is right if you have the right tools (i.e. a
good IDE).
.
- References:
- CLOS a la Java
- From: Javier
- Re: CLOS a la Java
- From: Marco Antoniotti
- CLOS a la Java
- Prev by Date: Re: CLOS a la Java
- Next by Date: Re: CLOS a la Java
- Previous by thread: Re: CLOS a la Java
- Next by thread: Re: CLOS a la Java
- Index(es):
Relevant Pages
|