Vacuum-tube Lisp

Started by m i c h a e l, May 25, 2008, 07:35:59 AM

Previous topic - Next topic

m i c h a e l

cormullion,



Loved your last post at unbalanced-parentheses: "http://unbalanced-parentheses.nfshost.com/vacuumtubelisp">Vacuum-tube Lisp." I really appreciated the quote from "Slug" in light of the recent car/cdr thread.



Inspired by a chapter in a now-forgotten book, I once intended to write a song about the cddr/cadadr permutations. Someday, maybe I'll get around to doing it :-)



Also, your joke about giving up writing because of us Hollywood types made me realize something: videos can cover subjects only superficially, while writing can explore those subjects in true depth. It's like the difference between movies and novels. Maybe one day, we'll witness someone writing the following blog entry, "The newLISP Introduction movie was okay, but it really didn't do cormullion's original justice" ;-)



m i c h a e l

Lutz

#1
I also enjoyed the post, but want to add this to make the resulting functions a bit faster.



Instead of:


(define (car x) (first x))
(define (cdr x) (rest x))


just do:


(define car first)
(define cdr rest)


or if you want to have them protected against change and global:


(constant (global 'car) first)
(constant (global 'crd) rest)


The new 'car' and 'cdr' now will behave just like the originals and with same speed.



While we at it, lets do something for a friendlier 'if' suggested in this group earlier::


(constant (global 'then) begin)
(constant (global 'else) begin)

; now you can do

(if condition
  (then ...)
  (else ...)
)

xytroxon

#2
Quote from: "Lutz"
While we at it, lets do something for a friendlier 'if' suggested in this group earlier::


(constant (global 'then) begin)
(constant (global 'else) begin)

; now you can do

(if condition
  (then ...)
  (else ...)
)


LOL... That's exactly what I have been using!

(After the "passionate" responses, I was kind of afraid to ask if that was the fastest form ;)



The above style is helpful while editing and creating code and helps me to quickly regain my focus in subsquent editing sessions... Even days later...



But I have started using this style, to ease my "Lisp-think" transition...

(if condition
  (then-begin ...)
  (else-begin ...)
)

Then I delete out the then- and else- after I have it working...



But still, this style:

(if condition
  (begin ...)
  (begin ...)
)

just looks to me like my code is "stuttering"...



And the ideal Lisp compressed form?
(if condition (begin ...)(begin ...))
It is so, hanging chad, 72 column Hollerith punch card looking to me...

(And we all know what problems hanging chads on Hollerith punch cards can be ;)



-- xytroxon
\"Many computers can print only capital letters, so we shall not use lowercase letters.\"

-- Let\'s Talk Lisp (c) 1976

Kazimir Majorinc

#3
I do not like "begin", because I wander why there is no "end". But I didn't replaced it yet.



But I happily replaced "lambda" with "function" and "lambda-macro" with "macro".
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

Lutz

#4
'lambda' and 'lambda-macro are the only reserved word, which cannot be replaced, but you can use 'fn' and 'fn-macro' instead, which are also built in.

cormullion

#5
thanks m i c h a e l !  Just feeling whimsical this weekend. :)

Kazimir Majorinc

#6
Quote from: "Lutz"'lambda' and 'lambda-macro are the only reserved word, which cannot be replaced, but you can use 'fn' and 'fn-macro' instead, which are also built in.


This is how I did it.



(set 'macro (lambda-macro()(eval (append '(lambda-macro) (args)))))

(set 'function (macro()(eval (append '(lambda) (args)))))



It works.
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

Lutz

#7
Nice solution! You even can take out the 'eval' and the quotes, because in newLISP lambda expressions evaluate to themselves ;-)


(set 'macro (lambda-macro() (append (lambda-macro) (args))))
(set 'function (macro() (append (lambda) (args))))

(set 'foo (macro (x y) (+ (eval x) (eval y))))

(foo 3 4) => 7

(set 'foo (function (x y) (+ x y)))

(foo 4 5) => 9