Changes in newLISP v.10.0 (previous init.lsp)

Started by cormullion, September 05, 2008, 08:32:55 AM

Previous topic - Next topic

Lutz

#15
I really mean dropping them. It has streamlined code for 'nth' and 'assoc' considerably, as the setter code was part of it. Dropping them made the remains of 'nth' and 'assoc' leaner and faster and there is less to learn. Keeping newLISP free of glut, fit and trim ;-)



Fortunately these four functions where used relatively rarely, so in the end the compatibility impact is not that big and we have a more unified approach using 'setf' for modifying lists and array by reference. Also more conform to what other programming languages do.



The 9.x.x series (really starting at v.8.9 two years ago) has been a constant explosion of new features. With version 10.0 it is time to consolidate and do some cleanup, where things have gone too messy in the language caused by rapid introduction of many new features (which was necessary).



ps: I changed the topic of the whole thread.

cormullion

#16
Quote from: "Lutz"Fortunately these four functions where used relatively rarely.


? True perhaps for assoc-set and set-assoc - they were relatively new - on my system only Jeff and Norman seem to have used it in their code. But nth-set (and to  some extent set-nth) are more widely used.



Perhaps it's just me that's surprised - perhaps other programming languages are constantly dropping core functions and changing existing ones.



I'll shut up now! :)

Lutz

#17
All programming languages go through sometimes major changes, and they all manage it differently.



On one extreme are languages, which never change, they get used, then eventually die out making place for new ones. Others change in major shifts, like Perl from version 3 to 4 to 5 to 6, or like Python 1 to 1.4 to 1.6 to 2 to upcoming 3.



newLISP always has followed a more evolutionary model in smaller steps, constantly changing but smaller shifts in-between versions. When you start converting your code e.g. identifying all 'nth-set' you will see its just not such a big deal and most of your code will keep running unchanged ;-)



What makes a language easier to use and learn and expressive is the degree to which words can be combined and work together in composites.



Reference returns and 'setf' do just that, allowing more composites between different built-in functions and in this way increasing the expressiveness of the language and the ease to learn it.



It also leads to more consistent and efficient code internally. Here an example:


(set 'L '(a b c))

(time (setf (nth 0 L) 'z) 1000000) => 207 ; in version 9.9.2
(time (setf (L 0) 'z) 1000000)     => 149 ; in version 9.9.2
(time (setf (first L) 'z) 1000000) => 126 ; in version 9.9.2

(time (nth-set 0 L 'z) 1000000)    => 301 ; in version 9.4.8
(time (nth-set (L 0) 'z) 1000000)  => 194 ; in version 9.4.8

L => (z b c) ; same result for all versions


Execution times are much faster for the composite idioms in the new version. All five make the same change to L, but the first three work by combining built-ins to new composites.



Look for 9.9.2 tomorrow :-)

cormullion

#18
My point has nothing to do with the changes - I welcome them (if there's a good reason for them)!



I'm more concerned with the transition process, which you seem anxious to minimize. It's important to be able to write code that runs on two or more releases. You're proposing dropping nth-set and introducing setf at the same release, aren't you? How could I write code that runs on either 9.4 or 10?

Lutz

#19
Here is a snippet from stat.lsp module which is distributed with newLISP:


(if (< (sys-info -2) 9902)
    (nth-set (ps 0) (div (first ps) 2))
    (setf (ps 0) (div (first ps) 2)))


I had to do this only twice but have all modules published on newlisp.org compatible for past and future version.



If you adhere strictly to the above syntax for 'nth-set' and you have many of those, you could do once at the beginning of old files:


(if (>= (sys-info -2) 9902)
    (constant 'nth-set setf))


or at the beginning of new files you write:


(if (< (sys-info -2) 9902)
    (constant 'setf nth-set))


Both, old and new files will than run on old and new newLISP.

   

In my own code I opted for the first solution, because I had very few places to change. If you have cases like the one Kazimir was referring to, like: (pop (sort lst)) and you relied on the pop to be nondestructive for lst, you would have to rewrite it to (first (sort lst)) to give the same result on both versions of newLISP. But those 'Kazimir' cases are very rarely occurring. I did not have even one in all of my code.



Ps: currently, Sept 14, http://www.newlisp.org">http://www.newlisp.org is down, probably because of scheduled IP-renumbering at the hosting site. Same seems to be true for http://unbalanced-parentheses.nfshost.com">http://unbalanced-parentheses.nfshost.com



- update: both sites just came back

Jeff

#20
Lutz,



When can we expect a dev release?  Also, will we be able to create our own reference functions by returning a list reference expression?  I.e.:


(define (my-first lst) (expand '(lst 0) 'lst))
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code