From: Tamas K Papp on
On Tue, 12 Jan 2010 09:32:37 +0100, Norbert_Paul wrote:

> 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.

Try indent-sexp, usually bound to C-M-q. Get a SLIME reference card
(google will turn up a few).

>> HTH,
> ??? Is it "Hi There?

"Hope this helps".

> P.S. I have never given up in LISP but often been told to.

I would not advise to give up, it think it is the best language ever.

Tamas
From: Norbert_Paul on
Thomas A. Russ wrote:
> 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)
OK, you made me look up "condition designators". I'm still (re-)learning.

> http://www.lispworks.com/documentation/HyperSpec/Body/f_error.htm
OOPS. There is a new Hyperspec around!?. Version 7.0. I used 3.0 so far.
I like the brighter background.
From: Pillsy on
On Jan 12, 6:06 am, John Thingstad <jpth...(a)online.no> wrote:
> The Tue, 12 Jan 2010 08:33:53 +0000, Tim Bradshaw wrote:
[...]
> > 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?

Probably because Mathematica is a weird, hacky language?

My favorite example here is the "context" system, which is
Mathematica's equivalent of CL's package system. In fact, it's almost
exactly like CL's context system except they

1) made contexts hierarchical, which is pretty nice
2) took out everything else which made the system remotely usable

No DEFPACKAGE forms. No SHADOW or SHADOWING-IMPORT. No easy way to
distinguish between what we CLers would call internal and external
symbols except if you do the goofy workaround with having a
"`Private`" subcontext, and the fact that as soon as the Mathematica
reader interns a symbol for you, it's helpfully exported. People
complain about the CL package system, but it could be oh so much
worse.

Another example would be the preposterous Module[] hack for creating
lexical scopes. Mathematica is a dynamically scoped language, but then
they went and made Module[] to allow you to use lexical scope, in
exactly the same gruesome way as the lexical-let macro from Emacs
Lisp's "cl" compatibility package. Except Mathematica doesn't even
have a real GENSYM, it just has GENTEMP---the "unique" symbols are
interned and thus not so unique at all.

I use Mathematica for my day job. I could literally go on like this
for hours. Once you get the hang of it you get used to it, and there
are enough things that work right that it's productive to work in. But
you feel like you're passing through a small New England town in an HP
Lovecraft story. Sure, it may be oozing lovely Colonial architecture,
but the people have freaking *gills*, man.

Cheers,
Pillsy
From: Thomas F. Burdick on
On Jan 12, 9:44 am, Norbert_Paul <norbertpauls_spam...(a)yahoo.com>
wrote:
> >> 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.
>
> No. It is a programmer error to odivide by zero (in LISP, in Java
> it's OK and returns infinty or NaN).

Nope. (/ 1 0) isn't required to signal an error, although it may.
IIRC, Java requires division by zero to throw an exception for
integers. And (/ 1 0.0) may return infinity, just like in Java. You
can control this in SBCL, for example, by calling sb-int:set-floating-
point-modes.
From: Norbert_Paul on
Kenneth Tilton wrote:
> Norbert_Paul wrote:
>> Kenneth Tilton wrote:
>>>> 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.
>> No. It is a programmer error to odivide by zero (in LISP, in Java
>> it's OK and returns infinty or NaN).
>
> "Or"? Java is not sure what to do? Does it choose between them at random
> at runtime? Meanwhile infinity is wrong and NaN... it does not throw an
> exception? So every time I do arithmetic I have to check the result to
> know ASAP when I have gotten into NaN Land? I thought Java was the "all
> exceptions all the time" language?
First what I said applies to floating point arithmetics only (my error,
I forgot to mention that).

Second,

{ -Infinity : a < 0
a/0.0d == { NaN : a == 0
{ +Infinity : a > 0

holds for all doubles a in Java (0.0d is 0d0 in LISP), so the result is
well-defined.

> I will hope and pray you have this all wrong. If a language is going to
> be bad, it should at least do so consistently.
Your prayers didn't succeed. It is only wrong with integers. Hence, it is
not *all* wrong.

> No, they didn't. First of all, you are mistaken. Lisp indeed is not sure
> what to do: the spec says the behavior is undefined.
> [...]
My error. I overlooked that.

> No, throwing an error is not handholding the programmer. What would you
> like Lisp to do given (/ 0)? It has to do something, right? It cannot
> return most-positive-fixnum, that is simply wrong although what many
> incompetents would lean towards. NaN is not bad but then I have to check
> for it everywhere. A division-by-zero condition is like a NaN return
> value except I can choose to handle it non-locally and still know where
> it happened. And unlike NaN, know /what/ happened.
The error signaling behavior is the best solution. So it is a pity that you
cannot rely on an error being signalled.
It can be OK to divide by zero and then return something representing 'INFINITY
It could also be allowed to do (/ 0 0) => 0 if 0 is the only number in
some context (look up "trivial ring").
In most cases, however, it is a programming error that should be noticed as
early as possible--for example by that unhadled error during testing.

> Happy Lisping.
thanks.