Using __MODULE__ in protocol implementation

protocols

#1

Hi all,

when I am trying to use __MODULE__ alias in protocol implementation (functions inside the defimpl block), it’s complaining, that <MyProtocol>.<MyModule>.__struct__ is undefined, cannot expand struct.

Should I use the literal name of the module everywhere or is there some better approach for DRYing the code?

Thanks. :slight_smile:


#2

There are the @protocol and @for module attributes. :slight_smile:


#3

Oh, perfect, thank you @josevalim :slight_smile: