Jump to page: 1 25  
Page
Thread overview
DConf 2013 Day 3 Talk 2: Code Analysis for D with AnalyzeD by Stefan Rohe
Jun 12, 2013
David
Jun 12, 2013
bearophile
Jun 12, 2013
Adam D. Ruppe
Jun 12, 2013
Andrej Mitrovic
Jun 12, 2013
Adam D. Ruppe
Jun 12, 2013
Jonathan M Davis
Jun 12, 2013
Walter Bright
Jun 12, 2013
Jonathan M Davis
Jun 12, 2013
bearophile
Jun 12, 2013
Walter Bright
Jun 12, 2013
bearophile
Jun 12, 2013
Timon Gehr
Jun 12, 2013
Jonathan M Davis
Jun 12, 2013
Walter Bright
Jun 12, 2013
Ary Borenszweig
Jun 12, 2013
Ary Borenszweig
Jun 12, 2013
bearophile
Jun 12, 2013
Ary Borenszweig
Jun 12, 2013
bearophile
Jun 12, 2013
Walter Bright
Jun 12, 2013
bearophile
Jun 12, 2013
Andrej Mitrovic
Jun 12, 2013
Adam D. Ruppe
Jun 13, 2013
bearophile
Jun 14, 2013
Jacob Carlborg
Jun 14, 2013
bearophile
Jun 14, 2013
Jacob Carlborg
Jun 15, 2013
Jacob Carlborg
Jun 17, 2013
Jacob Carlborg
Jun 12, 2013
Nick Sabalausky
Jun 13, 2013
Anthony Goins
Jun 14, 2013
Don
Jun 14, 2013
bearophile
Jun 15, 2013
Timon Gehr
Jun 15, 2013
bearophile
Jun 16, 2013
Timon Gehr
Jun 16, 2013
bearophile
Jun 15, 2013
Dicebot
Jun 15, 2013
Jacob Carlborg
Jun 15, 2013
Timon Gehr
Jun 16, 2013
Jacob Carlborg
Nov 01, 2013
Brad Anderson
June 12, 2013
Reddit: http://www.reddit.com/r/programming/comments/1g6x9g/dconf_2013_code_analysis_for_d_with_analyzed/

Hackernews: https://news.ycombinator.com/item?id=5867764

Twitter: https://twitter.com/D_Programming/status/344798127775182849

Facebook: https://www.facebook.com/dlang.org/posts/655927124420972

Youtube: http://youtube.com/watch?v=ph_uU7_QGY0

Please drive discussions on the social channels, they help D a lot.


Andrei
June 12, 2013
Am 12.06.2013 14:50, schrieb Andrei Alexandrescu:
> Reddit: http://www.reddit.com/r/programming/comments/1g6x9g/dconf_2013_code_analysis_for_d_with_analyzed/
> 
> 
> Hackernews: https://news.ycombinator.com/item?id=5867764
> 
> Twitter: https://twitter.com/D_Programming/status/344798127775182849
> 
> Facebook: https://www.facebook.com/dlang.org/posts/655927124420972
> 
> Youtube: http://youtube.com/watch?v=ph_uU7_QGY0
> 
> Please drive discussions on the social channels, they help D a lot.
> 
> 
> Andrei

The reddit link seems to be deleted?
June 12, 2013
On 6/12/13 9:00 AM, David wrote:
> Am 12.06.2013 14:50, schrieb Andrei Alexandrescu:
>> Reddit:
>> http://www.reddit.com/r/programming/comments/1g6x9g/dconf_2013_code_analysis_for_d_with_analyzed/
>>
>>
>> Hackernews: https://news.ycombinator.com/item?id=5867764
>>
>> Twitter: https://twitter.com/D_Programming/status/344798127775182849
>>
>> Facebook: https://www.facebook.com/dlang.org/posts/655927124420972
>>
>> Youtube: http://youtube.com/watch?v=ph_uU7_QGY0
>>
>> Please drive discussions on the social channels, they help D a lot.
>>
>>
>> Andrei
>
> The reddit link seems to be deleted?

Sorry, wrong URL. It's here: http://www.reddit.com/r/programming/comments/1g6xbi/dconf_2013_code_analysis_for_d_with_analyzed_by/

Please vote, it only has 3 points!


Andrei
June 12, 2013
Andrei Alexandrescu:

> Youtube: http://youtube.com/watch?v=ph_uU7_QGY0

It's an interesting talk. Maybe all talks of this conference were interesting.

Some notes on the slides.

- - - - - - - - - - - -

Slide 12:

>A class is an item with a strict boundary. e.g.: Arrays will be dupped at these borders.<

I think this kind of privacy for reference data is a common need. I think enforcing this is not a job of static analysis tools, it looks like a job for the type system. An annotation should suffice (in theory this annotation should allow the access of the array from outside, so it should be forbidden by default for private fields. Now this can't be done, so an annotation needs to do the opposite). Maybe this needs some discussion in the main D newsgroup.

- - - - - - - - - - - -

Slide 12:

>We do not use Ddoc, because most important information about functions are not included.
- In- / Out-Constrains
- Exceptional Cases aka Throws<

How to annotate throws in ddoct? Do they need to be generated automatically?

Regarding pre/post conditions, maybe a ddoc macro or switch can be used to make them appear in the ddoc output on request.

- - - - - - - - - - - -

Slide 12:

>Next to classes also model package dependency
- no cyclic dependencies anymore<

Maybe it's possisible to add some way (like a standard annotation) to enforce the absence of cyclic dependencies in a section of a project (like inside a package).

- - - - - - - - - - - -

Slide 14:

>- Private static functions which could be tested inplace are tested using D-unittest-Blocks (Unit =:= Function)
- Other tests require setups, teardowns, names (Testdox http://agiledox.sourceforge.net/). Need to be filtered, selected. For them using Dunit. (Unit =:= Class / Struct)<

I think the built-in unit test system should be improved, so in _most_ cases there's no need to use a second unittest system.

Bye,
bearophile
June 12, 2013
On Wednesday, 12 June 2013 at 17:31:27 UTC, bearophile wrote:
>>We do not use Ddoc, because most important information about functions are not included.
> - In- / Out-Constrains

These are pretty easy to add to dmd. In doc.c's FuncDelaration::toDocBuffer you can throw in something like this:
            if(frequire)
                buf->writestring(frequire->toChars());
            if(fensure)
                buf->writestring(fensure->toChars());

with a little cleanup and a wrapper macro and I think that would be good.

> - Exceptional Cases aka Throws<

No easy way to do this automatically though because the compiler doesn't even know what a function can throw. You'd just have to do it manually.
June 12, 2013
On 6/12/13 8:50 AM, Andrei Alexandrescu wrote:
> Reddit:
> http://www.reddit.com/r/programming/comments/1g6x9g/dconf_2013_code_analysis_for_d_with_analyzed/
>
>
> Hackernews: https://news.ycombinator.com/item?id=5867764
>
> Twitter: https://twitter.com/D_Programming/status/344798127775182849
>
> Facebook: https://www.facebook.com/dlang.org/posts/655927124420972
>
> Youtube: http://youtube.com/watch?v=ph_uU7_QGY0
>
> Please drive discussions on the social channels, they help D a lot.
>
>
> Andrei

In HD: https://archive.org/details/dconf2013-day03-talk02

Andrei
June 12, 2013
On 6/12/13, Adam D. Ruppe <destructionator@gmail.com> wrote:
> No easy way to do this automatically though because the compiler doesn't even know what a function can throw. You'd just have to do it manually.

Are you sure? A compiler can tell whether a function /can/ throw (hence why nothrow works), so I assume it has information on where an exception is thrown.

I think it'd be nice if we added this ability to ddoc, having to manually do it often means the documentation being out of date.
June 12, 2013
On Wednesday, 12 June 2013 at 20:23:43 UTC, Andrej Mitrovic wrote:
> Are you sure? A compiler can tell whether a function /can/ throw
> (hence why nothrow works), so I assume it has information on where an exception is thrown.

Consider this:

extern(D) void foo();
void bar() { foo(); }


That's legal D code, and foo could throw anything, and bar would have no idea what it is.

Looking at dmd's source, looks like Walter actually wrote code to parse a throws Exception, etc. to be part of the function signature but stripped it out (surely because that's annoying).

Without a list like that, the compiler just can't be sure what happens. It could maybe try to figure it out based on the source it has available, and at least get an incomplete list, but currently it doesn't attempt to do that.

That might not be too hard to do actually, when outputting the ddoc, dive into the function body for throw statements and build up a list. If the call tree goes down to anything it doesn't recognize and is not marked nothrow, then it could say "I'm not sure if this is everything but this is what I found".
June 12, 2013
On Wednesday, June 12, 2013 22:29:15 Adam D. Ruppe wrote:
> On Wednesday, 12 June 2013 at 20:23:43 UTC, Andrej Mitrovic wrote:
> > Are you sure? A compiler can tell whether a function /can/ throw (hence why nothrow works), so I assume it has information on where an exception is thrown.
> 
> Consider this:
> 
> extern(D) void foo();
> void bar() { foo(); }
> 
> 
> That's legal D code, and foo could throw anything, and bar would have no idea what it is.

nothrow is like @safe or pure. The compiler knows whether that attribute on the function is valid by looking at the signatures of the functions called within that function (as well as what the built-in operations used are). The bodies of the functions being called never comes into play. At least some of the time, it would be theoretically possible for the compiler to go look in the bodies of the functions being called, but all of that stuff is based off of the function signatures, not their bodies. A function's body is only looked at when it's being compiled, not when other functions refer to it. And with the C linking model, it really doesn't make sense for the compiler to look at the bodies of other functions when compiling a function.

Tools could certainly look at source code and figure out stuff like what exceptions could be thrown from a particular function, but that requires having all of the source and examining it, and that's not how compilers normally work.

- Jonathan M Davis
June 12, 2013
On Wed, 12 Jun 2013 08:50:41 -0400
Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:

> Reddit: http://www.reddit.com/r/programming/comments/1g6x9g/dconf_2013_code_analysis_for_d_with_analyzed/
> 
> Hackernews: https://news.ycombinator.com/item?id=5867764
> 
> Twitter: https://twitter.com/D_Programming/status/344798127775182849
> 
> Facebook: https://www.facebook.com/dlang.org/posts/655927124420972
> 
> Youtube: http://youtube.com/watch?v=ph_uU7_QGY0
> 
> Please drive discussions on the social channels, they help D a lot.
> 
> 
> Andrei

Torrents and links: http://semitwist.com/download/misc/dconf2013/
« First   ‹ Prev
1 2 3 4 5