D-etractions A real world programmers view on D

Steven Schveighoffer schveiguy at yahoo.com
Thu Aug 30 06:35:31 PDT 2012


On Sat, 25 Aug 2012 15:39:14 -0400, Walter Bright  
<newshound2 at digitalmars.com> wrote:

> On 8/25/2012 6:03 AM, Peter Alexander wrote:
>> Okay, so bitfields are rarely used, but many templates involve some use  
>> of CTFE,
>> and templates are very common in D code. It's good that D's parser is  
>> fairly
>> simple to implement (compared to C++ anyway), but to do automated  
>> refactoring
>> you need simple semantic analysis, and this is something that D does  
>> not have.
>
> How many IDEs can handle the C preprocessor, with token pasting and all,  
> when refactoring?

Not any that I have used.  In fact, in one project that I was working from  
an existing code base, I had to configure Visual Studio 2010 to NOT fade  
out what it thought was commented code, because it was wrong.  Otherwise,  
it was too distracting.

Here is what I think:

1. an IDE can be built that refactors non-meta-generated code quite well,  
D is easily parsed.
2. Said IDE can be provided hooks so when it does encounter mixins, it can  
be told what things mean.

For example, I use netbeans to write php -- a dynamic language.  There are  
no real variable type declarations, so when you start typing,  
auto-complete sucks unless you have told the IDE what a variable is.  You  
do so like this:

/**
  @var Type
  */
var $varname;

And now the IDE assumes you have stored a Type into $varname, so when you  
type $this->varname->, it completes with the members of Type.  Without the  
comment, I get nothing.

A similar approach could be taken with mixins, like bitfields.  You  
identify what the parameters to the mixin are, and then the IDE can take  
appropriate actions.

For things like bitfields, which are considered core language constructs  
in phobos, the IDE may actually be made more intelligent and detect this  
automatically.

I don't think this is an unsolvable problem...

-Steve


More information about the Digitalmars-d mailing list