funtions I wanted something that deleted itself after execution..
Sound logical indeed but correct me if im wrong but in previous
releases of newlisp you couldn't destroy yourself as being a variable
or function...
Seems that indeed now the destructive-save function 'copy is introduced
you can destroy yourself (finaly!..who doesnt want that ;-)
*edited* seems that for functions the 'copy isnt needed only
the 'catch is enough
there is
Code: Select all
(MAIN)-> (setq self-destruct (copy (delete 'self-destruct)))
true
(MAIN)-> self-destruct
nil
Code: Select all
(MAIN)-> (define self-destruct (catch (copy (delete 'self-destruct))))
?
(MAIN)-> self-destruct
nil
Code: Select all
(MAIN)-> (define (self-destruct) (catch (copy (delete 'self-destruct))))
(lambda () (catch (copy (delete 'self-destruct))))
(MAIN)-> (self-destruct)
true
(MAIN)-> (self-destruct)
ERR: invalid function : (self-destruct)
(MAIN)-> self-destruct
nil
And namespaced
Code: Select all
(MAIN)-> (define (self:destruct) (catch (copy (delete 'self:destruct))))
(lambda () (catch (copy (delete 'self:destruct))))
(MAIN)-> (self:destruct)
true
What surprices me is that 'Catch indeed catches here the error, because if you dont the function will crash newlisp..
The '?' is probably a tiny bug? Or is it indeed a BIG Question to newlisp ;-)