Skip to content

Commit

Permalink
Merge pull request #682 from JinShil/patch-1
Browse files Browse the repository at this point in the history
Added new type alias syntax as a preference
  • Loading branch information
MartinNowak committed Nov 14, 2014
2 parents 74592a8 + d3f6567 commit 26f94d5
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions dstyle.dd
Expand Up @@ -130,17 +130,49 @@ ubyte asciiChar;

)

$(H3 Meaningless Type Aliases)
$(Type Aliases)

$(P Things like:)
$(P The D programming languages offers two functionally equivalent syntaxes for type aliases, but ...)

-------------------------------
alias size_t = uint;
-------------------------------

$(P ... is preferred over ...)

-------------------------------
alias uint size_t;
-------------------------------

$(P ... because ...)

$(UL
$(LI It follows the already familiar assignment syntax intead of the inverted typedef syntax from C)
$(LI In verbose declarations, it is easier to see what is being declared)
)

-------------------------------
alias important = someTemplateDetail!(withParameters, andValues);
alias Callback = ReturnType function(Arg1, Arg2) pure nothrow;
-------------------------------

$(P vs.)

-------------------------------
alias someTemplateDetail!(withParameters, andValues) important;
alias ReturnType function(Arg1, Arg2) pure nothrow Callback;
-------------------------------


$(P Meaningless type aliases like ...)

-------------------------------
alias VOID = void;
alias INT = int;
alias pint = int*;
-------------------------------

$(P should be avoided.)
$(P ... should be avoided.)

$(H3 Declaration Style)

Expand Down

0 comments on commit 26f94d5

Please sign in to comment.