Thursday, April 09, 2009

[newLISP] reverse-find

I've always thought learning Lisp would be a good thing to do. The purists may argue that newLISP is not the best place to start. Oh well, too bad.

Below is my first (ever) lambda expression, a port of the VBScript RevInstr() function.

I must say I'm impressed with newLISP. Note that the minus (-) function above can receive more than one argument. A lot of the functions are like that.

Using the reverse-find is very like the (find) function, as below

One thing that differentiates my lambda expression from the in-built find, is in the manner in which an error is flagged.

I'm not sure at this point why the difference and what to do about it. In my use of (find) I check for a result equal to nil, but with (reverse-find) I have to check to see if the result is a string. For example,

Doubtless, someone in the
newLISP Fan Club will set me straight soon.

© Copyright Bruce M. Axtens, 2009


Kazimir Majorinc said...


Because your reverse-find at one moment does something like

( - 7 nil)

where nil is returned from find.

You have very interesting blog.

Anonymous said...

newLisp is not the best place to start. There are plenty of great Common Lisp and Scheme implementations to choose from.


(defun reverse-find (x seq) (find x seq :from-end t))



Kazimir Majorinc said...

I must disagree with Marco. I used all three as my primary programming languages for some time. By my experience, Newlisp is the simplest of the tree, and Scheme is simpler than Common Lisp. Only one Lisp dialect of the similar simplicity is Pico Lisp. Interested readers can check my blog for lot of examples of Newlisp code.

Anonymous said...

instead of:

(set 'reverse-find (lambda (...) ...))

you can just say:

(define (reverse-find ...) ...)

its the same :-)

cormullion said...

Hi Bruce - didn't realise you had newlisp entries on here... Hope you're having fun with the language...

I think newLISP is a great place to start - move on if and when you want to, not when others tell you.

I see you've met the grumpy (and easily upset) Common Lispers already. Don't worry, they can be safely ignored. Common Lisp is one of the very few languages that comes complete with an implementation of 'lisp condescension', This makes it particularly easy (apparently) to lapse into sneering at other people's interests.

Karenality said...

It's been years since I learned VBScript thru basic programming at school for my Web Development degree. I am now working for an Aerospace company and am in need of 2 VBScript snippets that will enable us to (We're coding 2 Macro-buttons) when the text is selected, for one block of text to turn blue when the button is pressed and the other button will turn the text red with a strike-thru. Thank you for any help you can give!

Anonymous said...

You're not learning real Lisp concepts with newLisp. For example, a key concept in Lisp is object identity. When you construct new aggregate objects out of existing ones, something called "substructure sharing" is going on. newLisp has a wacky "one reference only" memory management model which causes all objects to be copied. This is to avoid garbage collection. (However, newLisp does not avoid tracing! If you want to delete an object, scanning takes place to find that one object and replace it with nil.)

newLisp is also interpreted only, with a design that ensures it will be impossible to compile in the future, due to the reliance on "fexprs": a way of simulating macros that the Lisp culture abandoned more than three decades ago as being inferior, in favor a compiling approach.

newLisp eschews lexical scope in favor of dynamic scope. Lexical scoping is available through awkward namespace hacks that are explicit to the programmer. Real Lisp made the move to lexical scope in the 1960's, because lexical scoping is less error-prone and compiles to fast code. Scheme abandoned dynamic scope entirely. Common Lisp is lexically scoped by default, but support for dynamic scope, which has some nice advantages, is smoothly integrated into the language.

You really owe it to yourself to be learning with something standard. Both of the major Lisp dialects, ANSI CL and Scheme, are standard languages with numerous implementations. Why would you want to be stuck with a one-implementation, wacky, incompatible dialect.

newLisp is bad for Lisp because it brings back some wacky old crap that gave Lisp a bad reputation many decades ago. newLisp to Lisp is like Javascript to Java. Only, it calls itself "Lisp", which damages the real thing.

Lisp programmers have to regularly confront FUD about the language, which turns out to be based on someone's outdated knowledge based on memories of interactions with a poor implementation, or a strange dialect, and not the real Lisp!

If you ever develop a more serious interest, you will only have to "unlearn" quite a few things.

There is only only reason to ever work with a weird, incompatible Lisp dialect/implementation: you wrote it yourself. (That is a path to learning a lot.)

Also be aware that the website is full of embarrassing lies that a real software developer would be ashamed to say no matter how much he's in love with newLisp. There are inaccurate statements about Lisp, and also no objective discussions about the hidden tradeoffs of newLisp's design decisions.