const a storage class or a type modifier?

Jens Mueller jens.k.mueller at gmx.de
Fri Nov 26 07:31:11 PST 2010


Michel Fortin wrote:
> On 2010-11-26 09:12:53 -0500, Jens Mueller <jens.k.mueller at gmx.de> said:
> 
> >So how do you like it to be?
> >void foo(const(int)*, char *, const(float)*);
> >or
> >void foo(const int*, char *, const float*);
> >
> >I still like the fixed original one namely
> >void foo(const(int)*, char *, const float*);
> 
> I don't really have a preference. Note that for function arguments,
> you can also use 'in' to mean const:
> 
> 	void foo(in int*, char *, in float*);
> 
> My opinion is that we have too much choice. When everyone can write
> the same thing differently it can easily become confusing.

Right. Definitely too much choice. So it becomes a matter of style and I
think the documentation should be in one consistent style. For
interfacing with C I prefer the const version over in. Because I
consider in and out to be like one pair of shoes. And since out doesn't
make sense when interfacing with C I don't like it.
But for non interfacing code one should use in/out because they are more
explicit than const.

Jens


More information about the Digitalmars-d mailing list