The issue with the static access operator (the dot)

Would be in mine as well, instead of thing.vwoop(2) you can do MyTesting.vwoop(2, thing) (I’m using Erlang functionality, which puts the thing into the last slot as it should be, unlike Elixir’s weird way, and I cannot fix that, however I could swap it if it is detected in the last slot with ease though in the macro case generator).

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 Likes

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:

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

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