Immutability and other attributes, please review

Jacob Carlborg doob at me.com
Thu Jun 14 02:51:44 PDT 2012


On 2012-06-14 11:19, Roman D. Boiko wrote:
> I have not much experience in D programming yet, and one of things which
> I frequently mess up is usage of various attributes, especially
> immutable and related.
>
> Could anybody make a review my code at
> https://github.com/roman-d-boiko/functional-data-structures/blob/master/fds/persistent.d,
> https://github.com/roman-d-boiko/dct/blob/master/fe/syntax.d, and
> https://github.com/roman-d-boiko/dct/blob/master/fe/_/syntax.d with
> respect to usage of attributes (immutable, const, pure, etc.),
> contracts, and any other issues.
>
> I'm redesigning my previous coding attempts to build D compiler front
> end, and would like to pay attention to these aspects. Please note that
> adding DDoc comments has been deferred because I need to learn how to
> use them.

Just a note on the style. The convention is to but all attributes on 
front of the return type, except for "const", when "const" is referring 
to that the method is const and not the return type.

Another note.

class _Module : Module {...}

The underscore is unnecessary if you use fully quailed names:

class Module : fe.syntax.Module {...}

You can also use renamed imports or aliases.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list