digitalmars.D - My presentation at Oscon last Thursday
- Walter Bright (1/1) Jul 24 2010 http://assets.en.oreilly.com/1/event/45/The%20D%20Programming%20Language...
- bearophile (65/66) Jul 24 2010 I'm currently reading many other PDF/PPT from other conferences too.
- Walter Bright (3/5) Jul 24 2010 You're right, the buf.dup code is not only scary, it's dead wrong. My sc...
- bearophile (5/5) Jul 24 2010 The slides for another talk, "Build Your Own Contributors (One Part at ...
- bearophile (4/4) Jul 25 2010 Nice slides, "High Wizardry in the Land of Scala Presentation" by Daniel...
http://assets.en.oreilly.com/1/event/45/The%20D%20Programming%20Language%20Presentation.pdf
Jul 24 2010
Walter Bright:http://assets.en.oreilly.com/1/event/45/The%20D%20Programming%20Language%20Presentation.pdfI'm currently reading many other PDF/PPT from other conferences too. In your RAII example you are doing something that's scary, mixing C heap allocations with D GC heap allocations with C free. This is a program based on your code: import std.c.stdlib: malloc, free; struct Buffer { this(size_t s) { buf = malloc(s)[0 .. s]; } this(this) { buf = buf.dup; } ~this() { free(buf.ptr); } void[] buf; } void main() { auto b1 = Buffer(100); auto b2 = b1; } But I think this is better: import std.c.stdlib: malloc, free; struct Buffer { this(size_t s) { buf = malloc(s)[0 .. s]; } this(this) { void* newbuf = malloc(buf.length); newbuf[0 .. buf.length] = buf[]; buf = newbuf[0 .. buf.length]; } ~this() { free(buf.ptr); } void[] buf; } void main() { auto b1 = Buffer(100); auto b2 = b1; } This is your example for the functional style: pure sum_of_squares (immutable double[] a) { auto sum = 0;bearophile wrote:In your RAII example you are doing something that's scary, mixing C heap allocations with D GC heap allocations with C free.You're right, the buf.dup code is not only scary, it's dead wrong. My screw up. Derp, derp.Jul 24 2010The slides for another talk, "Build Your Own Contributors (One Part at a Time)", by Denise Paolucci (Dreamwidth Studios), Mark Smith (Dreamwidth Studios): http://assets.en.oreilly.com/1/event/45/Build%20Your%20Own%20Contributors%20_One%20Part%20at%20a%20Time_%20Presentation%201.ppt Some of the things it says seems good to improve the D community management. Bye, bearophileJul 24 2010Nice slides, "High Wizardry in the Land of Scala Presentation" by Daniel Spiewak, in pages 4-36 he shows Higher-Kinds and Typeclasses, that can be interesting for D programmers too: http://assets.en.oreilly.com/1/event/45/High%20Wizardry%20in%20the%20Land%20of%20Scala%20Presentation.pdf Bye, bearophileJul 25 2010