> On 08 Aug 2016, at 03:36, Paul Schoenfelder <[email protected]> 
> wrote:
> 
> Just my two cents, but why would this function return atoms instead of -1, 0, 
> 1? Then it works easily with sorting functions, and is consistent with 
> compare implementations in other languages.

There’s no sorting function that accepts -1, 0, 1 - sorting functions in 
Erlang/Elixir accept a binary function that returns true if the arguments are 
in correct order and false otherwise. The choice of numeric values or atoms is 
not clear. There are languages on both sides - haskell uses ADT for Ord 
typeclass, which would correspond to the atoms I’ve proposed. Integers might be 
more familiar for people coming from imperative/OO languages.

> 
> I can say I've seen multiple people make the mistake of trying to use the 
> comparison operators with structs in Timex, even though there is a compare 
> function in the API. I really only see this working if the compare operators 
> use the protocol.

We probably can’t change the comparison operator, since it’s a built-in. If we 
change it, it wouldn’t work in guards.

> 
> If the decision of including a protocol in standard library is because of 
> issues for doing conflict resolution for protocols then we need to improve 
> protocols and not add more protocols to the language. The latter solves the 
> issue only for the protocols added as part of the language while we leave 
> everyone else hanging.
> 

It’s not just that. If the protocol would be a package, I would never use it 
when writing another package - simply in the vain of avoiding dependencies. I 
only see usefulness of such protocol if it’s commonly used. It’s a similar case 
with calendar types - they could work as a package, but that would just create 
another standard - I feel like it’s a perfect example of https://xkcd.com/927/

Michał.

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/0C3321BB-DC04-4521-90D4-EC5F8C9B44EE%40muskala.eu.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to