Page 1 of 1

newLISP coding form

Posted: Thu Apr 30, 2009 8:42 pm
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)
)

Posted: Thu Apr 30, 2009 9:14 pm
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))

Posted: Thu Apr 30, 2009 9:41 pm
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 ")".

Posted: Fri May 01, 2009 7:14 am
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

Posted: Fri May 01, 2009 10:52 am
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

Posted: Fri May 01, 2009 10:37 pm
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!

Posted: Fri May 01, 2009 10:43 pm
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...

Posted: Sat May 02, 2009 6:21 am
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

Posted: Sat May 02, 2009 12:46 pm
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

Posted: Sat May 02, 2009 5:34 pm
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! :)

Posted: Sat May 02, 2009 9:48 pm
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...

Posted: Sun May 10, 2009 5:36 pm
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).

Posted: Mon May 11, 2009 5:37 pm
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

Posted: Sun May 17, 2009 3:34 pm
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