From: metaperl.com
Subject: code review request : redick array processing library
Date: 
Message-ID: <77cdba6e-bd00-4ab7-bac8-171ae6c0e384@i29g2000prf.googlegroups.com>
Okey dokey, the framework for rank-sensitive Lisp functions is now in
place. First a brief demo of the working functionality:

; SLIME 2006-04-20
CL-USER> (load "load.lsp")
T
CL-USER> (in-package :redick)
#<PACKAGE "REDICK">
REDICK> (setf a (array-iota 2 2))
#2A((0 1) (2 3))
REDICK> (double a)
#2A((0 2) (4 6))
REDICK> (set-array! a (lambda (x) (random 50.0)))
#2A((12.123537 48.862587) (3.3986747 38.05262))
REDICK> (floor_ a)
#2A((12 48) (3 38))
REDICK>

Ok, now. What I would appreciate is a review of the code implemented
so far.

You can get the whole distro:

   hg clone http://hg.metaperl.com/redick

Or just browse it online:

   http://hg.metaperl.com/redick?mf=2a63ddac72f3;path=/lisp/;style=gitweb

I would like to present the heart of the entire framework inline here.

Here is the double file which works regardless of array rank:
(in-package :redick)

(defconstant double-rank 0
  "The rank of the verb double is 0. This means that even though the
public
function takes data of any rank, the core function expects data of
rank 0, or atoms"
  )

(defun double-core (n)
  "Input is a number and the output is twice the number"
  (+ n n))

(defun double (data)
  "Input is a numeric atom or n-dimensional array.
Output is the same datum with all data cells doubled"
  (monad-apply #'double-core data double-rank))

And monad-apply is the function (in lisp/monad/apply.lsp) which
applies the rank-insensitive core function to data in  rank it can
handle:

#|
http://jsoftware.com/help/jforc/loopless_code_i_verbs_have_r.htm#_Toc141157986
|#

(in-package :redick)

(defun monad-apply (verb noun verb-rank)
  (let* ((noun-rank (noun-rank noun))
	 (r (min noun-rank verb-rank))
	 (f (calc-frame noun r))
	 (result-array (make-array (frame-shape f)
				   :displaced-to noun
				   )	   )
	 (linear-result-array
	  (make-array
	   (array-total-size result-array) :displaced-to result-array))
	 (side-effect
	  (map-into linear-result-array verb linear-result-array))
	 )
    result-array))

From: Geoff Wozniak
Subject: Re: code review request : redick array processing library
Date: 
Message-ID: <73904cda-9347-48f7-a929-ef0b7e6d93dd@s19g2000prg.googlegroups.com>
On Dec 13, 11:55 pm, "metaperl.com" <········@gmail.com> wrote:
> You can get the whole distro:
>
>    hg clonehttp://hg.metaperl.com/redick
>

Some cursory thoughts upon a cursory look:

- What is the significance of the name of the package?  It doesn't
tell me anything about what the point to the package is.  (Note, I'm
guilty of this as well.  Good names can be difficult to come up
with.)  I should note that I parsed "redick" as "re-dick", which not
only makes no sense, but would be considered obscene in some company.

- Perhaps you should consider using ASDF instead of something like
load.lsp.  ASDF is pretty commonplace these days and frankly, it's a
lot easier to work with than manually loading files.  It's worth the
time to learn the basics of ASDF:DEFSYSTEM.  Many good resources can
be found on the CLiki page: http://www.cliki.net/asdf

- The line

  (declaim (optimize (debug 3) (safety 3)))

in ./load.lsp doesn't strike me as a good idea.  I'm guessing this was
added because of another discussion you raised regarding debugging
issues in SBCL.  What if I don't care about safety and debugging when
I compile your code?  Furthermore, the effects of that line outside of
that file are unspecified according to the HyperSpec, so it may make
litlte to no difference at all.

See: http://www.lispworks.com/documentation/HyperSpec/Body/m_declai.htm

- There are an awful lot of files there with very little code in
them.  Seems simpler to have it all in one file, but perhaps that's
more a personal preference than anything else. (Maybe I'm missing
something...)

- The .lsp file extension is not one I've come across very often.  Is
there a compelling reason to leave out the 'i'?
From: livingcosmos.org
Subject: Re: code review request : redick array processing library
Date: 
Message-ID: <48fed0d6-a89d-4f68-bfba-89a69e1ec6e0@i12g2000prf.googlegroups.com>
On Dec 14, 5:06 pm, Geoff Wozniak <·············@gmail.com> wrote:

>
> Some cursory thoughts upon a cursory look:
>
> - What is the significance of the name of the package?

This project started as a Java implementation of J ... hence JJ was
obvious, but the most famous JJ? Why JJ Redick of Duke University

It had its second incarnation in Scheme. After doing 90% of the monads
in Scheme, I simply quit using chicken scheme. Common Lisp is very
fast. The array library is standard and uses much J terminology. Also
Lisp comes with all the trimmings from the get-go. So the 3rd
incarnation begins...

> It doesn't
> tell me anything about what the point to the package is.  (Note, I'm
> guilty of this as well.  Good names can be difficult to come up
> with.)  I should note that I parsed "redick" as "re-dick", which not
> only makes no sense, but would be considered obscene in some company.

googlegroups prevents any new group with name "dick" in it. But google
projects does not - http://code.google.com/p/redick/


>
> - Perhaps you should consider using ASDF instead of something like
> load.lsp.  

yes, this is the 2nd time i've been told this. So it's time to go
horizontal once again. Learn more Common Lisp and then back to coding.
Scheme, Chicken Scheme, had no package system or complex ASDF-like
thing. So I was just coding full speed ahead. But all of the
infrastructure in CL is time-tested and worth these break
intermezzoes.

>
> - The line
>
>   (declaim (optimize (debug 3) (safety 3)))
>
> in ./load.lsp doesn't strike me as a good idea.  

Ok, removed.

>
> - There are an awful lot of files there with very little code in
> them.  Seems simpler to have it all in one file,

If you look at the coding style, each verb (j terminology for
function) has quite a bit of machinery around it. I prefer to isolate
it.

> - The .lsp file extension is not one I've come across very often.  Is
> there a compelling reason to leave out the 'i'?

hmm, no. but Emacs recognized it as Lisp, so I'm happy with it. I was
looking for more comments on the infrastructure I'm using for each
verb, like shown here -

http://hg.metaperl.com/redick?f=b7d829aed11d;file=lisp/monad/double.lsp;style=gitweb
From: Geoff Wozniak
Subject: Re: code review request : redick array processing library
Date: 
Message-ID: <f9b29712-81f7-4d23-8cf9-f443269ebc1c@p1g2000hsb.googlegroups.com>
On Dec 14, 9:53 pm, "livingcosmos.org" <········@gmail.com> wrote:
> On Dec 14, 5:06 pm, Geoff Wozniak <·············@gmail.com> wrote:
> > - The .lsp file extension is not one I've come across very often.  Is
> > there a compelling reason to leave out the 'i'?
>
> hmm, no. but Emacs recognized it as Lisp, so I'm happy with it.

Just a personal pet peeve, possibly of no great importance really, but
I like full, descriptive words when possible.  (Using .lisp seems
reasonable, but maybe .PortableDocumentFormat is a bit much.)
Sticking to the DOS 8.3 approach smacks of an anachronism.

> I was looking for more comments on the infrastructure I'm using for each
> verb, like shown here -
>

Like I said, it was only a cursor look. :)  If I get more time, I'll
look closer.
From: Raffael Cavallaro
Subject: Re: code review request : redick array processing library
Date: 
Message-ID: <200712142055548930-raffaelcavallaro@pasdespamsilvousplaitmaccom>
On 2007-12-14 17:06:59 -0500, Geoff Wozniak <·············@gmail.com> said:

>  I should note that I parsed "redick" as "re-dick", which not
> only makes no sense,

I think John Wayne Bobbit might disagree:
<http://en.wikipedia.org/wiki/John_Bobbitt>



> but would be considered obscene in some company.

granted ;^)
From: Geoff Wozniak
Subject: Re: code review request : redick array processing library
Date: 
Message-ID: <d5e7a30e-8d6c-45a3-9d2a-0d6f7dd46297@d21g2000prf.googlegroups.com>
On Dec 14, 8:55 pm, Raffael Cavallaro <················@pas-d'espam-
s'il-vous-plait-mac.com> wrote:
> On 2007-12-14 17:06:59 -0500, Geoff Wozniak <·············@gmail.com> said:
>
> >  I should note that I parsed "redick" as "re-dick", which not
> > only makes no sense,
>
> I think John Wayne Bobbit might disagree:
> <http://en.wikipedia.org/wiki/John_Bobbitt>
>

OK, now that's funny. You got me there. :-)
From: Rob Warnock
Subject: Re: code review request : redick array processing library
Date: 
Message-ID: <Eq6dnbbHG9VZm_janZ2dnUVZ_vWtnZ2d@speakeasy.net>
Geoff Wozniak  <·············@gmail.com> wrote:
+---------------
| - The .lsp file extension is not one I've come across very often.
|   Is there a compelling reason to leave out the 'i'?
+---------------

Besides, at least two web infrastructure projects already
used the ".lsp" extension to mean "Lisp Server Pages":  ;-}

    http://www.cliki.net/Lisp%20Server%20Pages

which refers to these:

    http://sourceforge.net/projects/lsp/

    http://www.lemonodor.com/archives/000128.html


-Rob

p.s. Hmmm... The Mishra/Bradshaw LSP seems to have
morphed into XMLP, and then into hybernation. (Tim?)

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607