ericmj

ericmj

Elixir Core Team

Typespecs to the rescue. Declare your types as opaque and users should know they shouldn’t depend on the structure. If they use dialyzer they will even get errors when matching on the structure or using the dot field access.

3
Post #21
DianaOlympos

DianaOlympos

BTW this is exactly how Liskov and Zilles handle types in their “Programming with Abstract Data Types” paper. So seems it has some reasons :stuck_out_tongue:

0
Post #22
Qqwy

Qqwy OP

TypeCheck Core Team

Yes, exactly! I feel like more library designers should be aware of this option, and should use this, in my opinion.

0
Post #23
OvermindDL1

OvermindDL1

Exactly what I said, this is why -opaque exists (er, @opaque in Elixir). ^.^

0
Post #24
— All posts loaded —