Inherent code performance advantages of D over C?

Manu turkeyman at gmail.com
Mon Dec 9 19:04:53 PST 2013


On 10 December 2013 12:32, H. S. Teoh <hsteoh at quickfur.ath.cx> wrote:

> On Tue, Dec 10, 2013 at 02:42:05AM +0100, deadalnix wrote:
> > On Sunday, 8 December 2013 at 05:37:09 UTC, H. S. Teoh wrote:
> > >Or maybe this is just another one of those cultural old age
> > >indicators?  Has the term "refactoring" shifted to mean "variable
> > >renaming" among the younger coders these days? Genuine question. I'm
> > >baffled that these two things could even remotely be considered
> > >similar things.
> > >
> >
> > Refactoring is changing your code, without changing what it does. It
> > is done in order to make your code easier to understand, more
> > maintainable, more testable, or whatever.
> >
> > Both extracting some code into a function and renaming a variable
> > are refactoring operations.
>
> OK, but isn't renaming among the more trivial refactoring operations?
> Albeit, granted, it is probably also the most easily automated.
> Splitting an overly-long function into smaller pieces is a more
> meaningful (IMO) refactoring operation, but probably much more difficult
> to automate (if it even can be).
>

It can be done. I use tools like this.
One of my favourites goes:

* highlight text
* click 'refactor' (or hotkey)
* type name for function

New function is produced containing the selected code. If the selected code
was an expression, then the function is generated with a return statement
and the appropriate return type.
If the selected code relied on any local variables, they are automatically
added as function parameters. The call-site is updated with the new
function call, and the local variables previously referenced passed to the
function as arguments appropriately.

There's room for an extension to this tool which might scan for the same
code throughout the project, and offer to replace the same pattern with
calls to the new function, again, automatically filling out the function
parameters.

This is only one of many useful tools that become available once tooling
has a thorough semantic analysis library available.
It would be amazing if there was some real effort put into a convenient
tooling API in the DMD front-end lib.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20131210/9636ce5e/attachment.html>


More information about the Digitalmars-d mailing list