For a framework I’m writing I have to implement matcher functions, like e.g. equals (whicl tests for equality and also prints out what was expected to match if it doesn’t match).
The problem is I need to implement this for strings as well as integers (and probably arrays) and I don’t know how distinguish those functions based on their type. Some ideas are:
-
using some sort of prefix
integer_equals '1' '2' string_equals '1' '2' -
passing the type to the function
equals 'integer' '1' '2' equals 'string' '1' '2' -
separating the prefix with a . (dot)
string.equals '1' '2' integer.equals '1' '2'
Which one of these would fit best, i.e. which one would be the most idiomatic one or the least astoninishing?
I think your proposal 1 (string_equals) is the clearest and least surprising.