www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - enum string

reply "Namespace" <rswhite4 googlemail.com> writes:
[code]
import std.regex;

enum Token : string {
	Blank = r"\s+"
}

void main() {
	const string text = "Foo Bar";

	// text.split(regex(Token.Blank)); // don't work
	
	const string blank = Token.Blank;
	text.split(regex(blank)); // work
}
[/code]

Can me somebody explain that? o.O
Aug 07 2012
parent reply Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On 07-Aug-12 21:05, Namespace wrote:
 [code]
 import std.regex;

 enum Token : string {
      Blank = r"\s+"
 }

 void main() {
      const string text = "Foo Bar";

      // text.split(regex(Token.Blank)); // don't work

      const string blank = Token.Blank;
      text.split(regex(blank)); // work
 }
 [/code]

 Can me somebody explain that? o.O
isSomeString!T regression? See enum & std.traits topic in d.D. Seems like it will work again in 2.061... -- Dmitry Olshansky
Aug 07 2012
next sibling parent "Namespace" <rswhite4 googlemail.com> writes:
On Tuesday, 7 August 2012 at 17:14:03 UTC, Dmitry Olshansky wrote:
 On 07-Aug-12 21:05, Namespace wrote:
 [code]
 import std.regex;

 enum Token : string {
     Blank = r"\s+"
 }

 void main() {
     const string text = "Foo Bar";

     // text.split(regex(Token.Blank)); // don't work

     const string blank = Token.Blank;
     text.split(regex(blank)); // work
 }
 [/code]

 Can me somebody explain that? o.O
isSomeString!T regression? See enum & std.traits topic in d.D. Seems like it will work again in 2.061...
-.-
Aug 07 2012
prev sibling parent reply "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Tuesday, August 07, 2012 21:14:00 Dmitry Olshansky wrote:
 isSomeString!T regression? See enum & std.traits topic in d.D.
 Seems like it will work again in 2.061...
Yeah. In 2.060, std.traits doesn't treat enums as their base type for stuff like isSomeString and isIntegral, which is the problem. It's been fixed on github, but it's still broken in 2.060. - Jonathan M Davis
Aug 07 2012
parent reply "Namespace" <rswhite4 googlemail.com> writes:
On Tuesday, 7 August 2012 at 18:31:41 UTC, Jonathan M Davis wrote:
 On Tuesday, August 07, 2012 21:14:00 Dmitry Olshansky wrote:
 isSomeString!T regression? See enum & std.traits topic in d.D.
 Seems like it will work again in 2.061...
Yeah. In 2.060, std.traits doesn't treat enums as their base type for stuff like isSomeString and isIntegral, which is the problem. It's been fixed on github, but it's still broken in 2.060. - Jonathan M Davis
Which file must i replace with his version from github to solve the problem?
Aug 08 2012
parent reply "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Wednesday, August 08, 2012 17:58:17 Namespace wrote:
 On Tuesday, 7 August 2012 at 18:31:41 UTC, Jonathan M Davis wrote:
 On Tuesday, August 07, 2012 21:14:00 Dmitry Olshansky wrote:
 isSomeString!T regression? See enum & std.traits topic in d.D.
 Seems like it will work again in 2.061...
Yeah. In 2.060, std.traits doesn't treat enums as their base type for stuff like isSomeString and isIntegral, which is the problem. It's been fixed on github, but it's still broken in 2.060. - Jonathan M Davis
Which file must i replace with his version from github to solve the problem?
I really wouldn't advise grabbing single files like that. The release was recent enough that it may be okay, but in general, that's just asking for trouble - especially with something as integral as std.traits. But if you really want to, this is the relevant pull request: https://github.com/D-Programming-Language/phobos/pull/739 std.conv, std.format, std.stdio, and std.traits were all changed as part of the fix. - Jonathan M Davis
Aug 08 2012
parent reply "Namespace" <rswhite4 googlemail.com> writes:
 I really wouldn't advise grabbing single files like that. The 
 release was
 recent enough that it may be okay, but in general, that's just 
 asking for
 trouble - especially with something as integral as std.traits. 
 But if you
 really want to, this is the relevant pull request:

 https://github.com/D-Programming-Language/phobos/pull/739

 std.conv, std.format, std.stdio, and std.traits were all 
 changed as part of
 the fix.

 - Jonathan M Davis
Fails on Win7 with: Error: don't know how to make '..\druntime\lib\druntime.lib' Quick question: I've asked that for some time: why is it std.stdio and not std.io?
Aug 08 2012
parent reply "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Wednesday, August 08, 2012 21:21:38 Namespace wrote:
 Quick question: I've asked that for some time: why is it
 std.stdio and not std.io?
I don't remember. Probably because it's stdio.h in C/C++. But Steven Schveighoffer is working on a replacement for it which will probably be named std.io. So, in the long run, that's probably what we'll end up with. - Jonathan M Davis
Aug 08 2012
parent reply "Namespace" <rswhite4 googlemail.com> writes:
And why ends my compilation with this error?
To cast any Token is _very_ annoying. -.-
Aug 08 2012
parent reply "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Thursday, August 09, 2012 01:21:29 Namespace wrote:
 And why ends my compilation with this error?
You're going to need to build both druntime and Phobos if you want to build Phobos. I don't know what's in the zip file, since I haven't used it in ages, so I don't know if you can build them from what's in there or whether you need to actually grab them from github.
 To cast any Token is _very_ annoying. -.-
I have no idea what you're talking about. - Jonathan M Davis
Aug 08 2012
parent reply "Namespace" <rswhite4 googlemail.com> writes:
Ok. Now I have built both phobos and druntime.
Then I have packed the generated phobos.lib in the windows> lib.
Now I still have in druntime a new folder "lib" with a 
druntime.lib in it.
What should I do with this?
And must I also build dmd anew?
Aug 09 2012
next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Thursday, August 09, 2012 10:43:15 Namespace wrote:
 Ok. Now I have built both phobos and druntime.
 Then I have packed the generated phobos.lib in the windows> lib.
 Now I still have in druntime a new folder "lib" with a
 druntime.lib in it.
 What should I do with this?
You don't need druntime.lib. You just need to make sure that your sc.ini points to the right import paths for the source and library paths for phobos.lib. If you copy phobos.lib to where the one from 2.060 is and copy the source over to where the source is for 2.060, then you should be fine without doing anything to sc.ini. But if you don't want to replace any of that, then you need to point sc.ini at the place where the new stuff is.
 And must I also build dmd anew?
Probably not given how recent the release was. Certainly, if everything built fine with dmd 2.060, then you should be fine, but in general, if you want to build the latest druntime or Phobos, you need the latest dmd. - Jonathan M Davis
Aug 09 2012
prev sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Thursday, August 09, 2012 01:51:43 Jonathan M Davis wrote:
 On Thursday, August 09, 2012 10:43:15 Namespace wrote:
 Ok. Now I have built both phobos and druntime.
 Then I have packed the generated phobos.lib in the windows> lib.
 Now I still have in druntime a new folder "lib" with a
 druntime.lib in it.
 What should I do with this?
You don't need druntime.lib. You just need to make sure that your sc.ini points to the right import paths for the source and library paths for phobos.lib. If you copy phobos.lib to where the one from 2.060 is and copy the source over to where the source is for 2.060, then you should be fine without doing anything to sc.ini. But if you don't want to replace any of that, then you need to point sc.ini at the place where the new stuff is.
 And must I also build dmd anew?
Probably not given how recent the release was. Certainly, if everything built fine with dmd 2.060, then you should be fine, but in general, if you want to build the latest druntime or Phobos, you need the latest dmd.
Another option would be to use dvm: https://bitbucket.org/doob/dvm/wiki/Home - Jonathan M Davis
Aug 09 2012