From: Norbert_Paul on
The quote was a typo. Of course in my source the class names are not
quoted.

(1) Wouldn't a :before specializer be better (fail fast):

* (defclass foo () ((bar :initarg :bar)))

* (defmethod initialize-instance :before ((object foo)
&key (bar nil bar-supplied)
&allow-other-keys)
(if (not bar-supplied)
(error ...))
)

?


(2) Where can I learn standard indentation/formatting?

Norbert

Tamas K Papp wrote:
> Certainly. I would just create an :after method for
> initialize-instance, and check everything I want there. For example,
>
> (defclass modular-ring ()
> ((ring :initarg :ring :initform 'something)
> (generator :initarg :generator)))
>
> (defmethod initialize-instance :after ((object modular-ring) &key &allow-other-keys)
> (unless (slot-boundp object 'generator)
> (error 'modular-ring-without-generator)))
>
> (make-instance 'modular-ring :generator 'something-else) ; OK
> (make-instance 'modular-ring) ; error
>
> BTW, your indentation/formatting is pretty non-standard (you should learn
> to use your editor to indent Lisp code properly), and you don't need to quote
> the name of the class (I wonder how you got your code to run, I tried
> it in SBCL and it tells me that "'MODULAR-RING is not a legal class
> name.").
>
> HTH,
>
> Tamas
From: Tamas K Papp on
On Mon, 11 Jan 2010 17:00:27 +0100, Norbert_Paul wrote:

> The quote was a typo. Of course in my source the class names are not
> quoted.
>
> (1) Wouldn't a :before specializer be better (fail fast):
>
> * (defclass foo () ((bar :initarg :bar)))
>
> * (defmethod initialize-instance :before ((object foo)
> &key (bar nil bar-supplied)
> &allow-other-keys)
> (if (not bar-supplied)
> (error ...))
> )

That is also OK.

A note on style: I would write it like

(unless bar-supplied
(error "bar not supplied")))

UNLESS is a standard macro.

> (2) Where can I learn standard indentation/formatting?

Your editor (emacs+slime or a commercial Lisp IDE) should have an
autoindent function. Other than that, just don't put closing ) on
separate lines. There is not that much to it, as Lisp doesn't have
much of a syntax :-)

You might like this: norvig.com/luv-slides.ps

HTH,

Tamas
From: Tamas K Papp on
On Mon, 11 Jan 2010 16:32:18 +0100, Norbert_Paul wrote:

> Hello Kenneth,
>
> in this case I'd prefer being a non-real (algebraic?, ...) programmer by

:-)

> Another hockey puck: I am also planning to use somethig like CLUnit.
> JUnit is fun! So will be CLUnit, I'm sure.

Unit testing is standard among CLers too. Personally, I use LIFT,
which is a nice unit testing library.

HTH,

Tamas

From: Tim Bradshaw on
On 2010-01-10 22:55:26 +0000, Kenneth Tilton <kentilton(a)gmail.com> said:

> Hockey pucks. Real Lispers do not give a r*t's *ss about guarding
> against programmer error. You need to turn over the helicopter keys and
> get some rehab, you been doing java too long.

Real Lispers also use a languages where (EQ 'REAL-LISPERS
'LISP-HIPPIES) evaluates to NIL. Although in fact they would write
this (EQ (QUOTE REALLISPERS) (QUOTE LISPHIPPIES)) and would probably
worry about the anachronism. No helicopter keys for you (and
Mathematica is this week's toy language).

From: Kenneth Tilton on
Norbert_Paul wrote:
> Hello Kenneth,
>
> in this case I'd prefer being a non-real (algebraic?, ...) programmer
> by simply pasting together what he considers best habits from all
> communities
> he comes in touch with.

Would you drive a truck as if it were a Ferrari? Have Navy frogs wear
suits of armor? Put garlic in a cheescake?

Just checking.

>
> Note that I am, in fact, trying to return from years of Java-programming
> back to LISP. Ho did you guess?
>
> Note. (/ 1 0) => error: division-by-zero (in HyperSpec)
> Has the spec been written by non-real programmers, too?

I think you just changed the subject.

>
> Another hockey puck: I am also planning to use somethig like CLUnit.
> JUnit is fun! So will be CLUnit, I'm sure.

That's fine. There are no right answers when it comes to things like
this because it comes down to personal temperament and ability. Reinhold
Meisner's style of mounteering (often with Habeler (sp?)) is not for
everyone.

kt

--
http://www.stuckonalgebra.com
"The best Algebra tutorial program I have seen... in a class by itself."
Macworld