newLISP coding form

Pondering the philosophy behind the language
Locked
dukester
Posts: 115
Joined: Tue May 08, 2007 1:06 pm
Location: Alberta, Canada

newLISP coding form

Post by dukester »

Would the following offend an old-salt LISPer?

Code: Select all

(define index? 1)
(map (fn (value3)
	     (println "Item " index? "=  " value3)
	     (inc index?)
     )
(sequence 25 20)
)
duke

Kazimir Majorinc
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia
Contact:

Post by Kazimir Majorinc »

I do not use Newlisp long time but it looks OK to me. You can use $idx also.

Code: Select all

(map (fn (value3)
         (println "Item " (+ $idx 1) "=  " value3))
     (sequence 25 20))

dukester
Posts: 115
Joined: Tue May 08, 2007 1:06 pm
Location: Alberta, Canada

Post by dukester »

Kazimir Majorinc wrote:I do not use Newlisp long time but it looks OK to me. You can use $idx also.

Code: Select all

(map (fn (value3)
         (println "Item " (+ $idx 1) "=  " value3))
     (sequence 25 20))
I should have been clearer in my message! I was referring to my "style" of coding -- more specifically the indenting and seperating some of the closing ")".
duke

m i c h a e l
Posts: 394
Joined: Wed Apr 26, 2006 3:37 am
Location: Oregon, USA
Contact:

Post by m i c h a e l »

duke,

There is no single, correct way to format newLISP code. Do whatever makes it easier for you to understand the code's structure. Lutz intentionally uses various code formats in the manual to help encourage freedom in this area.

m i c h a e l

xytroxon
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm
Contact:

Post by xytroxon »

I like to do the open form of parens... It is easier to see what I am doing and easy to add or remove lines of code...
And I keep debug code lines to the far left margin, that helps them stand out better in my code...
With the SciTE editor, I can activate or deactivate debugging code via SciTE's Ctrl-Q comment toggle, which I have setup the comment as being <b>;~(space)</b> which also helps my eyes easily see that it is not a just a normal comment...

Code: Select all

(define (myfunc)
    (dowhile ...)
        (code line...)
;~ (println "some info") ;<--- debugging line inactive
        (code line...)
    )
    (code line...)
(println "some info") ;<--- debugging line active
    (code line...)
)
Also I call the open form "dragonfly parens" because: dragonflies are "Slender-bodied non-stinging insect having iridescent wings that are outspread at rest; adults and nymphs feed on mosquitoes etc."...

While the folded up LISP/Scheme form is called "damselfly parens" because: damselflies are "Slender non-stinging insect similar to but smaller than the dragonfly but having wings folded when at rest"

Which is better? Well... We all know that dragonflies are <i>much cooler looking</i> than damselflies ;o)

-- xytroxon
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976

dukester
Posts: 115
Joined: Tue May 08, 2007 1:06 pm
Location: Alberta, Canada

Post by dukester »

m i c h a e l wrote:duke,

There is no single, correct way to format newLISP code. Do whatever makes it easier for you to understand the code's structure. Lutz intentionally uses various code formats in the manual to help encourage freedom in this area.

m i c h a e l
Thanks for that observation - I hadn't noticed. Answers my question!
duke

dukester
Posts: 115
Joined: Tue May 08, 2007 1:06 pm
Location: Alberta, Canada

Post by dukester »

Hey xytroxon...
xytroxon wrote:I like to do the open form of parens... It is easier to see what I am doing and easy to add or remove lines of code...
[snip all the good stuff]

Now I know what my prefered form is called ;) I agree with you totally - and I've always wanted to try SciTe. Does it have a newLISP "mode" for syntax highlighting?
Thanks again...
duke

xytroxon
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm
Contact:

Post by xytroxon »

dukester wrote:Hey xytroxon...
xytroxon wrote:I like to do the open form of parens... It is easier to see what I am doing and easy to add or remove lines of code...
[snip all the good stuff]

Now I know what my prefered form is called ;) I agree with you totally - and I've always wanted to try SciTe. Does it have a newLISP "mode" for syntax highlighting?
Thanks again...
SciTE homepage:
http://www.scintilla.org/SciTE.html

SciTE download page:
http://www.scintilla.org/ScintillaDownload.html

You can replace the lisp properties file, Kazimir Majorinc has one for newLISP on his blog page: Click here.

Copy all lines from:

# Define SciTE settings for Newlisp files.

to the end of the post just before "Comments"

Paste and save into a new file named lisp.properties
and replace the old one in the scite directory.

Comments in the post tell how to change the colors...

-- xytroxon
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976

Kazimir Majorinc
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia
Contact:

Post by Kazimir Majorinc »

Those who use Windows and like Scite can also try Notepad++ which looks like more sophisticated editor built around same Scintilla "engine", and it allows more (or all?) customization through GUI.

http://en.wikipedia.org/wiki/Notepad%2B%2B

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

xytroxon wrote:Also I call the open form "dragonfly parens" because: dragonflies are "Slender-bodied non-stinging insect having iridescent wings that are outspread at rest; adults and nymphs feed on mosquitoes etc."...

While the folded up LISP/Scheme form is called "damselfly parens" because: damselflies are "Slender non-stinging insect similar to but smaller than the dragonfly but having wings folded when at rest"
Excellent!!

I tinker with auto-formatting code sometimes. I have an extremely aggressive dragonfly mode for nestor:

Code: Select all


   (define index? 1
   ) 

   (map 
      (fn 
         (value3
         ) 
        
         (println "Item " index? "=  " value3
         ) 
        
         (inc index?
         ) 
     
      ) 

      (sequence 25 20
      ) 

   )
which is occasionally useful! :)

dukester
Posts: 115
Joined: Tue May 08, 2007 1:06 pm
Location: Alberta, Canada

Post by dukester »

xytroxon wrote:You can replace the lisp properties file, Kazimir Majorinc has one for newLISP on his blog page: Click here.
Thnaks for the URLs. I'll be giving SciTe a test-drive real soon. Best...
duke

shercipher
Posts: 15
Joined: Sun May 10, 2009 3:11 am

Post by shercipher »

I'm knew CL first, so the closing ) on their own lines looks wrong to me. Stacking parentheses on the end of lines has always seemed the logical thing to do (unlike }'s, which look ugly when stacked together).

m35
Posts: 171
Joined: Wed Feb 14, 2007 12:54 pm
Location: Carifornia

Post by m35 »

The number two thing I like about newLISP (first being the fact it takes no effort to install and start using) is that the community doesn't care how you write your parenthesizes. Do what works best for you and enjoy :D

Tim Johnson
Posts: 253
Joined: Thu Oct 07, 2004 7:21 pm
Location: Palmer Alaska USA

Post by Tim Johnson »

I like the CL style - for deployment. But I find a more open "dragonfly" style
easier to modify. Begs for an editor macro that could compress or
decompress a region.
tim

Locked