Le mercredi 16 novembre 2016 à 13:38 +0000, FANG Colin a écrit : > Is there going to be overhead if I create constant group modules and > use them via module_name.abc? Not that I know of.
Regards > On 16 November 2016 at 13:31, Milan Bouchet-Valat <nalimi...@club.fr> > wrote: > > Le mercredi 16 novembre 2016 à 04:18 -0800, FANG Colin a écrit : > > > Say, I have a few constants > > > > > > const VTYPE_BINARY = 'B' > > > const VTYPE_INTEGER = 'I' > > > const VTYPE_CONTINUOUS = 'C' > > > > > > What's a good way to have a namespace on it? > > > > > > So that I can use Vtype.BINARY, Vtype.INTEGER, Vtype.CONTINUOUS > > > > > > Should I put those in a separator module? or create a type and > > get an > > > instance of it? > > > > > > module Vtype > > > const .... > > > end > > > > > > immutable Vtype > > > BINARY::Char > > > INTEGER::Char > > > CONTINUOUS::Char > > > end > > > > > > const vtype = Vtype('B','I','C')? > > Putting it in a module is fine if you want to regroup these under > > the > > same namespace. That's the standard practice with enums too (when > > constants correspond to integer codes, which isn't the case here). > > > > > > Regards > > >