Re: Comparing Sequences
To Derek (and others):
Derek wrote:
>>
For example...
function tester(atom X, atom Y)
return (functionOne(X) = functionTwo(Y))
end function
There is no way you can tell if this function returns an atom or a sequence,
unless you find out what functionOne() and functionTwo() return.
Is this a problem? Maybe, maybe not. Just thought I'd mention it though.
<<
I've noticed this a long time ago, but it isnt an issue of comparison.
For example, take the same function 'tester' and simplify it:
function tester(atom X)
return functionOne(X)
end function
and still cant tell what tester() returns.
I wont go as far as to say its a problem though, as it does allow one
to return 'objects', a 'feature' i wouldnt want to go without.
Second point:
Some functions are better off with the ability to return an object,
rather then a particular sub type (atom, sequence).
For example:
--Sqrt(object a) is a function that returns the sqrt of a number with
-- real or complex result
object x,a
a=4
x=Sqrt(a) --returns 2
a= -4
x=Sqrt(a) --returns {0,2}
a={-3,4)
x=Sqrt(a) --returns {1,2}
Here the return value depends on the users input and has to be
an atom or a sequence. Thats one reason why i like to be able to
retain the ability to return objects. I think this is an advanced
feature of the language. True you could default to all sequences,
but i think then that would over-complicate the calculations on
simple numbers.
BTW im in favor of extending the syntax to allow comparisons on
sequences as well i.e.
"Thisa"="Thata" returns false
"Thisa"=This" returns false
"This"="" returns false
""="" returns true
{"This","That"}={"This"} returns false
"A"={65} returns true
'A'={65} returns false
"AB"={65,66} returns true
etc.
although i would like to see the double equal sign come in like other
languages:
if "This"=="That" then
dosomething()
end if
making comparisons stand out from assignments a bit more.
--Al
ps. i should be posting a math library soon that has many more examples.
|
Not Categorized, Please Help
|
|