Tips and Tricks for D

Henrik Eneroth Henrik_member at pathlink.com
Mon Jul 3 03:21:21 PDT 2006


In article <e89hsn$1rvh$1 at digitaldaemon.com>, mclysenk at mtu.edu says...
>
>(Not sure if this belongs in announcements)
>
>I've recently written up an article for intermediate and beginning D
>programmers.  
>
>In it I discuss some basic tricks, covering:
>+ printf
>+ import scope
>+ struct initialization
>+ converting static arrays
>+ removing objects from dynamic arrays
>
>You can read it at http://www.assertfalse.com/articles/tricks.shtml .
>
>Any comments, questions, suggestions or other feedback is welcome!
>
>-Mikola Lysenko
>
>

Useful stuff! 
A question about structs: I have in many cases used classes over structs because
of the lack of constructors in structs. Performance-wise, is it always better to
use structs over classes if you can? Or will a class where no virtual functions
etc. are used be similar to a struct performance-wise?
Also, if structs are copy-by-value, could this lead to unnecessary memory
allocations in those cases where just passing a reference (i.e. classes) would
do? That is, would classes be a better choice in this case?

/// Henrik





More information about the Digitalmars-d-learn mailing list