[erlang-questions] Type specs expressivity

Olivier BOUDEVILLE <>
Fri Sep 9 14:00:55 CEST 2011


Hi,

I would have three small questions regarding what can be expressed with 
type specs:

        - we can define immediate constants and even ranges for integer 
values (ex: '-spec f() -> 42.' or  '-spec f() -> 0..42.'), but apparently 
we cannot do the same for floats? Is there any particular reason for that 
(besides the lack of meaning of exact comparisons for floating-point 
numbers), or maybe it is a planned enhancement?

        - it is a still more minor point, but we are using a hashtable 
type in pure Erlang, which is implemented as a tuple containing buckets. 
The number of elements of the tuple is determined at run-time (depending 
on a targeted ideal load factor, based on the expected number of elements 
to be stored in the hashtable). We can define a type for bucket(), but for 
the hashtable is there any way of expressing a more precise declaration 
than  '-opaque hashtable() :: tuple()', i.e. to tell that even if we do 
not know the size of the tuple, we know it will contain bucket() instances 
at each position?

        - what is the recommended way of handling functions that may or 
may not throw exceptions? If otherwise returning a type T, should we use T 
| none() or T | no_return() as return type, or should we consider that 
type specs focus on actual return types under normal circumstances, and 
that exceptions are in "another dimension"? I suppose it is the latter 
option, but then one could imagine that type specs for functions could be 
enriched with exception specifications, for example to check whether a 
catch clause has any chance of being triggered at all?

Thanks in advance for any hint,
Best regards,

Olivier.
---------------------------
Olivier Boudeville

EDF R&D : 1, avenue du Général de Gaulle, 92140 Clamart, France
Département SINETICS, groupe ASICS (I2A), bureau B-226
Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 
65 27 13



Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme à sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse.

Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez reçu ce Message par erreur, merci de le supprimer de votre système, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions également d'en avertir immédiatement l'expéditeur par retour du message.

Il est impossible de garantir que les communications par messagerie électronique arrivent en temps utile, sont sécurisées ou dénuées de toute erreur ou virus.
____________________________________________________

This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval.

If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message.

E-mail communication cannot be guaranteed to be timely secure, error or virus-free.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110909/565b064a/attachment.html>


More information about the erlang-questions mailing list