append demands a string

Started by kanen, April 21, 2010, 01:25:22 PM

Previous topic - Next topic

kanen

Most of newLISP is forgiving, not so with append.
newLISP v.10.2.4 on Linux IPv4 UTF-8, execute 'newlisp -h' for more info.

> (set 'foo 4)
4
> (println "foo is: " foo)
foo is: 4
4
> (println (append "foo is: " foo))

ERR: string expected in function append : foo
> (println (append "foo is: " (string foo)))
foo is: 4
"foo is: 4"
>
>


I consider this behavior to be inconsistent with the rest of newLISP's variable handling. Is it just me?
. Kanen Flowers http://kanen.me[/url] .

Kazimir Majorinc

#1
One specificity of Newlisp is that it has + and add, two different operators for two types of data, with automatic conversion if argument does not match type determined by function call.  



Sometimes, Newlisp doesn't convert automatically. For example (sym '(1 2)) returns error. (sym (string '(1 2))) works.



In append, type of the result is determined by first argument, with error if other arguments do not match the first one.



It appears that you suggest fourth approach, i.e. automatic conversion of other arguments to the first argument.



I'm more in favour of the fifth approach "don't do smart things behind my back". That means, default should be as it is now, and if one wants automatic conversion, there should be built-in or user defined function append-with-conversion which does that. As far as I know, Lutz doesn't apply that philosophy at all.



I guess it is up to Lutz to make strategic decision and gradually move toward consistency in that direction. But I think that, yes, your proposal is close to some general, forgiving spirit of the language.
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.