[erlang-questions] What is the best location to place common type specs?

Zhemzhitsky Sergey <>
Thu Jul 5 14:25:10 CEST 2012


Hello Loïc,

Thanks a lot for suggestions. 

Best Regards,
Sergey


-----Original Message-----
From: Loïc Hoguin [mailto:] 
Sent: Thursday, July 05, 2012 4:11 PM
To: Zhemzhitsky Sergey
Cc: 
Subject: Re: [erlang-questions] What is the best location to place common type specs?

Hello,

Your specs should belong to a single module. module1:myrec() isn't the same type as module2:myrec().

A bit off-topic but I wouldn't use a record over multiple modules (even though I've done it in the past, this is getting fixed). It's better to have your record belong to one module, make it opaque and to add functions to manipulate it without having to know what's in it. This way you can modify your record only in one place and not have to worry about breaking code everywhere.

On 07/05/2012 02:07 PM, Zhemzhitsky Sergey wrote:
> Hi guys,
>
> I have multiple .hrl files with multiple records. I’d like to define 
> separate types for these records and their fields.
>
> These records will be used across multiple modules, and I’m wondering 
> whether it is legal to define type specs in the hrl files?
>
> Or would it be better to have a separate module with exported common 
> type specs?
>
> Best Regards,
>
> Sergey
>
> _______________________________________________________
>
> The information contained in this message may be privileged and conf 
> idential and protected from disclosure. If you are not the original 
> intended recipient, you are hereby notified that any review, 
> retransmission, dissemination, or other use of, or taking of any 
> action in reliance upon, this information is prohibited. If you have 
> received this communication in error, please notify the sender 
> immediately by replying to this message and delete it from your 
> computer. Thank you for your cooperation. Troika Dialog, Russia.
>
> If you need assistance please contact our Contact Center (+7495) 258
> 0500 or go to www.troika.ru/eng/Contacts/system.wbp
>
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>


--
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu





More information about the erlang-questions mailing list