Re: When is a slice not a slice?

2014-06-06 Thread Alix Pexton via Digitalmars-d-learn
On 05/06/2014 8:56 PM, Philippe Sigaud via Digitalmars-d-learn wrote: enum b = DataAndView(1); assert (!sameTail(b.data, b.view)); I suppose it's because enums are manifest constants: the value they represent is 'copy-pasted' anew everywhere it appears in the code. So for

Re: When is a slice not a slice?

2014-06-06 Thread Alix Pexton via Digitalmars-d-learn
On 06/06/2014 8:52 AM, Alix Pexton wrote: And the two DataAndView(1), being completely separated, do not have the same tail. Ah, Isee, that does kinda make sense ^^ A re-factoring we go... However, the code that originally tripped over this issue had the call to sameTail in the struct's

Re: When is a slice not a slice?

2014-06-06 Thread Alix Pexton via Digitalmars-d-learn
On 05/06/2014 8:58 PM, Steven Schveighoffer wrote: On Thu, 05 Jun 2014 15:56:00 -0400, Philippe Sigaud via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: enum b = DataAndView(1); assert (!sameTail(b.data, b.view)); I suppose it's because enums are manifest

Re: When is a slice not a slice?

2014-06-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 6 June 2014 at 08:17:43 UTC, Alix Pexton wrote: On 05/06/2014 8:58 PM, Steven Schveighoffer wrote: On Thu, 05 Jun 2014 15:56:00 -0400, Philippe Sigaud via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: enum b = DataAndView(1); assert (!sameTail(b.data,

Weird behaviour when using -release in dmd

2014-06-06 Thread Mikko Aarnos via Digitalmars-d-learn
Hello all, I have a program which works perfectly when compiled without -release: parser a implies b equivalent not b implies not a Input: ((a implies b) equivalent ((not b) implies (not a))) CNF: (not a) or b) or (not b)) and (((not a) or b) or a)) and (((b or (not a )) or a) and ((b or

Building phobos documentation

2014-06-06 Thread Damian Day via Digitalmars-d-learn
I'm having some trouble with building Phobos documentation locally on Win32. I've been referring to this guide: http://wiki.dlang.org/Building_DMD#Building_the_Docs I don't want to pull it from github and I don't really need the tools building either. My make command is: make -f win32.mak

Create const regex?

2014-06-06 Thread AntonSotov via Digitalmars-d-learn
const r1 = regex(bla); matchFirst( big string, r1 ); // ERROR! immutable r2 = regex(bla); // ERROR! Why can I not use const/immutable regex?

Re: Create const regex?

2014-06-06 Thread Rikki Cattermole via Digitalmars-d-learn
On 7/06/2014 12:01 a.m., AntonSotov wrote: const r1 = regex(bla); matchFirst( big string, r1 ); // ERROR! immutable r2 = regex(bla); // ERROR! Why can I not use const/immutable regex? In none of your examples you have not defined the type of the variables. However you are giving it an

Re: Building phobos documentation

2014-06-06 Thread Robert Schadek via Digitalmars-d-learn
On 06/06/2014 12:22 PM, Damian Day via Digitalmars-d-learn wrote: I'm having some trouble with building Phobos documentation locally on Win32. I've been referring to this guide: http://wiki.dlang.org/Building_DMD#Building_the_Docs I don't want to pull it from github and I don't really need

Re: Weird behaviour when using -release in dmd

2014-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Fri, 06 Jun 2014 10:10:24 + Mikko Aarnos via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hello all, I have a program which works perfectly when compiled without -release: parser a implies b equivalent not b implies not a Input: ((a implies b) equivalent ((not b)

Re: Create const regex?

2014-06-06 Thread AntonSotov via Digitalmars-d-learn
On Friday, 6 June 2014 at 12:08:40 UTC, Rikki Cattermole wrote: In none of your examples you have not defined the type of the variables. However you are giving it an access modifier. I assume you are wanting auto. no. keyword const auto before the variable name - equivalently const.

Re: Weird behaviour when using -release in dmd

2014-06-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 6 June 2014 at 10:10:25 UTC, Mikko Aarnos wrote: Hello all, I have a program which works perfectly when compiled without -release: parser a implies b equivalent not b implies not a Input: ((a implies b) equivalent ((not b) implies (not a))) CNF: (not a) or b) or (not b)) and

Re: Create const regex?

2014-06-06 Thread hane via Digitalmars-d-learn
On Friday, 6 June 2014 at 12:01:55 UTC, AntonSotov wrote: const r1 = regex(bla); matchFirst( big string, r1 ); // ERROR! immutable r2 = regex(bla); // ERROR! Why can I not use const/immutable regex? I think it's a Phobos bug that can't use regex as immutable. You can use const regex with

Re: Create const regex?

2014-06-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 6 June 2014 at 12:01:55 UTC, AntonSotov wrote: const r1 = regex(bla); matchFirst( big string, r1 ); // ERROR! immutable r2 = regex(bla); // ERROR! Why can I not use const/immutable regex? Not sure, but I suspect Regex has some internal state which is mutated during matching.

Re: Create const regex?

2014-06-06 Thread Meta via Digitalmars-d-learn
On Friday, 6 June 2014 at 14:25:26 UTC, hane wrote: On Friday, 6 June 2014 at 12:01:55 UTC, AntonSotov wrote: const r1 = regex(bla); matchFirst( big string, r1 ); // ERROR! immutable r2 = regex(bla); // ERROR! Why can I not use const/immutable regex? I think it's a Phobos bug that can't

Re: Can't link libs?

2014-06-06 Thread Adam D. Ruppe via Digitalmars-d-learn
When you compile the final program, the library .d file needs to be available too, either in the folder based on its name or passed straight to dmd explicitly. Despite the presence of the .lib file, the .d file is still needed so it can get code prototypes and type names, etc., out of it.

Can't link libs?

2014-06-06 Thread K.K. via Digitalmars-d-learn
So being a noob and all I've gotten stuck on something stupid... Whenever I try to compile using DMD, and try to link .lib files I always get errors like: file4.d(2): Error: module file3 is in file 'file3lib\file3.d' which cannot be read import path[0] = %cd%\file3 import path[1] =

Re: Can't link libs?

2014-06-06 Thread K.K. via Digitalmars-d-learn
On Friday, 6 June 2014 at 16:33:27 UTC, Adam D. Ruppe wrote: When you compile the final program, the library .d file needs to be available too, either in the folder based on its name or passed straight to dmd explicitly. Despite the presence of the .lib file, the .d file is still needed so

Re: Can't link libs?

2014-06-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 June 2014 at 16:41:24 UTC, K.K. wrote: I have kept all the files in one folder. So if I don't need to explicitly call the .lib in DMD, does that mean the .lib is just a passive object? Should I make libs in place of object files? If you pass all the .d files at once, you don't

Re: Can't link libs?

2014-06-06 Thread K.K. via Digitalmars-d-learn
On Friday, 6 June 2014 at 16:52:24 UTC, Adam D. Ruppe wrote: On Friday, 6 June 2014 at 16:41:24 UTC, K.K. wrote: I have kept all the files in one folder. So if I don't need to explicitly call the .lib in DMD, does that mean the .lib is just a passive object? Should I make libs in place of

Re: When is a slice not a slice?

2014-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 06 Jun 2014 06:14:30 -0400, Rene Zwanenburg renezwanenb...@gmail.com wrote: On Friday, 6 June 2014 at 08:17:43 UTC, Alix Pexton wrote: On 05/06/2014 8:58 PM, Steven Schveighoffer wrote: Yes, this should work (and execute the initializer at compile time): static b = ... Ah, the

zip with fieldTuple

2014-06-06 Thread John via Digitalmars-d-learn
So let's say I'm trying to create a really simple ORM. I have a struct: struct foo { int a; float b; } I can iterate over the struct elements with the traits FieldTypeTuple!foo, I can iterate over the the string that represents the elements I want to shove in the struct, but

Re: zip with fieldTuple

2014-06-06 Thread bearophile via Digitalmars-d-learn
John: I can iterate over the struct elements with the traits FieldTypeTuple!foo, In such iteration you are using a static foreach. Types are compile-time constructs in D. If you need run-time entities you need to get their typeinfo. I can iterate over the the string that represents the

Re: zip with fieldTuple

2014-06-06 Thread Brad Anderson via Digitalmars-d-learn
On Friday, 6 June 2014 at 22:16:36 UTC, John wrote: So let's say I'm trying to create a really simple ORM. I have a struct: struct foo { int a; float b; } I can iterate over the struct elements with the traits FieldTypeTuple!foo, I can iterate over the the string that

Re: zip with fieldTuple

2014-06-06 Thread bearophile via Digitalmars-d-learn
John: C:\D\dmd2\windows\bin\..\..\src\phobos\std\range.d(3808): Error: template std.range.zip cannot deduce template function from argument types !()((int, float),string[]) By the way, I find it surprising that D/Phobos give a so good error message for a so messed up situation. I don't

Re: zip with fieldTuple

2014-06-06 Thread John via Digitalmars-d-learn
On Friday, 6 June 2014 at 22:27:38 UTC, bearophile wrote: John: I can iterate over the struct elements with the traits FieldTypeTuple!foo, In such iteration you are using a static foreach. Types are compile-time constructs in D. If you need run-time entities you need to get their typeinfo.

Creating new types from tuples.

2014-06-06 Thread Evan Davis via Digitalmars-d-learn
Hello, I'm looking to use the Tuple type as a way of generating types to represent data in a send recieve connection pair. I created a template to try this: template s_to_c(UDP packetType) { static if (packetType == UDP.ping) { alias Tuple!() s_to_c; } else static if

Re: Create const regex?

2014-06-06 Thread hane via Digitalmars-d-learn
On Friday, 6 June 2014 at 15:42:41 UTC, Meta wrote: You should not do this, as it will create a new regex everywhere you use it. Unlike const or immutable, enum in this situation is more or less like a C macro. #define r1 regex(bla) I see. Thanks.

Re: zip with fieldTuple

2014-06-06 Thread Brad Anderson via Digitalmars-d-learn
On Friday, 6 June 2014 at 23:18:49 UTC, John wrote: On Friday, 6 June 2014 at 22:27:38 UTC, bearophile wrote: John: I can iterate over the struct elements with the traits FieldTypeTuple!foo, In such iteration you are using a static foreach. Types are compile-time constructs in D. If you

Re: next!T

2014-06-06 Thread Andrew Edwards via Digitalmars-d-learn
On 5/25/14, 10:12 PM, Ali Çehreli wrote: On 05/25/2014 05:21 PM, Andrew Edwards wrote: Hello All, I wrote the following convenience functions to aid in my studies. Unfortunately, I'm using Java books (Ali I will get to yours soon enough) so the need was necessitated by the frequency of use in

Re: next!T

2014-06-06 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Saturday, 7 June 2014 at 02:23:18 UTC, Andrew Edwards wrote: This function now works for all types except dstring. This remains a problem I cannot figure out. The error code is as follows: $ rdmd -unittest textnext /usr/share/dmd/src/phobos/std/conv.d(3293): Error: cannot modify

Re: Creating new types from tuples.

2014-06-06 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Friday, 6 June 2014 at 23:44:04 UTC, Evan Davis wrote: Hello, I'm looking to use the Tuple type as a way of generating types to represent data in a send recieve connection pair. I created a template to try this: template s_to_c(UDP packetType) { static if (packetType ==

Re: next!T

2014-06-06 Thread Andrew Edwards via Digitalmars-d-learn
On 6/6/14, 10:57 PM, Chris Nicholson-Sauls wrote: On Saturday, 7 June 2014 at 02:23:18 UTC, Andrew Edwards wrote: Any assistance/advice is appreciated. Thanks, Andrew I got it working here by putting an else before the second static-if. Wow. Sometimes you really cannot see the things you

Re: next!T

2014-06-06 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Saturday, 7 June 2014 at 03:21:49 UTC, Andrew Edwards wrote: Wow. Sometimes you really cannot see the things you type no matter how long you stare at it. Thank you soo much. No problem. I only noticed when I re-typed it by hand to study the flow, and instinctively added the else out of

Re: Creating new types from tuples.

2014-06-06 Thread Evan Davis via Digitalmars-d-learn
On Saturday, 7 June 2014 at 03:14:52 UTC, Chris Nicholson-Sauls wrote: Is there any reason you couldn't (or would rather not) use structs rather than tuples? That would work. What would be the best way to auto-generate the types? I have somewhere around 30 already, and the number will grow