From d3f65674a1eecb6da083b2ba9507a8305b361dbc Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 27 Oct 2014 23:13:30 +0900 Subject: [PATCH] Added new type alias syntax as a preference Added elaboration based on comments received Fix syntax errors --- dstyle.dd | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/dstyle.dd b/dstyle.dd index d249f32c3e..b766f9d820 100644 --- a/dstyle.dd +++ b/dstyle.dd @@ -130,9 +130,41 @@ 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; @@ -140,7 +172,7 @@ alias INT = int; alias pint = int*; ------------------------------- - $(P should be avoided.) + $(P ... should be avoided.) $(H3 Declaration Style)