Should Different-Typed Comparisons Be Less Friendly?

I've historically been on the side of saying that I don't think it's good for types of different categories to compare equally, e.g. <foo> = "foo" being true can cause some headaches.

But these headaches can work the other way as well. I just had a bug where I was passing something as a string, but the caller was comparing it as a WORD!.

 if info.name = 'startup* [
     ...  ; it was a string, so actually "startup*"
 ]

This makes me wonder if different-typed comparisons need some distinction in the comparison, to help say that you know the type you're comparing against is completely different.

if info.name =T 'startup* [
   ;
   ; ugly example... but imagine =T is a way of saying "I know the type
   ; should be the type on the right (e.g. WORD!), so tell me if it is
   ; not...
]

>> 'foo =T 'bar
== #[false]

>> "foo" =T 'bar
** Error: =T expected a WORD! on the left but got a TEXT!

It's always the latest such bug to bite you in languages of this nature that make you wish for stricter typing policies. :frowning:

2 Likes