funcool

A channel for discussing and asking questions about Funcool libraries https://github.com/funcool/
serioga 2016-09-18T08:34:04.000020Z

It should return false or true if all parameters are nil

niwinz 2016-09-18T09:16:12.000021Z

thanks @serioga, my first approach is return nil

niwinz 2016-09-18T09:16:25.000022Z

just for consistency and nil punning approach of the whole library

niwinz 2016-09-18T09:16:46.000023Z

if the first parameter is not string it just return nil instead of raising NPE

niwinz 2016-09-18T09:17:21.000024Z

example: (starts-with? nil "foobar") => nil

niwinz 2016-09-18T09:18:00.000025Z

the confusion will come that caseless= has very different semantics to the clojure = operator

niwinz 2016-09-18T09:18:21.000026Z

caseless= only works with strings and clojure = works with all types.

niwinz 2016-09-18T09:18:48.000027Z

so, I consider does not return true in case where (caseless= nil nil)

niwinz 2016-09-18T09:19:23.000028Z

In fact right now in the latest published snapshot it returns nil (`(caseless= nil nil) => nil`)

serioga 2016-09-18T09:30:05.000029Z

> In fact right now in the latest published snapshot it returns nil (`(caseless= nil nil) => nil`) maybe. but for (caseless= nil "foobar") I expect false the analogy with starts-with?looks wrong

serioga 2016-09-18T09:33:03.000030Z

> caseless= only works with strings it depends if it includes nilable or not I don't see a reason to disallow nilable strings for comparison

serioga 2016-09-18T09:34:03.000031Z

Maybe caseless= require options argument to define a behavour 🙂

serioga 2016-09-18T09:35:10.000032Z

Or maybe it should raise an exception for invalid arguments

serioga 2016-09-18T09:36:57.000033Z

well, returning nil if arguments are invalid is like an exception. usually I don't expect nils from predicates

serioga 2016-09-18T09:37:51.000034Z

how caseless= works in case if some arg is int?

niwinz 2016-09-18T09:57:59.000035Z

in same way as it is nil

niwinz 2016-09-18T09:59:13.000036Z

take cara that at this moment, cuerdas handles the nil or wrong input in a consistent manner around the library

niwinz 2016-09-18T09:59:32.000037Z

if the main argument is not string, it just return nil

niwinz 2016-09-18T10:00:17.000039Z

that in boolean comparisons is considered false

niwinz 2016-09-18T10:00:46.000040Z

(boolean (caseless= nil "foobar")) => false

serioga 2016-09-18T10:26:29.000041Z

> take cara that at this moment, cuerdas handles the nil or wrong input in a consistent manner around the library in this case your initial question has no sense 🙂

niwinz 2016-09-18T10:31:57.000042Z

The initial question is about the similarity of the caseless= with = and the possible confusion with (= nil nil) => true and (caseless= nil nil) => nil

niwinz 2016-09-18T10:40:39.000044Z

In any case thanks!

serioga 2016-09-18T10:46:33.000045Z

welcome 👌