newLISP coding form

Started by dukester, April 30, 2009, 01:42:20 PM

Previous topic - Next topic

dukester

Would the following offend an old-salt  LISPer?




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

Kazimir Majorinc

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


(map (fn (value3)
         (println "Item " (+ $idx 1) "=  " value3))
     (sequence 25 20))
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

dukester

#2
Quote from: "Kazimir Majorinc"I do not use Newlisp long time but it looks OK to me. You can use $idx also.


(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

#3
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

#4
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 ;~(space) which also helps my eyes easily see that it is not a just a normal comment...

(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 much cooler looking 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

#5
Quote from: "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


Thanks for that observation - I hadn't noticed. Answers my question!
duke

dukester

#6
Hey xytroxon...


Quote from: "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...


[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

#7
Quote from: "dukester"Hey xytroxon...


Quote from: "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...


[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">//http://www.scintilla.org/SciTE.html



SciTE download page:

http://www.scintilla.org/ScintillaDownload.html">//http://www.scintilla.org/ScintillaDownload.html



You can replace the lisp properties file, Kazimir Majorinc has one for newLISP on his blog page: http://kazimirmajorinc.blogspot.com/2008/06/lispproperties-for-scite.html">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

#8
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">http://en.wikipedia.org/wiki/Notepad%2B%2B
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

cormullion

#9
Quote from: "xytroxon"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:




   (define index? 1
   )

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

      (sequence 25 20
      )

   )


which is occasionally useful! :)

dukester

#10
Quote from: "xytroxon"You can replace the lisp properties file, Kazimir Majorinc has one for newLISP on his blog page: http://kazimirmajorinc.blogspot.com/2008/06/lispproperties-for-scite.html">Click here.

Thnaks for the URLs. I'll be giving SciTe a test-drive real soon. Best...
duke

shercipher

#11
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

#12
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

#13
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
Programmer since 1987. Unix environment.