From: Kenneth Tilton on
Tim Bradshaw wrote:
> 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).
>

Oh, cool. I have an image now of you and Xah team-coding. Should be fun.

kt

--
http://www.stuckonalgebra.com
"The best Algebra tutorial program I have seen... in a class by itself."
Macworld
From: Thomas A. Russ on
Norbert_Paul <norbertpauls_spambin(a)yahoo.com> writes:

> Hello,
>
> I have defined a class where a slot *must* be initialized when creating
> instances:
>
> (define-condition modular-ring-without-generator (algebraic-error) ())
>
> (defclass 'modular-ring (ring)
> ((ring :initarg :ring :initform (make-instance 'ring))
> (generator :initarg :generator
> :initform (error (make-condition
> 'modular-ring-without-generator)))))
>
> which works, as HyperSpec says that initform is not evaluated when
> the user specifies an initial form in make-instance:
>
> So (make-instance 'modular-ring) signals the above error, whereas
> (make-instance 'modular-ring :generator 7) creates Z/7Z.
>
> Is there a standard way in CLOS or are there standard LISP-idioms
> to get a similar behaviour? I couldn't find in HyperSpec how slot
> initialization can be made mandatory.

Well, what you have is a "clever way" to force the initialization. It
has the virtue of being compact and including the error information with
the slot.

I'll note that you can simplify it slightly by not including the
MAKE-CONDITION function call. Instead just use
(error 'module-ring-without-generator)

The use of :BEFORE or :AFTER methods on INITIALIZE-INSTANCE are other
ways that you can enforce constraints. You will need to use those
approaches if you have constraints that need to consider a combination
of the values used to initialize an instance, say if you wanted to make
sure that h^2 = a^2 + b^2 for a right triangle.

As to which is better, it's mostly a matter of style and personal
preference. If you want to do this a lot, you can generalize your
condition to be MISSING-REQUIRED-SLOT-INITIALIZATION and have it take
arguments similar to the last example given in the hyperspec at

http://www.lispworks.com/documentation/HyperSpec/Body/f_error.htm


--
Thomas A. Russ, USC/Information Sciences Institute
From: Norbert_Paul on
Tamas K Papp wrote:
> [...]
>> (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 :-)
I only put the top-level closing ) on a separate line.

I have indeed--before reading your note--tried that with slime
(SLIME->Editing->Update indentation). It didn't change anything.
The only difference I note is that I indent at least two spaces
and therefore often separate opening parentheses by blanks.

Well, I will change that according to
> You might like this: norvig.com/luv-slides.ps
which I already have.

> HTH,
??? Is it "Hi There?
> Tamas
Regards
Norbert

P.S. I have never given up in LISP but often been told to.
From: Tim Bradshaw on
On 2010-01-11 22:19:59 +0000, Kenneth Tilton <kentilton(a)gmail.com> said:

> Oh, cool. I have an image now of you and Xah team-coding. Should be fun.

You're assuming Xah and I are different people.

But seriously: Mathematica makes me feel significantly iller than Java:
at least the people who designed Java understood they were creating a
limited, hacky language. Mathematica seems to have been designed by
someone who did some rather casual reading about other languages, but
whose ego was so vast they considered it beneath them to actually learn
those languages, and thus revisited all the mistakes that early
implementations of those languages made. REDUCE, which I moved from,
at least has the excuse that it really was written in the 1960s, and
even then it's probably less horrible. Doesn't have the nice
environment though. Should probably have got the hobbyist Maple I
think.

From: John Thingstad on
The Tue, 12 Jan 2010 08:33:53 +0000, Tim Bradshaw wrote:

> On 2010-01-11 22:19:59 +0000, Kenneth Tilton <kentilton(a)gmail.com> said:
>
>> Oh, cool. I have an image now of you and Xah team-coding. Should be
>> fun.
>
> You're assuming Xah and I are different people.
>
> But seriously: Mathematica makes me feel significantly iller than Java:
> at least the people who designed Java understood they were creating a
> limited, hacky language.

You are a strange one. Where did you get that idea?
Java suffers from elepantosis. It's not quite as bad a C++ yet, but it is
getting there. Exactly becaus it tries to do everything and satisfy
everyone.

> Mathematica seems to have been designed by
> someone who did some rather casual reading about other languages, but
> whose ego was so vast they considered it beneath them to actually learn
> those languages, and thus revisited all the mistakes that early
> implementations of those languages made. REDUCE, which I moved from, at
> least has the excuse that it really was written in the 1960s, and even
> then it's probably less horrible. Doesn't have the nice environment
> though. Should probably have got the hobbyist Maple I think.

Mathematica is probaly the most carefully designed language I have ever
encountered. Immencly powerfull. Plenty of mistakes sure. Interprented
when it should have been compiled. Then handeling of local variables and
modules seem the reverse of what they should be. They default to global.

And.. What's wrong with reduce?

Maple to me has a zillion windows and dialogs and no overall design plan.
They just kept on adding 'stuff'.

But to each his own.

--
John Thingstad