Re: LDC 0.13.0 has been released!
On 6/23/2014 9:50 PM, Kai Nacke wrote: Hi everyone, LDC 0.13.0, the LLVM-based D compiler, is available for download! This is the first stable release based on the 2.064.2 frontend and standard library and supports LLVM 3.1-3.4.2 (OS X: 3.2/3.4.x only). As usual, you can find links to the changelog and the binary packages over at digitalmars.D.ldc: http://forum.dlang.org/post/yefpjkfouykvwkjil...@forum.dlang.org Regards, Kai Congratulations!
Laby clone in D
Hello I've written a clone of the game Laby https://github.com/sgimenez/laby in D. But it is not complete yet, missing features include : - A GUI (it's a simple CLI right now) - Accutally parsing any language (it just accepts simple commands) But writeing it was very delightful. Roughly 250LOC. It took maybe 5 hours ... All of it Fun! git err get it at https://github.com/UplinkCoder/antd please try it.
Re: Laby clone in D
Roughly 250LOC. Correction dscanner says it's 200 LOC Currently there is only one Labyrinth hardcoded. But it's not hard to change, because it's just ASCII-ART that is parsed.
Re: LDC 0.13.0 has been released!
On Tuesday, 24 June 2014 at 04:50:07 UTC, Kai Nacke wrote: Hi everyone, LDC 0.13.0, the LLVM-based D compiler, is available for download! This is the first stable release based on the 2.064.2 frontend and standard library and supports LLVM 3.1-3.4.2 (OS X: 3.2/3.4.x only). As usual, you can find links to the changelog and the binary packages over at digitalmars.D.ldc: http://forum.dlang.org/post/yefpjkfouykvwkjil...@forum.dlang.org Regards, Kai Congratulations!
Re: DGui is alive
How about the DGui's status?
Re: DGui is alive
On Wednesday, 25 June 2014 at 15:16:03 UTC, FrankLike wrote: How about the DGui's status? https://bitbucket.org/dgui/dgui/issues
Re: LDC 0.13.0 has been released!
On Wednesday, 25 June 2014 at 07:13:27 UTC, Walter Bright wrote: On 6/23/2014 9:50 PM, Kai Nacke wrote: Hi everyone, LDC 0.13.0, the LLVM-based D compiler, is available for download! This is the first stable release based on the 2.064.2 frontend and standard library and supports LLVM 3.1-3.4.2 (OS X: 3.2/3.4.x only). As usual, you can find links to the changelog and the binary packages over at digitalmars.D.ldc: http://forum.dlang.org/post/yefpjkfouykvwkjil...@forum.dlang.org Regards, Kai Congratulations! Thanks. That was really hard work. I hope that we can create the next version a bit faster. Regards, Kai
Re: LDC 0.13.0 has been released!
On Wednesday, 25 June 2014 at 18:28:50 UTC, Kai Nacke wrote: On Wednesday, 25 June 2014 at 07:13:27 UTC, Walter Bright wrote: On 6/23/2014 9:50 PM, Kai Nacke wrote: Hi everyone, LDC 0.13.0, the LLVM-based D compiler, is available for download! This is the first stable release based on the 2.064.2 frontend and standard library and supports LLVM 3.1-3.4.2 (OS X: 3.2/3.4.x only). As usual, you can find links to the changelog and the binary packages over at digitalmars.D.ldc: http://forum.dlang.org/post/yefpjkfouykvwkjil...@forum.dlang.org Regards, Kai Congratulations! Thanks. That was really hard work. I hope that we can create the next version a bit faster. Regards, Kai I hope this too. IMHO LDC is very important as a D2 compiler! One question is will be next version use 2.065 or 2.066 frontend ? Beta of DMD 2.066 is almost there. Regards, Remo
Re: LDC 0.13.0 has been released!
On Wednesday, 25 June 2014 at 18:33:12 UTC, Remo wrote: On Wednesday, 25 June 2014 at 18:28:50 UTC, Kai Nacke wrote: On Wednesday, 25 June 2014 at 07:13:27 UTC, Walter Bright wrote: On 6/23/2014 9:50 PM, Kai Nacke wrote: Hi everyone, LDC 0.13.0, the LLVM-based D compiler, is available for download! This is the first stable release based on the 2.064.2 frontend and standard library and supports LLVM 3.1-3.4.2 (OS X: 3.2/3.4.x only). As usual, you can find links to the changelog and the binary packages over at digitalmars.D.ldc: http://forum.dlang.org/post/yefpjkfouykvwkjil...@forum.dlang.org Regards, Kai Congratulations! Thanks. That was really hard work. I hope that we can create the next version a bit faster. Regards, Kai I hope this too. IMHO LDC is very important as a D2 compiler! One question is will be next version use 2.065 or 2.066 frontend ? Beta of DMD 2.066 is almost there. Regards, Remo It will be based on 2.065. There are only a few issues left in this version. 2.066 will add new issues in addition to the existing once. That is the reason why I will not skip a frontend version. Regards, Kai
Re: LDC 0.13.0 has been released!
On Wednesday, 25 June 2014 at 18:43:34 UTC, Kai Nacke wrote: It will be based on 2.065. There are only a few issues left in this version. 2.066 will add new issues in addition to the existing once. That is the reason why I will not skip a frontend version. I support your decision. We have release building down to a science now, the most time-consuming thing is usually just waiting for the LLVM build to complete (apart from writing the release notes, of course – and having to wait for me to run the build process for the OS X packages on my notebook). The hard part is ironing out the one to two hard to debug issues that inevitable seem to crop up with every new frontend merge. David
Re: Adding the ?. null verification
On 2014-06-24 22:52, Ary Borenszweig wrote: And in Ruby it's just ||=. How more intuitive can it get? a = nil a ||= 1 The or that you are discussing here is just an || in Ruby: b = nil || 1 Yeah, but that behaves a bit different in D. -- /Jacob Carlborg
Re: Time to rename D to @D !?
On 2014-06-25 01:32, Marco Nembrini wrote: Wouldn't an attribute like @nogc only be a keyword for attribute symbols, while something like nothrow is a keyword for everything? I guess that's true. E.g. using @nogc means I can't define my own nogc UDA but I can have a function or variable named nogc, while I can't have a function named nogc. Being a attribute keyword seems a much smaller restriction on user code. I guess so. If what I wrote above is correct, why not declare existing compiler-attributes attribute keywords, and then allow a mix of them: @(nothrow, public, const, my_custom_attribute) void foo (); Yeah, if the built-in attributes were implemented as UDA's, defined in object.d, then there would be less of a problem. Then one could always use fully qualified symbol names to disambiguate the attributes. -- /Jacob Carlborg
Re: Time to rename D to @D !?
Jacob Carlborg: Yeah, if the built-in attributes were implemented as UDA's, defined in object.d, then there would be less of a problem. Then one could always use fully qualified symbol names to disambiguate the attributes. Walter in the @nogc pull request has explained why this is a bad idea, and I agree with him. There are many things that need to be fixed in D, like the problem of uniqueness. The problem of attributes like @nogc being names @nogc or nogc is very low on the list. So I suggest to refocus the discussions on more significant things, like tuples, significant missing part of Phobos, etc. Bye, bearophile
Re: D Logos
On 24/06/2014 9:58 PM, Iain Buclaw via Digitalmars-d wrote: You can also make a logo for GDC if you like. I'm phasing the site itself through something of an infrastructure change, may as well make some visual changes too to make it more appealing. ;-) http://gdcproject.org Here are half a morning's worth of doodles, let me know if you see anything you like. https://drive.google.com/file/d/0B3i8FWPuOpryaGVwb2NKT18zNFE/edit A...
Re: D Logos
On 2014-06-24 16:52:47 +, Chris Cain said: On Sunday, 22 June 2014 at 08:52:56 UTC, Alix Pexton wrote: https://drive.google.com/file/d/0B3i8FWPuOpryQU9OQlMydXJmeTQ/edit I like the ones with Mars and Phobos on the side the most, but I feel like the top D is excessive and doesn't really communicate anything. Maybe something like that, but without the top (that is, instead of an overhead corner view of the box, you'd be level with the box and looking at just two sides ... maybe with a some more emphasis on the D side) I think any logo design really needs to incorporate Mars and Phobos and probably should be just red and white (preferably flat shaded to work with most modern logos). But that's just my thoughts as a non-designer. Oh I didn't notice those omes. Those are even better than the straight D one!
Re: D Logos
On 2014-06-24 16:03:50 +, Alix Pexton said: On 22/06/2014 9:52 AM, Alix Pexton wrote: I feel that most of the new logos that have been proposed lately are too much of a departure from what we already have, so I'm throwing a few of my own designs into the ring. https://drive.google.com/file/d/0B3i8FWPuOpryQU9OQlMydXJmeTQ/edit https://drive.google.com/file/d/0B3i8FWPuOpryMmJZSnpkdnNyR2M/edit A... In the spirit of being my own harshest critic, I did one more logo that addresses my biggest gripe with the originals. While the originals were still distinctive at small sizes, the incorporated letter-Ds became illegible. This revision retains the same character but with more clarity when shrunk. https://drive.google.com/file/d/0B3i8FWPuOpryYWxJOXUwYU8yQ0U/edit A... Muchas Gracias. Looks much better. -Shammah
Re: D Logos
On 25 June 2014 12:07, Alix Pexton via Digitalmars-d digitalmars-d@puremagic.com wrote: On 24/06/2014 9:58 PM, Iain Buclaw via Digitalmars-d wrote: You can also make a logo for GDC if you like. I'm phasing the site itself through something of an infrastructure change, may as well make some visual changes too to make it more appealing. ;-) http://gdcproject.org Here are half a morning's worth of doodles, let me know if you see anything you like. https://drive.google.com/file/d/0B3i8FWPuOpryaGVwb2NKT18zNFE/edit A... The circle O doodle could be a turned into the site favicon. I see you did a prettier version of the existing GDC logo, I think the G in that looks too much like C. I think it would be better using the first G in the top left hand corner on the first line (GGDCC). Not sure where the bottom right logo is going. :) Regards Iain
Re: D Logos
On 25 June 2014 14:08, Iain Buclaw ibuc...@gdcproject.org wrote: On 25 June 2014 12:07, Alix Pexton via Digitalmars-d digitalmars-d@puremagic.com wrote: On 24/06/2014 9:58 PM, Iain Buclaw via Digitalmars-d wrote: You can also make a logo for GDC if you like. I'm phasing the site itself through something of an infrastructure change, may as well make some visual changes too to make it more appealing. ;-) http://gdcproject.org Here are half a morning's worth of doodles, let me know if you see anything you like. https://drive.google.com/file/d/0B3i8FWPuOpryaGVwb2NKT18zNFE/edit A... The circle O doodle could be a turned into the site favicon. I see you did a prettier version of the existing GDC logo, I think the G in that looks too much like C. I think it would be better using the first G in the top left hand corner on the first line (GGDCC). Or maybe the second...
Re: Time to rename D to @D !?
On 23 June 2014 23:58, Grogan via Digitalmars-d digitalmars-d@puremagic.com wrote: On Monday, 23 June 2014 at 22:16:22 UTC, Grogan wrote: On Monday, 23 June 2014 at 22:02:26 UTC, Tobias Pankrath wrote: import std.stdio; @safe int safe() { auto i = 8; return i; } void main(string ars[]) { writeln(safe); } --- What you want is just impossible... Would be a good use case for dfix. It really isn't hard to rename every identifier consistently. Maybe the future will tell you you're right... From my point of view this change is a very unprobable one but who knows ? ^^ People are skeptikal about the the air-skate too... I don't wanna be segregative... I meant the 'hoverboard' of course... BTW I think '@' makes sense. And another BTW: in your fantastic nazi plan which consists into eradicating the '@' prefix, how would look the UDA ? I mean that '@' has a signification in the D grammar not only for predifined attributes, but also for user ones... Godwin's Law.
Re: D Logos
On Wednesday, 25 June 2014 at 11:07:47 UTC, Alix Pexton wrote: Here are half a morning's worth of doodles, let me know if you see anything you like. https://drive.google.com/file/d/0B3i8FWPuOpryaGVwb2NKT18zNFE/edit A... Yeah, the one on the 3rd row next to GDC looks fantastic to me. I'd feel happy slapping that on my website to advertise that it runs on D. (obviously, though, I wouldn't want to use a non-standard logo, so it'd have to be accepted first) That's just my opinion though. Great work :)
Re: D Logos
On 25/06/2014 2:16 PM, Iain Buclaw via Digitalmars-d wrote: On 25 June 2014 14:08, Iain Buclaw ibuc...@gdcproject.org wrote: On 25 June 2014 12:07, Alix Pexton via Digitalmars-d digitalmars-d@puremagic.com wrote: On 24/06/2014 9:58 PM, Iain Buclaw via Digitalmars-d wrote: You can also make a logo for GDC if you like. I'm phasing the site itself through something of an infrastructure change, may as well make some visual changes too to make it more appealing. ;-) http://gdcproject.org Here are half a morning's worth of doodles, let me know if you see anything you like. https://drive.google.com/file/d/0B3i8FWPuOpryaGVwb2NKT18zNFE/edit A... The circle O doodle could be a turned into the site favicon. I see you did a prettier version of the existing GDC logo, I think the G in that looks too much like C. I think it would be better using the first G in the top left hand corner on the first line (GGDCC). Or maybe the second... Gs can be tricky to draw (yes, these are drawn not from an existing font). The black letters at the top use different thicknesses for the horizontal and vertical strokes, so that G would look out of place with the red letters. Here are some quick variations (just the old red G with bits on ^^). https://drive.google.com/file/d/0B3i8FWPuOpryb2tmc2ZMdVMwcEE/edit A...
Supertypes, subtypes, and more
In Phobos we have Typedef (that needs some improvements), that allows to define a not compatible type. In D we have alias this that inside a struct allows to create a new type (with instance object of size equal or larger than the original type) with similar semantics of a given type. This allows to define a type that acts like another. In Ada there is a standard way to restrict a type. In a Reddit thread I have found this simple example of modern Ada code, a sufficiently common need: My go-to example is social-security numbers, because it's simple enough that people can see what's going on as well as provides a good way to illustrate how subtypes can allow one to 'ignore'1 the implementation. -- SSN format: ###-##- Subtype Social_Security_Number is String(1..11) with Dynamic_Predicate = (for all Index in Social_Security_Number'Range = (case Index is when 4|7 = Social_Security_Number(Index) = '-', when others = Social_Security_Number(Index) in '0'..'9' ) ); -- The above declaration can allows me to skip the validity -- checks of parameters within the body of a subprogram as -- the constraints are checked on subprogram-call. -- I do not need to check the validity of the return value, -- an attempt to return a non-conformant string will raise -- and exception. Function Get_SSN( Record : ID ) return Social_Security_Number; -- Likewise, passing a non-conformant value to SSN will raise -- an exception. Procedure Save_SSN( Record : ID; SSN : Social_Security_Number ); I think where you expect a String you can send a Social_Security_Number, but where it expects a Social_Security_Number it doesn't accept a String. (The Dynamic_Predicate and Static_Predicate of modern Ada allow to perform such restrictions.) So I think there are some analogies with OOP. I'd like to do something like this in D, with structs/values. Bye, bearophile
Re: D Logos
On 6/15/2014 2:57 AM, Russel Winder via Digitalmars-d wrote: More to the point, one doesn't just change a logo (*). The logo is a part of the brand and the brand is more than the logo. Although D doesn't really have an organized brand (at least as yet), the letter D with two moons red logo and the current red/brown/black website are the closest thing to a brand D has. There is also the issue of the D stick figure as a mascot. Rust and Go may not have the world's best brands, but they have a more joined up brand image than that of D. Just look at rust-lang.org and golang.org alongside dlang.org. Creating a strong brand is not easy, and it isn't just marketing hype; it is about looking at all aspects of public facing material: colou?rs, shapes, images, logos, fonts, layout, mascots, history,… A strong brand is a huge asset. The current D logo has a lot of history and a surprising public (as in programmer) awareness. This is an intangible asset not to be thrown away. We have had proposals for a new logo, a new website. I have no problem with this, but just as when dlang.org split off from Digital Mars, there needs to be thought about the whole brand, especially if you want to get traction of D usage. I agree with Russel. I think we've had good success with the D With Moons logo, and it's use is pervasive and recognizable as being D.
Re: D Logos
On 25 June 2014 17:16, Walter Bright via Digitalmars-d digitalmars-d@puremagic.com wrote: On 6/15/2014 2:57 AM, Russel Winder via Digitalmars-d wrote: More to the point, one doesn't just change a logo (*). The logo is a part of the brand and the brand is more than the logo. Although D doesn't really have an organized brand (at least as yet), the letter D with two moons red logo and the current red/brown/black website are the closest thing to a brand D has. There is also the issue of the D stick figure as a mascot. Rust and Go may not have the world's best brands, but they have a more joined up brand image than that of D. Just look at rust-lang.org and golang.org alongside dlang.org. Creating a strong brand is not easy, and it isn't just marketing hype; it is about looking at all aspects of public facing material: colou?rs, shapes, images, logos, fonts, layout, mascots, history,… A strong brand is a huge asset. The current D logo has a lot of history and a surprising public (as in programmer) awareness. This is an intangible asset not to be thrown away. We have had proposals for a new logo, a new website. I have no problem with this, but just as when dlang.org split off from Digital Mars, there needs to be thought about the whole brand, especially if you want to get traction of D usage. I agree with Russel. I think we've had good success with the D With Moons logo, and it's use is pervasive and recognizable as being D. I forgot about these designs also: http://wendlerchristoph.wordpress.com/designs-for-d/
Re: std.file read with start position
On Tue, Jun 24, 2014 at 10:06:51PM -0400, Etienne Cimon via Digitalmars-d wrote: On 2014-06-24 20:33, H. S. Teoh via Digitalmars-d wrote: Once this goes in, ddoc anchors should be*much* saner. While I don't have the confidence this is the last we'll hear of ddoc anchor issues, I Well, that was quick! Quick, but not quite complete: https://github.com/D-Programming-Language/dmd/pull/3695 I might contribute some documentation in phobos, there's obviously a little bit of work to do in there =) Please do, the state of phobos docs in many places are quite sad. Any help in facelifting them would be appreciated. :) T -- Change is inevitable, except from a vending machine.
Re: DSLs for high performance computing
On Tuesday, 24 June 2014 at 21:01:34 UTC, Guillaume Chatelet wrote: On Wednesday, 18 June 2014 at 19:00:26 UTC, Andrei Alexandrescu wrote: A coworker brought this list to my attention: https://xstackwiki.modelado.org/DSL%27s The work on such DSLs (reminiscent of Don's work on optimizing matrix operations years ago) seems be on the rise. I didn't know most of them. I encourage everybody interested in Image/Signal Processing to have a look at Halide Talk https://www.youtube.com/watch?v=3uiEyEKji0M papers http://halide-lang.org/ I don't know if it's already available in the source code but they mention the scheduling part can now be optimized through genetic algorithms : the code will autotune to use the best of your hardware, exploring the space of precomputing (stencil buffer), inlining, multithreading, vectorization, unrolling, sliding window ... Thanks for sharing Andrei :) Halide looks just *mind-blowing* though I couldn't find any project using it on github (other than toy-examples). I couldn't find anything either in the doc about the automatic scheduling they mention in their paper. I am wondering if it is possible to perform linalg operations, it seems rather convolution-oriented. Anyway, it would be awesome to have a D front-end (not that I have the time to code it, I usually just talk ;)). Else : Preferably to DSLs though, I am more waiting something as basic as containers based on std.allocator or a standard multi-dimensional array (with range behaviour based on a permutation of the dimensions and allow borrowed slices of any subspace). Well in fact I am not waiting since I do not have the time to code in D but if I had the time this is what I would be waiting/working for. Keep it up !
Re: D Logos
On 25 June 2014 16:33, Alix Pexton via Digitalmars-d digitalmars-d@puremagic.com wrote: On 25/06/2014 2:16 PM, Iain Buclaw via Digitalmars-d wrote: On 25 June 2014 14:08, Iain Buclaw ibuc...@gdcproject.org wrote: On 25 June 2014 12:07, Alix Pexton via Digitalmars-d digitalmars-d@puremagic.com wrote: On 24/06/2014 9:58 PM, Iain Buclaw via Digitalmars-d wrote: You can also make a logo for GDC if you like. I'm phasing the site itself through something of an infrastructure change, may as well make some visual changes too to make it more appealing. ;-) http://gdcproject.org Here are half a morning's worth of doodles, let me know if you see anything you like. https://drive.google.com/file/d/0B3i8FWPuOpryaGVwb2NKT18zNFE/edit A... The circle O doodle could be a turned into the site favicon. I see you did a prettier version of the existing GDC logo, I think the G in that looks too much like C. I think it would be better using the first G in the top left hand corner on the first line (GGDCC). Or maybe the second... Gs can be tricky to draw (yes, these are drawn not from an existing font). The black letters at the top use different thicknesses for the horizontal and vertical strokes, so that G would look out of place with the red letters. Here are some quick variations (just the old red G with bits on ^^). https://drive.google.com/file/d/0B3i8FWPuOpryb2tmc2ZMdVMwcEE/edit A... Having quickly patched it together in gimp, I'm leaning on either on the right hand side. The G on the bottom left could be nice next to the D in a strange perspective (eg: a 3D box). At the same time I agree with Walter on the Moons logo. But I'd like to make it slightly unique. Maybe a Gibbous Moon. :) http://darkhorizons.emissionline.com/images/moon-ha2l.jpg You could almost make out a G to fir into that...
Re: Supertypes, subtypes, and more
On Wednesday, 25 June 2014 at 15:33:16 UTC, bearophile wrote: In Phobos we have Typedef (that needs some improvements), that allows to define a not compatible type. In D we have alias this that inside a struct allows to create a new type (with instance object of size equal or larger than the original type) with similar semantics of a given type. This allows to define a type that acts like another. In Ada there is a standard way to restrict a type. In a Reddit thread I have found this simple example of modern Ada code, a sufficiently common need: My go-to example is social-security numbers, because it's simple enough that people can see what's going on as well as provides a good way to illustrate how subtypes can allow one to 'ignore'1 the implementation. -- SSN format: ###-##- Subtype Social_Security_Number is String(1..11) with Dynamic_Predicate = (for all Index in Social_Security_Number'Range = (case Index is when 4|7 = Social_Security_Number(Index) = '-', when others = Social_Security_Number(Index) in '0'..'9' ) ); -- The above declaration can allows me to skip the validity -- checks of parameters within the body of a subprogram as -- the constraints are checked on subprogram-call. -- I do not need to check the validity of the return value, -- an attempt to return a non-conformant string will raise -- and exception. Function Get_SSN( Record : ID ) return Social_Security_Number; -- Likewise, passing a non-conformant value to SSN will raise -- an exception. Procedure Save_SSN( Record : ID; SSN : Social_Security_Number ); I think where you expect a String you can send a Social_Security_Number, but where it expects a Social_Security_Number it doesn't accept a String. (The Dynamic_Predicate and Static_Predicate of modern Ada allow to perform such restrictions.) So I think there are some analogies with OOP. I'd like to do something like this in D, with structs/values. Bye, bearophile You can do this in C# as well: class SocialSecurityNumber { string _ssn; //Implicitly converts to string public static implicit operator string(SocialSecurityNumber ssn) { return _ssn; } }
Re: Supertypes, subtypes, and more
Meta: You can do this in C# as well: class SocialSecurityNumber { But it's essential to do that on structs. Bye, bearophile
Re: D Logos
On 25/06/2014 6:34 PM, Iain Buclaw via Digitalmars-d wrote: Having quickly patched it together in gimp, I'm leaning on either on the right hand side. The G on the bottom left could be nice next to the D in a strange perspective (eg: a 3D box). I agree ^^ At the same time I agree with Walter on the Moons logo. But I'd like to make it slightly unique. Maybe a Gibbous Moon. :) The real Phobos and Deimos look nothing like our moon, Deimos isn't even remotely spherical! http://darkhorizons.emissionline.com/images/moon-ha2l.jpg You could almost make out a G to fir into that... And how do you feel about wolves? I've got 9 total variations on the G now, my 2nd favourite of the ones I've not shown you is just a tiny tweak away from the top right version ^^ A...
Re: Supertypes, subtypes, and more
On Wednesday, 25 June 2014 at 19:30:25 UTC, bearophile wrote: Meta: You can do this in C# as well: class SocialSecurityNumber { But it's essential to do that on structs. Bye, bearophile I believe it works for structs as well.
Re: Supertypes, subtypes, and more
On 25/06/14 17:33, bearophile via Digitalmars-d wrote: In D we have alias this that inside a struct allows to create a new type (with instance object of size equal or larger than the original type) with similar semantics of a given type. This allows to define a type that acts like another. I'd like to mention that this has an unfortunate issue with respect to encapsulation of data. See: http://d.puremagic.com/issues/show_bug.cgi?id=10996 The problem is that if you have a subtype implemented via alias this, struct Foo { SomeOtherStruct payload; alias payload this; // ... other stuff ... } ... then ideally you'd like the payload field to be private, because otherwise you're exposing implementation details, which could be nasty if you ever want to alter the design. (SOMEONE using your code is going to wind up assuming that accessing payload directly is OK.) However, if you try and implement it this way, struct Foo { private SomeOtherStruct payload; public alias payload this; // ... other stuff ... } ... the compiler won't accept it, because the private access to payload clashes with public access via alias this. It's a shame, because the principle -- payload is private, but public access to its fields is available via the alias this -- is a nice one; and it's clearly something that was envisioned for the language (TDPL p. 232, I think). Personally, I'd really appreciate it if the above-mentioned issue could get some compiler dev attention. :-)
Re: Supertypes, subtypes, and more
On Wed, 25 Jun 2014 15:33:14 +, bearophile wrote: I think where you expect a String you can send a Social_Security_Number, but where it expects a Social_Security_Number it doesn't accept a String. (The Dynamic_Predicate and Static_Predicate of modern Ada allow to perform such restrictions.) So I think there are some analogies with OOP. I'd like to do something like this in D, with structs/values. Bye, bearophile Does this do everything you're looking for? http://dpaste.dzfl.pl/50531f5b1356 The only potential problem I see is that the invariant presumably won't be compiled in when in release mode.
Re: Supertypes, subtypes, and more
struct Foo { private SomeOtherStruct payload; public alias payload this; // ... other stuff ... } ... the compiler won't accept it, because the private access to payload clashes with public access via alias this. Did you try using a method? module1 --- struct Subtype { private int x; public int getX() { return x; } alias getX this; } --- module2 --- import module1; void main() { Subtype st = Subtype(2); int x = st; } --- Works for me.
Re: Supertypes, subtypes, and more
On Wednesday, 25 June 2014 at 20:59:00 UTC, Justin Whear wrote: On Wed, 25 Jun 2014 15:33:14 +, bearophile wrote: I think where you expect a String you can send a Social_Security_Number, but where it expects a Social_Security_Number it doesn't accept a String. (The Dynamic_Predicate and Static_Predicate of modern Ada allow to perform such restrictions.) So I think there are some analogies with OOP. I'd like to do something like this in D, with structs/values. Bye, bearophile Does this do everything you're looking for? http://dpaste.dzfl.pl/50531f5b1356 The only potential problem I see is that the invariant presumably won't be compiled in when in release mode. Now if only we could get that to work with more than one type, such that we could have subtype implicitly convertible to more than one type.
Re: Supertypes, subtypes, and more
On 25/06/14 23:10, Tobias Pankrath via Digitalmars-d wrote: Did you try using a method? module1 --- struct Subtype { private int x; public int getX() { return x; } alias getX this; } --- module2 --- import module1; void main() { Subtype st = Subtype(2); int x = st; } --- Works for me. Yes, someone suggested this to me quite recently in fact. But I think it doesn't solve the real issue -- you're still exposing implementation details, as a user can always call getX directly.
Module level variable shadowing
While I try to minimize the number of module-level variables in D code, sometimes they are present, and sometimes I have problems (bugs) caused by unwanted shadowing of global names (or sometimes more generally, names from outer scopes, but this is less common): int x = 1; // ... void foo() { // ... int x = 2; // ... writeln(x); } Can't we find a way to avoid/find such kind of bugs? (It's not a problem of mutability, because the same problem happens with immutable variables.) I have hit this bug several times. The simplest way to avoid that kind of bugs is give a shadowing global x error (similar to the shadowing errors D gives with foreach and with statements). But this breaks most existing D code. Bye, bearophile
Re: Module level variable shadowing
On Wed, Jun 25, 2014 at 11:03:14PM +, bearophile via Digitalmars-d wrote: While I try to minimize the number of module-level variables in D code, sometimes they are present, and sometimes I have problems (bugs) caused by unwanted shadowing of global names (or sometimes more generally, names from outer scopes, but this is less common): int x = 1; // ... void foo() { // ... int x = 2; // ... writeln(x); } Can't we find a way to avoid/find such kind of bugs? (It's not a problem of mutability, because the same problem happens with immutable variables.) I have hit this bug several times. My advice is to avoid module globals unless absolute necessary. A whole class of problems are avoided that way. The simplest way to avoid that kind of bugs is give a shadowing global x error (similar to the shadowing errors D gives with foreach and with statements). But this breaks most existing D code. [...] If you want to refer to a module global, write .x instead of x. T -- Тише едешь, дальше будешь.
Software Assurance Reference Dataset
http://samate.nist.gov/SRD/view.php?count=20first=0sort=asc This is a list of security vulnerabilities in languages including C/C++. 88,737 of them (!). It's an interesting list, and an opportunity for D. I once said that my job was to put Coverity out of business. The more of these issues D can automatically prevent with @safe, the better.
Re: Module level variable shadowing
On 6/25/2014 4:03 PM, bearophile wrote: The simplest way to avoid that kind of bugs is give a shadowing global x error (similar to the shadowing errors D gives with foreach and with statements). But this breaks most existing D code. D has scoped lookup. Taking your proposal as principle, where do we stop at issuing errors when there is the same identifier in multiple in-scope scopes? I think we hit the sweet spot at restricting shadowing detection to local scopes. I suggest that your issues with global variables can be mitigated by adopting a distinct naming convention for your globals. Frankly, I think a global variable named x is execrable style - such short names should be reserved for locals.
Re: DSLs for high performance computing
On Wednesday, 18 June 2014 at 19:00:26 UTC, Andrei Alexandrescu wrote: The work on such DSLs (reminiscent of Don's work on optimizing matrix operations years ago) seems be on the rise. Is it? It would be good for D if it is, since D has a great offering in that arena, but I haven't seen much, if any, new DSL work recently. Maybe I'm not looking in the right places.
Re: DSLs for high performance computing
On Thursday, 26 June 2014 at 03:49:45 UTC, Peter Alexander wrote: On Wednesday, 18 June 2014 at 19:00:26 UTC, Andrei Alexandrescu wrote: The work on such DSLs (reminiscent of Don's work on optimizing matrix operations years ago) seems be on the rise. Is it? It would be good for D if it is, since D has a great offering in that arena, but I haven't seen much, if any, new DSL work recently. Maybe I'm not looking in the right places. Hack ?
Re: DSLs for high performance computing
On Thursday, 26 June 2014 at 03:59:47 UTC, deadalnix wrote: On Thursday, 26 June 2014 at 03:49:45 UTC, Peter Alexander wrote: On Wednesday, 18 June 2014 at 19:00:26 UTC, Andrei Alexandrescu wrote: The work on such DSLs (reminiscent of Don's work on optimizing matrix operations years ago) seems be on the rise. Is it? It would be good for D if it is, since D has a great offering in that arena, but I haven't seen much, if any, new DSL work recently. Maybe I'm not looking in the right places. Hack ? Maybe, although I see Hack as more of an extension of PHP, and I'd say PHP is more general purpose than domain specific. I suppose it depends on your definition of domain specific. Not worth arguing over, but I take your point.
Re: rehabilitating Juno
FYI after running coffimplib over SDK versions of oleaut32.lib and gdiplus.lib I've gotten all the examples in the makefile to run. Next up for me is to get tlbimpld compiling and I'll fork and do a pull request to add that to the makefile.
Re: Equivalent of C++ std::function
On Wednesday, 25 June 2014 at 05:13:00 UTC, Olivier Pisano wrote: On Wednesday, 25 June 2014 at 03:33:15 UTC, Yuushi wrote: Thanks a ton - I guess I need to do a fair bit more reading about alias. In this case, alias acts as typedef in C++. What is important here is the function pointers/delegates syntax. Yeah, I realised that when I went back and looked at what I'd tried: function string(string) transform; which should have been: string function(string) transform; which does work. Thanks for the clarification.
Re: Equivalent of C++ std::function
On 06/24/2014 08:33 PM, Yuushi wrote: I guess I need to do a fair bit more reading about alias. It is probably too basic for you but somebody else may find it useful: http://ddili.org/ders/d.en/lambda.html Ali
Re: Is their a way for a Child process to modify its Parent's environment?
On 2014-06-25 03:53, WhatMeWorry wrote: I open a command line window, and run the following 6 line program void main() { string envPath = environment[PATH]; writeln(PATH is: , envPath); envPath ~= r;F:\dmd2\windows\bin; environment[PATH] = envPath; envPath = environment[PATH]; writeln(PATH is: , envPath); } It prints out the following PATH is: C:\Windows\system32;C:\Windows... PATH is: C:\Windows\system32;C:\Windows...F:\dmd2\windows\bin when the program exits, I'm back at the command line and I do a echo %PATH% which just shows C:\Windows\system32;C:\Windows... Anybody know of a way to make the change stick for the lifetime of the command window? That's not possible. There is a workaround, DVM does something similar. Although, I don't remember how the code works for Windows but you can have a look at the code [1], or perhaps Nick can explain it. [1] https://github.com/jacob-carlborg/dvm/blob/master/dvm/commands/Use.d#L34 -- /Jacob Carlborg
Re: Equivalent of C++ std::function
On 06/24/2014 11:23 PM, Yuushi wrote: Yeah, I realised that when I went back and looked at what I'd tried: function string(string) transform; That gets me all the time! :-/ That is the long version of the function literal syntax: auto f = function string(string s) { return hello; }; which should have been: string function(string) transform; which does work. Thanks for the clarification. Ali
[OT]I throw in the towel
I wanted to create a simple application to display and edit data from postgresql database using GtkD and ddb (https://github.com/pszturmaj/ddb) The application should run on WinXp or Win7. After a week of work I throw in the towel ... 1. The first problem $ dub build Unexpected Termination OPTLINK at t = EIP 0040F5Ba After many attempts to find a solution (http://forum.dlang.org/thread/gskuwiynupngpungy...@forum.dlang.org) $ dub build --rdmd After writing a bit of code another problem: $ dub build --rdmd Error 45: Too Much Data for Old DEBUG CodeView format $ dub --build=release --rdmd C:\Documents and Settings\dao\Application Data\dub\packages\gtk-d-2.3.3\src\gtk\Builder.d(489): Error: ICE: cannot append 'char' to 'string' (see https://github.com/gtkd-developers/GtkD/issues/91 and https://issues.dlang.org/show_bug.cgi?id=12243) I love D but, with tail between legs, I come back to csharp... (BTW on Linux it's works well)
Assosiative array pop
Given an assosiative array : int[string] k, is there a way (either phobos or tango) to pop the first element of this array and append it to another array? I can come up with a primitive soluiton: int[string] k; // populate k here int[string] j; foreach(sttring key, int val; k) { j[key] = val; break; } but could it be better? it is wroth noting that the keys are not known beforehand.
Re: Assosiative array pop
Aso, I wanted to mention that I did not find much info in the manual page on this.
Exception style
i know you can use both throw new Exception(msg); and module test; class testException { this (string msg) { super(some error info : ~msg); } } throw new testException(msg); but which one is better conforms to the d style?
Re: Exception style
Sean Campbell: but which one is better conforms to the d style? Both are valid. Use the second when you want a more precise exception in your code, this is common in larger programs. Keep in mind that you can allocate an exception in a point and throw it in another. This reduces the runtime allocations and should allow more @nogc code. Bye, bearophile
Re: Assosiative array pop
On Wednesday, June 25, 2014 09:30:48 seany via Digitalmars-d-learn wrote: Given an assosiative array : int[string] k, is there a way (either phobos or tango) to pop the first element of this array and append it to another array? I can come up with a primitive soluiton: int[string] k; // populate k here int[string] j; foreach(sttring key, int val; k) { j[key] = val; break; } but could it be better? it is wroth noting that the keys are not known beforehand. There's no such thing as the first element of an AA. An associative array is a hash table and has no order to it. The order you get when iterating with foreach is undefined. If you just want to get _a_ key from an AA, then you need to either iterate over it with foreach and then break like you're doing or use byKey to get a range. e.g. something like auto key = k.byKey().front; j[key] = k[key]; should work. But there is no first key, so I don't know really understand what you're really trying to do here and can't provide a better answer without more information. - Jonathan M Davis
Re: Assosiative array pop
seany: int[string] k; // populate k here int[string] j; foreach(sttring key, int val; k) { j[key] = val; break; } This is OK, and you can encapsulate this into a little function. But you are not removing the pair from the first associative array. So you have to remove the item before the break. Bye, bearophile
Re: Exception style
On Wednesday, 25 June 2014 at 09:54:16 UTC, bearophile wrote: Sean Campbell: but which one is better conforms to the d style? Both are valid. Use the second when you want a more precise exception in your code, this is common in larger programs. Keep in mind that you can allocate an exception in a point and throw it in another. This reduces the runtime allocations and should allow more @nogc code. Bye, bearophile Thank you very much for the quick reply, and a method to save memory.
Re: Assosiative array pop
On Wednesday, 25 June 2014 at 09:30:54 UTC, seany wrote: Given an assosiative array : int[string] k, is there a way (either phobos or tango) to pop the first element of this array and append it to another array? I can come up with a primitive soluiton: int[string] k; // populate k here int[string] j; foreach(sttring key, int val; k) { j[key] = val; break; } but could it be better? it is wroth noting that the keys are not known beforehand. If you want something like a hash table that preserves insertion order, you could try using an array of tuples instead. Then to pop the first element, just do 'arr = arr[1..$]'.
Any GPL video games in D2
I would like to show D in action to other programmers/students. Anyone knows of a Video Game coded in D2 ? Thank you
Re: How to I call D code from C# Project?
On Thursday, 19 June 2014 at 13:59:25 UTC, Kagamin wrote: On Wednesday, 18 June 2014 at 20:55:09 UTC, GoD wrote: D, very fast programming language. But I can not WinForm applications from D. I'm using C# for WinForm applications. DWT and TkD didn't work for you? Can you give us some Design tools on windows for DWT? Thank you.
Re: How to I call D code from C# Project?
On Thursday, 19 June 2014 at 04:07:30 UTC, Jesse Phillips wrote: On Wednesday, 18 June 2014 at 23:41:43 UTC, GoD wrote: @Jesse How to use in C# projects? You'll have to access it through a COM interface on the C# side. http://msdn.microsoft.com/en-us/library/aa645736%28v=vs.71%29.aspx If you haven't done work in COM before its a lot of new things to learn. C# should also have interfacing with C, so you can have D expose a C interface. Sorry I can't walk you through working examples. As mentioned, I haven't gotten that far myself. That sounds legit.
Re: Any GPL video games in D2
Hi, Some time ago I wrote this Tetris-like game: https://bitbucket.org/lmb/anytris (also on GitHub: https://github.com/lmbarros/Anytris) Nothing fancy. I am sure there are better examples out there. And maybe this is not the best code to show to students ;-) Also, license is ZLib -- I assume it will be good for your purposes. LMB On Wed, Jun 25, 2014 at 11:24 AM, Binarydepth via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I would like to show D in action to other programmers/students. Anyone knows of a Video Game coded in D2 ? Thank you
Using attributes inside template instantiation
I'm trying to declare format for database record in compile time. I consider to use attributes fo this. Can I do something similar to this code? struct RecordFormat(T) {} alias Format = RecordFormat!( @(cool) int ); pragma( msg, Format ); void main() { } Or I want something strange that is not supported by language? For now I don't understand whether UDA are a part of types or they are a part of variable instance definition or something different (3rd dimension)). For example 'const int' is a type but what @attribute int is? Can it be considered as separate type or it could be binded to definition of variable only? @attribute int number; I failed to alias type alias coolInt = @(cool) int; But I can alias const int alias constInt = const int; I think I understood something wrong about attributes.
Re: Any GPL video games in D2
On Wednesday, 25 June 2014 at 14:24:11 UTC, Binarydepth wrote: I would like to show D in action to other programmers/students. Anyone knows of a Video Game coded in D2 ? Thank you Here are two: http://dgame-dev.de/?page=show
Re: Using attributes inside template instantiation
UDA's are compile-time metadata associated with a specific declaration. So in something like: @foo int x; The @foo is attached to x, but is not part of the type.
Re: Using attributes inside template instantiation
On Wed, Jun 25, 2014 at 05:10:06PM +, Chris Nicholson-Sauls via Digitalmars-d-learn wrote: UDA's are compile-time metadata associated with a specific declaration. So in something like: @foo int x; The @foo is attached to x, but is not part of the type. The term attribute is a bit confusing, especially since property is also used in the language to refer to something completely different. A better term is perhaps annotation. The @foo is an annotation on x, but its type is just int. Furthermore, the @foo annotation on it only exists at compile-type; it doesn't exist at runtime. The purpose is really to enhance compile-time introspection and metaprogramming; but what the OP wants seems to be something else altogether. Sadly, the attribute terminology has stuck, and is unlikely to change. T -- What do you get if you drop a piano down a mineshaft? A flat minor.
DDoc and private members / mixins / UDAs
Let me preface this by admitting that I'm not sure I'm using the DDoc functionality properly at all, so let me know if my questions are bogus. Is it possible to: - Add private members to documentation? - Have DDoc do its thing after mixins have been handled? - Access UDAs? To expand on the last point: in my code I currently use UDAs to annotate variables that can be set in an input file; at compile time I use __traits to find all of them and create a parser etc. for them. I would really like to be able to create a minimal documentation, which only includes all such UDA-annotated variables from all modules, so it can be used as a short manual for the end user, rather than being developer documentation. I was thinking of using a LaTeX template and using the absence or presence of the UDA to somehow insert a macro that is either just blank or actually adds the documentation. Any tips to achieve this in a different fashion are also appreciated. Kind regards, Stefan Frijters
expose class declared in unittest
I'm trying to create a set of utility functions that cache objects of various types loaded from json files, but having trouble testing it. One function I'd like to test uses new to instantiate an object based on a compile-time parameter: void loadDataFile(T)(string filename) { ... T obj = new T(name, value); ... } When testing, I try to create a dummy class to test that data can be written and read properly: unittest { class Dummy { ... } ... write some json to a tempfile ... loadDataFile!Dummy(tempfile_path); ... verify loaded data ... } When running the test, I get the error outer function context of util.jsondata.__unittestL31_1 is needed to 'new' nested class util.jsondata.__unittestL31_1. So it seems that a class nested in a unittest can't be 'newed' outside of the test. The test runs if I declare Dummy outside of the unittest, but I don't want it to exist outside of the test. I could import modules containing some of the classes that I will actually be loading with this, but I feel like the unittest shouldn't depend on those, as its designed to work with arbitrary classes. Any suggestions would be appreciated.
Re: expose class declared in unittest
On Wednesday, 25 June 2014 at 20:17:35 UTC, rcor wrote: I'm trying to create a set of utility functions that cache objects of various types loaded from json files, but having trouble testing it. One function I'd like to test uses new to instantiate an object based on a compile-time parameter: void loadDataFile(T)(string filename) { ... T obj = new T(name, value); ... } When testing, I try to create a dummy class to test that data can be written and read properly: unittest { class Dummy { ... } ... write some json to a tempfile ... loadDataFile!Dummy(tempfile_path); ... verify loaded data ... } When running the test, I get the error outer function context of util.jsondata.__unittestL31_1 is needed to 'new' nested class util.jsondata.__unittestL31_1. So it seems that a class nested in a unittest can't be 'newed' outside of the test. The test runs if I declare Dummy outside of the unittest, but I don't want it to exist outside of the test. I could import modules containing some of the classes that I will actually be loading with this, but I feel like the unittest shouldn't depend on those, as its designed to work with arbitrary classes. Any suggestions would be appreciated. I don't completely understand your problem, but have you tried marking the class as static? static class Dummy { ... }
Using two flags in conditonal compilation (version)
Hi, In the development of my library, I'm in a position where I need to add support for multiple compilers. For instance, supporting both the assembly of LDC/DMD and GDC. I want to do something like: version(DigitalMars LDC) { } However, it doesn't compile which forces me to rewrote the same code for both DigitalMars and LDC version(DigitalMars) { } version(LDC) { } Is there a way to check both versions at the same time? (I can't seem to find the solution through google, sorry) Thanks, Danyal Zia
Re: expose class declared in unittest
I don't completely understand your problem, but have you tried marking the class as static? static class Dummy { ... } I was about to post links to the actual code to make it more clear, but that did the trick. Thanks for the fast reply. Just to make sure - given: unittest { static class Dummy { ... } } Dummy will not exist unless compiled with -unittest, correct?
Re: Using two flags in conditonal compilation (version)
Danyal Zia: Is there a way to check both versions at the same time? (I can't seem to find the solution through google, sorry) This is close to being the best solution in D (untested): version(DigitalMars) enum myMars = true; else enum myMars = false; version(LDC) enum myLdc = true; else enum myLdc = false; enum myMarsOrLdc = myMars || myLdc; static if (myMarsOrLdc) { ... } else { ... } Bye, bearophile
Re: Using two flags in conditonal compilation (version)
On Wed, 25 Jun 2014 20:24:30 +, Danyal Zia wrote: Hi, In the development of my library, I'm in a position where I need to add support for multiple compilers. For instance, supporting both the assembly of LDC/DMD and GDC. I want to do something like: version(DigitalMars LDC) { } However, it doesn't compile which forces me to rewrote the same code for both DigitalMars and LDC version(DigitalMars) { } version(LDC) { } Is there a way to check both versions at the same time? (I can't seem to find the solution through google, sorry) Thanks, Danyal Zia I think you mean ||, not . The best way I know around this is to define enums: version (DigitalMars) enum compiler_DigitalMars = true; else enum compiler_DigitalMars = false; //... similar for LDC static if (compiler_DigitalMars || compiler_LDC) { ... } else { ... }
Returning fixed size arrays
Is it possible and a good idea to change the D ABI to make code like this avoid an array copy in 100% of the cases (without inlining)? ubyte[1000] foo() nothrow @safe { typeof(return) data; // some code here. return data; } void main() nothrow { immutable data = foo(); } Bye, bearophile
Re: Returning fixed size arrays
Is it possible and a good idea to change the D ABI to make code like this avoid an array copy in 100% of the cases (without inlining)? I meant, letting the compiler rewrite that code like this: void foo(ref ubyte[1000] __data) nothrow @safe { __data[] = 0; // some code here. } void main() nothrow { ubyte[1000] __data = void; foo(__data); immutable data = cast(immutable ubyte[1000])__data; } Bye, bearophile
Re: Any GPL video games in D2
On Wednesday, 25 June 2014 at 15:35:25 UTC, Leandro Motta Barros via Digitalmars-d-learn wrote: Hi, Some time ago I wrote this Tetris-like game: https://bitbucket.org/lmb/anytris (also on GitHub: https://github.com/lmbarros/Anytris) Nothing fancy. I am sure there are better examples out there. And maybe this is not the best code to show to students ;-) Also, license is ZLib -- I assume it will be good for your purposes. LMB On Wed, Jun 25, 2014 at 11:24 AM, Binarydepth via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I would like to show D in action to other programmers/students. Anyone knows of a Video Game coded in D2 ? Thank you Thank you. Very appreciated. I will check it.
Re: Any GPL video games in D2
On Wednesday, 25 June 2014 at 16:37:13 UTC, Namespace wrote: On Wednesday, 25 June 2014 at 14:24:11 UTC, Binarydepth wrote: I would like to show D in action to other programmers/students. Anyone knows of a Video Game coded in D2 ? Thank you Here are two: http://dgame-dev.de/?page=show That's great.They are using Derelict3 and SDL. It's in very good shape for what I want to do :)
Re: Returning fixed size arrays
On Wednesday, 25 June 2014 at 20:55:47 UTC, bearophile wrote: Is it possible and a good idea to change the D ABI to make code like this avoid an array copy in 100% of the cases (without inlining)? ubyte[1000] foo() nothrow @safe { typeof(return) data; // some code here. return data; } void main() nothrow { immutable data = foo(); } Bye, bearophile Isn't this a case for Named Return Value Optimization?
Re: Returning fixed size arrays
Tobias Pankrath: Isn't this a case for Named Return Value Optimization? Perhaps, but then why aren't dmd/ldc doing it? And the question was if that's possible in the ABI, so it always happens (unless the array is very small). Bye, bearophile
Re: expose class declared in unittest
On Wednesday, 25 June 2014 at 20:25:50 UTC, rcor wrote: Dummy will not exist unless compiled with -unittest, correct? Never mind, just verified that this is true. Thanks again.
Re: Any GPL video games in D2
On Wednesday, 25 June 2014 at 21:12:23 UTC, Binarydepth wrote: On Wednesday, 25 June 2014 at 16:37:13 UTC, Namespace wrote: On Wednesday, 25 June 2014 at 14:24:11 UTC, Binarydepth wrote: I would like to show D in action to other programmers/students. Anyone knows of a Video Game coded in D2 ? Thank you Here are two: http://dgame-dev.de/?page=show That's great.They are using Derelict3 and SDL. It's in very good shape for what I want to do :) Actually, they use Dgame. Dgame however used Derelict3 (SDL OpenGL). :)
Re: Returning fixed size arrays
On Wednesday, 25 June 2014 at 20:59:29 UTC, bearophile wrote: Is it possible and a good idea to change the D ABI to make code like this avoid an array copy in 100% of the cases (without inlining)? I meant, letting the compiler rewrite that code like this: void foo(ref ubyte[1000] __data) nothrow @safe { __data[] = 0; // some code here. } void main() nothrow { ubyte[1000] __data = void; foo(__data); immutable data = cast(immutable ubyte[1000])__data; } Bye, bearophile perhaps i'm misunderstanding things, but isn't this exactly what the System V ABI specifies anyway? Large aggregate returns are allocated on the calling stack, passed by hidden pointer.
Re: Momentary Eh?! for a Dynamic Language Programmmer. Tuples vs Arrays. Just rambling.
On Monday, 23 June 2014 at 22:08:59 UTC, John Carter wrote: On Monday, 23 June 2014 at 21:26:19 UTC, Chris Williams wrote: More likely what you want are variants: Hmm. Interesting. Yes, Variant and VariantArray are much closer to the dynamic language semantics... But the interesting thing is Tuple is much closer to What I Mean when I create these things. I probably should used Rubies http://ruby-doc.org/core-2.0/Struct.html but apart from naming the elements it gives me nothing beyond more keystrokes to enter. Tuple is very similar, but also grants type safety. D has structs. If you have any problem working with Tuples, you might consider moving over.
Re: DDoc and private members / mixins / UDAs
On Wednesday, 25 June 2014 at 18:49:27 UTC, Stefan Frijters wrote: Let me preface this by admitting that I'm not sure I'm using the DDoc functionality properly at all, so let me know if my questions are bogus. Is it possible to: - Add private members to documentation? - Have DDoc do its thing after mixins have been handled? - Access UDAs? To expand on the last point: in my code I currently use UDAs to annotate variables that can be set in an input file; at compile time I use __traits to find all of them and create a parser etc. for them. I would really like to be able to create a minimal documentation, which only includes all such UDA-annotated variables from all modules, so it can be used as a short manual for the end user, rather than being developer documentation. I was thinking of using a LaTeX template and using the absence or presence of the UDA to somehow insert a macro that is either just blank or actually adds the documentation. Any tips to achieve this in a different fashion are also appreciated. Kind regards, Stefan Frijters 1) You might be interested by ddox [1] which provides more functionality and a nicer output than DDoc (actually, the phobos docs are being replacd by it). As you can see in the example, you can filter what goes in and what doesn't, as well as the minimum protection level (so you can chose to put private in it). Note that if you have a dub-based project, you can just run dub --build=ddox to get it working. 2) Yes for regular mixin, no for template mixins. Example: mixin strToSym!(moduleName!moduleName); // Template mixin mixin(int a = 42;); // regular mixin Will output (using dmd -Xfdocs.json module.d): { name : strToSym!(\std.traits\), kind : mixin, line : 62 }, { name : a, kind : variable, protection : private, file : CppWrapper.d-mixin-63, line : 63, deco : i, init : 42 }, 3) Nope. Again, example: @(ThisIsAFunction) void foo() {} Ouputs in the docs.json: { name : foo, kind : function, protection : private, file : CppWrapper.d, line : 66, deco : FZv, endline : 66 }, Hope this helps ! [1]: https://github.com/rejectedsoftware/ddox
Re: Using two flags in conditonal compilation (version)
version(DigitalMars) version = DMDAsm; version(LDC) version = DMDAsm; version(DMDAsm) asm { //dmd/ldc asm here } version(GDC) asm { //gdc asm here } http://dlang.org/version.html#VersionSpecification
Re: Using attributes inside template instantiation
On Wednesday, 25 June 2014 at 17:21:21 UTC, H. S. Teoh via Digitalmars-d-learn wrote: The term attribute is a bit confusing, especially since property is also used in the language to refer to something completely different. A better term is perhaps annotation. The @foo is an annotation on x, but its type is just int. Agree whole-heartedly. I usually introduce people to the idea by referring to them as annotations, which they understand quickly, then later tell them that it's called an attribute because of reasons no one knows. I get funny looks, but at least they comprehend it. I'm not so sure it's too late to get the terminology changed, though, and I sincerely hope it will.
[Issue 10690] Assertion failure in swap caused by array() of a filter() of tuples of string
https://issues.dlang.org/show_bug.cgi?id=10690 Sönke Ludwig slud...@outerproduct.org changed: What|Removed |Added CC||maidenp...@hotmail.com --- Comment #9 from Sönke Ludwig slud...@outerproduct.org --- *** Issue 11357 has been marked as a duplicate of this issue. *** --
[Issue 11357] Weird behavior of appender with File as the element... do not know exactly where the bug resides.
https://issues.dlang.org/show_bug.cgi?id=11357 Sönke Ludwig slud...@outerproduct.org changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |DUPLICATE --- Comment #5 from Sönke Ludwig slud...@outerproduct.org --- The original issue has been resolved for DMD 2.065. *** This issue has been marked as a duplicate of issue 10690 *** --
[Issue 12988] New: Diagnostic for wrong 'this' prefix when matching parameter is found should improve
https://issues.dlang.org/show_bug.cgi?id=12988 Issue ID: 12988 Summary: Diagnostic for wrong 'this' prefix when matching parameter is found should improve Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: diagnostic Severity: enhancement Priority: P1 Component: DMD Assignee: nob...@puremagic.com Reporter: andrej.mitrov...@gmail.com - class F { void test(string str) { this.str = ; } } void main() { } - $ dmd test.d test.d(5): Error: no property 'str' for type 'test.F' The compiler should try to detect whether 'str' is also a parameter name, and in this case emit something like: $ dmd test.d test.d(5): Error: no property 'str' for type 'test.F', did you mean parameter 'str'? --
[Issue 12989] New: Wrong x86_64 code for delegate return when compiled as lib (-lib)
https://issues.dlang.org/show_bug.cgi?id=12989 Issue ID: 12989 Summary: Wrong x86_64 code for delegate return when compiled as lib (-lib) Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: critical Priority: P1 Component: DMD Assignee: nob...@puremagic.com Reporter: dragosc...@gmail.com Created attachment 1365 -- https://issues.dlang.org/attachment.cgi?id=1365action=edit expose bug by running ./runme.sh Wrong code for returning a delegate from a synchronized method of a class with invariants. Compiling it as library with -lib (2.065) following code is generated at the end of the method A.foo (see the comments inline): 102:48 8b 45 c8 mov-0x38(%rbp),%rax -- $rax contains the address of the delegate 106:48 8b 48 08 mov0x8(%rax),%rcx -- $rcx contains the delegate function pointer 10a:48 8b 30 mov(%rax),%rsi-- $rsi contains the context pointer 10d:48 83 ec 08 sub$0x8,%rsp 111:e8 15 00 00 00 callq 12b _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x12b 116:48 83 c4 08 add$0x8,%rsp 11a:eb 23jmp13f _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x13f 11c:48 83 ec 08 sub$0x8,%rsp 120:e8 06 00 00 00 callq 12b _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x12b 125:48 83 c4 08 add$0x8,%rsp 129:eb 10jmp13b _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x13b 12b:48 bf 00 00 00 00 00 movabs $0x0,%rdi 132:00 00 00 135:e8 00 00 00 00 callq 13a _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x13a 13a:c3 retq 13b:31 f6xor%esi,%esi 13d:31 c9xor%ecx,%ecx 13f:48 89 75 d0 mov%rsi,-0x30(%rbp) -- try to save delegate pointer and context on stack, but they are 143:48 89 4d d8 mov%rcx,-0x28(%rbp) -- already overwritten by the previous monitor_unlock call 147:48 83 7d e0 00 cmpq $0x0,-0x20(%rbp) 14c:75 07jne155 _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x155 14e:31 ffxor%edi,%edi 150:e8 00 00 00 00 callq 155 _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x155 155:48 8b 7d e0 mov-0x20(%rbp),%rdi 159:e8 00 00 00 00 callq 15e _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x15e 15e:48 8b 55 d8 mov-0x28(%rbp),%rdx 162:48 8b 45 d0 mov-0x30(%rbp),%rax 166:41 5fpop%r15 168:41 5epop%r14 16a:41 5dpop%r13 16c:41 5cpop%r12 16e:5b pop%rbx 16f:48 8b e5 mov%rbp,%rsp 172:5d pop%rbp 173:c3 retq 174:0f 1f 40 00 nopl 0x0(%rax) Strangely compiling the object file with -c (2.065) generates right code: 102:48 8b 45 c8 mov-0x38(%rbp),%rax -- $rax contains the address of the delegate 106:48 8b 50 08 mov0x8(%rax),%rdx -- $rdx contains the delegate function pointer 10a:48 8b 00 mov(%rax),%rax-- $rax contains the context pointer 10d:48 89 45 d0 mov%rax,-0x30(%rbp) -- save them on stack 111:48 89 55 d8 mov%rdx,-0x28(%rbp) -- save them on stack 115:48 83 ec 08 sub$0x8,%rsp 119:e8 15 00 00 00 callq 133 _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x133 11e:48 83 c4 08 add$0x8,%rsp 122:eb 2fjmp153 _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x153 124:48 83 ec 08 sub$0x8,%rsp 128:e8 06 00 00 00 callq 133 _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x133 12d:48 83 c4 08 add$0x8,%rsp 131:eb 10jmp143 _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x143 133:48 bf 00 00 00 00 00 movabs $0x0,%rdi 13a:00 00 00 13d:e8 00 00 00 00 callq 142 _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x142 142:c3 retq 143:48 c7 45 d0 00 00 00 movq $0x0,-0x30(%rbp) 14a:00 14b:48 c7 45 d8 00 00 00 movq $0x0,-0x28(%rbp) 152:00 153:48 83 7d e0 00 cmpq $0x0,-0x20(%rbp) 158:75 07jne161 _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x161 15a:31 ffxor%edi,%edi 15c:e8 00 00 00 00 callq 161 _D17delegatereturnbug1A3fooMFDFZvZDFZv+0x161 161:48 8b 7d e0 mov-0x20(%rbp),%rdi
[Issue 12990] New: utf8 string not read/written to windows console
https://issues.dlang.org/show_bug.cgi?id=12990 Issue ID: 12990 Summary: utf8 string not read/written to windows console Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: normal Priority: P1 Component: DMD Assignee: nob...@puremagic.com Reporter: sum.pr...@gmail.com import std.stdio; void main() { string s = stdin.readln(); write(s); } The code above should write a unicode (specifically cyrillic) string to output to a windows console (with cp set to 65001), but the string comes out empty. The same code works correctly when run through windows debugger windbg.exe, so hopefully it will be an easy fix. --
[Issue 12991] New: Possible performance optimization for std.range binary search
https://issues.dlang.org/show_bug.cgi?id=12991 Issue ID: 12991 Summary: Possible performance optimization for std.range binary search Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: Phobos Assignee: nob...@puremagic.com Reporter: bearophile_h...@eml.cc In std.range there is a binary search for SortedRange: // Assuming a predicate test that returns 0 for a left portion // of the range and then 1 for the rest, returns the index at // which the first 1 appears. Used internally by the search routines. private size_t getTransitionIndex(SearchPolicy sp, alias test, V)(V v) if (sp == SearchPolicy.binarySearch isRandomAccessRange!Range) { size_t first = 0, count = _input.length; while (count 0) { immutable step = count / 2, it = first + step; if (!test(_input[it], v)) { first = it + 1; count -= step + 1; } else { count = step; } } return first; } Binary search isn't very cache-friendly, so perhaps inside the binary search it's a good idea to switch to a linear search when the search interval is small enough. Where small enough means few cache lines long (assuming cache lines of 64 bytes. So you need T.sizeof to know how many items of type T this interval is). --
[Issue 12991] Possible performance optimization for std.range binary search
https://issues.dlang.org/show_bug.cgi?id=12991 Andrei Alexandrescu and...@erdani.com changed: What|Removed |Added CC||and...@erdani.com --- Comment #1 from Andrei Alexandrescu and...@erdani.com --- A cache-friendly binary search with cache friendliness and performance guarantees would be galloping search. --
[Issue 12991] Possible performance optimization for std.range binary search
https://issues.dlang.org/show_bug.cgi?id=12991 --- Comment #2 from bearophile_h...@eml.cc --- (In reply to Andrei Alexandrescu from comment #1) A cache-friendly binary search with cache friendliness and performance guarantees would be galloping search. That's not what I have suggested here. Here I have suggested to use binary search followed by linear search when the search range is few cache lines long. This is a generic (possible) improvement for the standard binary search, to be used (ideally) when you want to use a binary search. Galloping search is for a different purpose, like when you know the data you search for is near the start (or end, or a given point) of the array. --
[Issue 12992] New: Add an interpolate policy to binary search policies
https://issues.dlang.org/show_bug.cgi?id=12992 Issue ID: 12992 Summary: Add an interpolate policy to binary search policies Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: Phobos Assignee: nob...@puremagic.com Reporter: and...@erdani.com Currently http://dlang.org/phobos/std_range.html#.SearchPolicy lists five policies for binary searching. We should add interpolation. See e.g. http://www.reddit.com/r/programming/comments/290p6d/beating_the_binary_search_algorithm_interpolation/ --
[Issue 12992] Add an interpolate policy to binary search policies
https://issues.dlang.org/show_bug.cgi?id=12992 bearophile_h...@eml.cc changed: What|Removed |Added CC||bearophile_h...@eml.cc --- Comment #1 from bearophile_h...@eml.cc --- Interpolated search is nice, but it requires a knowledge of the distribution of the data. In general it's not easy to know it (and even if you know it, you need a give a lambda to the search function). --
[Issue 12992] Add an interpolate policy to binary search policies
https://issues.dlang.org/show_bug.cgi?id=12992 --- Comment #2 from Andrei Alexandrescu and...@erdani.com --- (In reply to bearophile_hugs from comment #1) Interpolated search is nice, but it requires a knowledge of the distribution of the data. That's why it's a policy chosen by the caller. In general it's not easy to know it (and even if you know it, you need a give a lambda to the search function). If the element type is numeric no lambda is needed. --
[Issue 12992] Add an interpolate policy to binary search policies
https://issues.dlang.org/show_bug.cgi?id=12992 --- Comment #3 from bearophile_h...@eml.cc --- (In reply to Andrei Alexandrescu from comment #2) If the element type is numeric no lambda is needed. I don't agree or I don't understand. If you have an array of sorted integers with a uniform distribution you need a certain interpolating function. if your array of sorted integers has a squared distribution, you need a different interpolating function, otherwise your search is slower than a standard binary search. Unless the interpolated search performs a statistics on the data, the user has to supply in both cases some kind of function that specifies that distribution. --
[Issue 12958] core.checkedint.mulu is broken
https://issues.dlang.org/show_bug.cgi?id=12958 --- Comment #5 from safety0ff.bugz safety0ff.b...@gmail.com --- (In reply to David Nadlinger from comment #3) At first glance, this looks good, but chances are I've missed to check some other edge cases. To this end, it would be awesome if somebody could write a quick test harness that verifies random multiplication results using BigInt arithmetic. I written some randomized tests using inline assembly, so far so good. --
[Issue 12992] Add an interpolate policy to binary search policies
https://issues.dlang.org/show_bug.cgi?id=12992 --- Comment #4 from Andrei Alexandrescu and...@erdani.com --- (In reply to bearophile_hugs from comment #3) (In reply to Andrei Alexandrescu from comment #2) If the element type is numeric no lambda is needed. I don't agree or I don't understand. If you have an array of sorted integers with a uniform distribution you need a certain interpolating function. if your array of sorted integers has a squared distribution, you need a different interpolating function, otherwise your search is slower than a standard binary search. Unless the interpolated search performs a statistics on the data, the user has to supply in both cases some kind of function that specifies that distribution. I was thinking of supporting the uniform distribution assumption. --
[Issue 12992] Add an interpolate policy to binary search policies
https://issues.dlang.org/show_bug.cgi?id=12992 --- Comment #5 from bearophile_h...@eml.cc --- (In reply to Andrei Alexandrescu from comment #4) I was thinking of supporting the uniform distribution assumption. OK, then this strict assumption needs to be stated clearly in the docs. --