Re: immutable string
On Saturday, April 27, 2013 20:14:10 Michael wrote: > According to http://dlang.org/const3.html > > >The simplest immutable declarations use it as a storage class. > >It can be used to declare manifest constants. > > So, immutable string s = "..."; should be a manifest constant. > > If it is a constant that it can be used in switch(...). > > switch(someStr) > { > case s: ...; // Error: case must be a string or an integral > constant, not s. > }, > > but string s = "..."; works good. > > Why? Because an immutable string _isn't_ a manifest constant. Only enums are manifest constants. immutable s = "foo"; or immutable string s = "foo"; specifically create an immutable variable. It has an address and doesn't result in "foo" being copy-pasted everywhere that s is used like it would if s were an enum. It's no different from string s = "foo"; or auto s = "foo"; except that when is is immutable, it's implicitly shared, and you can't mutate it. - Jonathna m Davis
Re: Simple delete directory tree?
On Friday, April 26, 2013 17:01:43 Nick Sabalausky wrote: > On Fri, 26 Apr 2013 22:55:36 +0200 > > "Andrej Mitrovic" wrote: > > On Friday, 26 April 2013 at 20:54:41 UTC, Nick Sabalausky wrote: > > > Does phobos have a simple way to delete a directory tree? > > > std.file.rmdir(path) and std.file.remove(path) don't seem to do > > > it. > > > > Try rmdirRecurse > > I don't know how I managed to overlook that! Thanks :) > > Unfortunately, that's still choking with "Access is denied" on > something inside a ".git" subdirectory. That's an interesting problem to solve. If you can't legally remove a file, then rmdirRecurse either has to throw or ignore it. If it ignores it, the only way to know what went wrong would be to loop through the files that were removed (which could also blow up depending on the file permissions) and see what happens when you try and call remove or rmdir on them directly. On the other hand, if it throws, then you're basically forces to re-implement rmdirRecurse yourself and make it delete every file that you can if you want to at least delete the files that you can delete. Neither approach is exactly ideal. Maybe rmdirRecurse should be changed so that it ignores exceptions and returns whether it succeeded at removing everything or not (since it's void right now). However, if it _did_ fail due to a permissions issue, odds are that it would fail a _lot_ (especially if you're talking about a directory that you don't have permission to write to), and that would be very expensive. So, that might not be a good idea. We _could_ add another argument for telling it which behavior you wanted though. But I'm not sure that providing options like that is a good idea in the general case, particularly when you start considering all of the combinations of behaviors that functions like this could have. Still, it may be merited in this case. I don't know. - Jonathan M Davis
Re: DWT Gui program without console
This is a bit of a faq! There's two solutions, a def file or a command line argument to the linker. The first two posts here describe the .def file: http://forum.dlang.org/thread/xkvdpdsfzevanucrg...@forum.dlang.org And if you scroll down a bit to this post: http://forum.dlang.org/thread/xkvdpdsfzevanucrg...@forum.dlang.org#post-mailman.2578.1355147894.5162.digitalmars-d-learn:40puremagic.com you'll see the quickest solution: dmd.exe -L/SUBSYSTEM:WINDOWS dwt_app.d
DWT Gui program without console
Hi, writing a GUI tool using DWT, looks like the windows console pops up everytime I run the tool. How can I prevent/supress the console? I did some googling and found a tip that -version=gui helps, but its not working for me. Thanks in advance. user
Re: C++ and D bool compatibility
Jeremy DeHaan: I was reading this: http://dlang.org/cpp_interface.html And it mentions the various types and their compatibility with one another, but it leaves out bools. It would be very useful for me if it works out like this, but does anyone know off the top of their heads/tried it before? If it misses bool, then maybe that page needs a documentation patch. bools in D are represented with 1 byte, 0 or 1. In C++ their size is not fixed: "for Visual C++ 4.2, a call of sizeof(bool) yields 4, while in Visual C++ 5.0 and later, the same call yields 1." Bye, bearophile
C++ and D bool compatibility
Hey guys! I was reading this: http://dlang.org/cpp_interface.html And it mentions the various types and their compatibility with one another, but it leaves out bools. It would be very useful for me if it works out like this, but does anyone know off the top of their heads/tried it before? Thanks in advance! Jeremy
Re: immutable string
On Saturday, 27 April 2013 at 21:46:03 UTC, Minas Mina wrote: On Saturday, 27 April 2013 at 18:14:11 UTC, Michael wrote: According to http://dlang.org/const3.html The simplest immutable declarations use it as a storage class. It can be used to declare manifest constants. So, immutable string s = "..."; should be a manifest constant. If it is a constant that it can be used in switch(...). switch(someStr) { case s: ...; // Error: case must be a string or an integral constant, not s. }, but string s = "..."; works good. Why? Because maybe string is already (immutable)char[]? immutable string is converted to immutable(string) which is converted to immutable(immutable(char)[]). So no error with that.
Re: immutable string
On Saturday, 27 April 2013 at 18:14:11 UTC, Michael wrote: According to http://dlang.org/const3.html The simplest immutable declarations use it as a storage class. It can be used to declare manifest constants. So, immutable string s = "..."; should be a manifest constant. If it is a constant that it can be used in switch(...). switch(someStr) { case s: ...; // Error: case must be a string or an integral constant, not s. }, but string s = "..."; works good. Why? Because maybe string is already (immutable)char[]?
Re: string enums
On 04/27/2013 12:02 PM, Lodo wrote: > I found that if I try to make an enum of doubles, dmd outputs 36 very > complex error messages. That works too. Tried with 2.063-devel-f6d55a9-dirty: enum Type : double { a = 1.5, b = 2.5 } void main() { auto e = Type.min; } Ali
Re: string enums
On Saturday, 27 April 2013 at 18:41:45 UTC, Namespace wrote: Works fine for me with dmd >= 2.062 I'm using dmd 2.059. Maybe I will update it. I'm using MonoDevelop as IDE. I found that if I try to make an enum of doubles, dmd outputs 36 very complex error messages. I will try to investigate further.
Re: string enums
On Saturday, 27 April 2013 at 18:34:24 UTC, Lodo wrote: Hi! I'm having some troubles with an enum with base type string. Here's the code: enum Type:string { DOT="DOT", ID="ID", MODULE="MODULE", SEMICOLON="SEMICOLON", ERROR="ERROR", EOF="EOF" } For every element of the enum, dmd writes this message two times: Integer constant expression expected instead of "DOT" (with "ID", "MODULE", ... instead of "DOT") Am I doing something wrong? Thanks in advance. Lodo Works fine for me with dmd >= 2.062
Re: string enums
I can't help too much with your problem because I tried it and it works for me (on my dmd 2.061), but the pattern you're doing there is actually unneeded: enum Type { DOT, ID, MODULE, /* etc */ } would actually work and you can get a string out of it with std.conv.to: import std.conv; Type t = Type.DOT; string s = to!string(t); assert(s == "DOT");
string enums
Hi! I'm having some troubles with an enum with base type string. Here's the code: enum Type:string { DOT="DOT", ID="ID", MODULE="MODULE", SEMICOLON="SEMICOLON", ERROR="ERROR", EOF="EOF" } For every element of the enum, dmd writes this message two times: Integer constant expression expected instead of "DOT" (with "ID", "MODULE", ... instead of "DOT") Am I doing something wrong? Thanks in advance. Lodo
Re: immutable string
On Saturday, 27 April 2013 at 18:14:11 UTC, Michael wrote: Why? Probably outdated documentation (and in upcoming 2.063 this will be enforced properly). Use enum instead.
immutable string
According to http://dlang.org/const3.html The simplest immutable declarations use it as a storage class. It can be used to declare manifest constants. So, immutable string s = "..."; should be a manifest constant. If it is a constant that it can be used in switch(...). switch(someStr) { case s: ...; // Error: case must be a string or an integral constant, not s. }, but string s = "..."; works good. Why?
Re: Internationalization vs. Unicode
On 2013-04-27 00:09, Tyro[17] wrote: There are myriad encoding schemes. D natively supports Unicode and provide functionality via phobos. A byproduct of this is that since ASCII is a subset of Unicode, it also natively support ASCII. This is a plus for the language but what of the other encoding schemes? What library functionality is provided to manipulate or convert between those encoding schemes and Unicode? I have a need to convert from CKJ encoding (presently EUC-JP and Shift-JIS) to Unicode. How do I accomplish this using D/Phobos? Is there a standalone library that does this? If so, can someone point me to it? If not, is there planned functionality for inclusion in phobos or am I doomed to resorting to Java or some other language to accomplish this task (or at least until I'm educated enough to do it myself)? Would ICU do the work? If that's the case you can take a look at this: https://github.com/d-widget-toolkit/com.ibm.icu I will most likely not compile with the latest version of DMD. Also I don't know how complete it is. -- /Jacob Carlborg
Re: Simple delete directory tree?
On 2013-04-26 23:25, Nick Sabalausky wrote: FWIW, This seems to work fine, at least on windows: import std.process; version(Windows) system(`rmdir /S /Q "`~path~`"`); else system(`rm -rf '`~path~`'`); That's cheating. -- /Jacob Carlborg
Re: does GtkD (win7) support opengl?
27.04.2013 0:57, Mike Wey пишет: Should be working now. Yes, 32bit binary works well (didn't run 64bit). Thank you very much!