Re: if auto and method call

2017-04-17 Thread ag0aep6g via Digitalmars-d-learn
On 04/18/2017 02:48 AM, Jethro wrote: I generally need this for regex stuff and it's quite annoying it doesn't work. if (!match(s, "\s*(?P.),").empty()) { // Need the result of match to do things! } but this doesn't work: if (!(auto r = match(s, "\s*(?P.),")).empty()) { } Stanislav Blinov

Re: Generating switch at Compile Time

2017-04-17 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 13 April 2017 at 21:06:52 UTC, Jesse Phillips wrote: I realize that this is likely really pushing the compile time generation but a recent change to the switch statement[1] is surfacing because of this usage. uninitswitch2.d(13): Deprecation: 'switch' skips declaration of variabl

Re: SFML gcc - MacOS

2017-04-17 Thread Joel via Digitalmars-d-learn
On Monday, 17 April 2017 at 08:48:06 UTC, Jacob Carlborg wrote: On 2017-04-16 10:11, Joel wrote: I've got Xcode, do I enter `xcode-select --install` in the terminal? Yes. That will get you access to Clang, the linker and other tools on the command line. It will also create /usr/include nee

Re: if auto and method call

2017-04-17 Thread Stanislav Blinov via Digitalmars-d-learn
Would be prettier as a language feature, but still: template test(alias pred) { import std.functional : unaryFun; alias P = unaryFun!pred; auto test(R)(R r) { struct Test { R v; string toString() { import std.co

Re: Recently added __equal

2017-04-17 Thread Jack Stouffer via Digitalmars-d-learn
On Monday, 17 April 2017 at 19:15:06 UTC, Nordlöw wrote: What's the plan for the recent adding __equal overloads at https://github.com/dlang/druntime/pull/1808/files Is it only meant for runtime and phobos to be updated? Or does user-libraries, such as container libraries, need to be updated

if auto and method call

2017-04-17 Thread Jethro via Digitalmars-d-learn
How to combine the need to localize a result for an if statement and have to call a method to get proper comparison: if (((auto x = X.value()).empty()) { } instead of having to do the long and winded way auto x = X.value(); if (x.empty()) { } Many times I need the result of a function insid

Re: Recently added __equal

2017-04-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 17 April 2017 at 19:15:06 UTC, Nordlöw wrote: What's the plan for the recent adding __equal overloads at https://github.com/dlang/druntime/pull/1808/files Is it only meant for runtime and phobos to be updated? Or does user-libraries, such as container libraries, need to be updated

Re: Stuck with DMD, and Unit-Threaded

2017-04-17 Thread Atila Neves via Digitalmars-d-learn
On Sunday, 16 April 2017 at 08:20:21 UTC, Russel Winder wrote: There are points when you need to ask someone for help… I am trying to get Dub to build integration tests from test-source as a separate thing from building unit tests from source. The latter is easy and works, as does building the

Re: Generating switch at Compile Time

2017-04-17 Thread ag0aep6g via Digitalmars-d-learn
On 04/17/2017 09:29 PM, Jesse Phillips wrote: On Thursday, 13 April 2017 at 21:33:28 UTC, ag0aep6g wrote: [...] By the way, in my opinion, `case li[0]:` shouldn't compile with the static immutable `list`. `list` and `li[0]` are dynamic values. The compiler only attempts (and succeeds) to evalua

Re: Empty Result

2017-04-17 Thread Ali Çehreli via Digitalmars-d-learn
On 04/17/2017 12:33 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Mon, Apr 17, 2017 at 12:05:19PM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] auto byNode(const(Tree) tree) { alias RangeType = typeof(byNode(tree.root)); Could this possibly be simplified to: alias Ra

Re: refRange with non copyable struct

2017-04-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 17, 2017 19:39:25 Stanislav Blinov via Digitalmars-d-learn wrote: > On Monday, 17 April 2017 at 19:00:44 UTC, Jonathan M Davis wrote: > > Because otherwise, it's not acting like a reference to the > > original range, which is the whole point of RefRange. The > > correct solution w

Re: Empty Result

2017-04-17 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Apr 17, 2017 at 12:05:19PM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] > auto byNode(const(Tree) tree) { > alias RangeType = typeof(byNode(tree.root)); Could this possibly be simplified to: alias RangeType = typeof(return); ? Or does that cause a circular depend

Re: refRange with non copyable struct

2017-04-17 Thread Stanislav Blinov via Digitalmars-d-learn
On Monday, 17 April 2017 at 19:00:44 UTC, Jonathan M Davis wrote: Because otherwise, it's not acting like a reference to the original range, which is the whole point of RefRange. The correct solution would probably be to @disable opAssign in the case where the original range can't be overwritt

Re: Generating switch at Compile Time

2017-04-17 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 13 April 2017 at 21:33:28 UTC, ag0aep6g wrote: That's not a static foreach. It's a normal run-time foreach. The switch jumps into the loop body without the loop head ever executing. The compiler is correct when it says that initialization of li is being skipped. Good good. I did

Recently added __equal

2017-04-17 Thread Nordlöw via Digitalmars-d-learn
What's the plan for the recent adding __equal overloads at https://github.com/dlang/druntime/pull/1808/files Is it only meant for runtime and phobos to be updated? Or does user-libraries, such as container libraries, need to be updated aswell?

Re: Empty Result

2017-04-17 Thread Ali Çehreli via Digitalmars-d-learn
On 04/17/2017 11:30 AM, Russel Winder via Digitalmars-d-learn wrote: I find myself in need of constructing an empty Result object. I tried takeNone!Result, but obviously the type Result doesn't appear to exist. Anyone any ideas? (Not a complete solution; just sharing your pain.) I had the sam

Re: refRange with non copyable struct

2017-04-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 17, 2017 18:45:46 Jerry via Digitalmars-d-learn wrote: > On Monday, 17 April 2017 at 18:07:36 UTC, Jonathan M Davis wrote: > > In this particular case, it looks like the main problem is > > RefRange's opAssign. For it to work, the type needs to be > > copyable. It might be reasonab

Re: refRange with non copyable struct

2017-04-17 Thread Jerry via Digitalmars-d-learn
On Monday, 17 April 2017 at 18:07:36 UTC, Jonathan M Davis wrote: In this particular case, it looks like the main problem is RefRange's opAssign. For it to work, the type needs to be copyable. It might be reasonable for RefRange to be enhanced so that it doesn't compile in opAssign if the range

Re: refRange with non copyable struct

2017-04-17 Thread Jerry via Digitalmars-d-learn
On Monday, 17 April 2017 at 18:07:36 UTC, Jonathan M Davis wrote: Non-copyable types tend to wreak havoc with things - Jonathan M Davis Basicly what I use this for is to combine RAII with ranges. Which I find quite useful when doing DB queries and the data is lazily fetched since this allows m

Empty Result

2017-04-17 Thread Russel Winder via Digitalmars-d-learn
I find myself in need of constructing an empty Result object. I tried takeNone!Result, but obviously the type Result doesn't appear to exist. Anyone any ideas? -- Russel. = Dr Russel Winder t: +44 20 7585 2200 voip

Re: refRange with non copyable struct

2017-04-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 17, 2017 17:23:32 Jerry via Digitalmars-d-learn wrote: > Hello guys, so I wanted to have a noncopyable range on the stack. > So my thoughts was to make it non copyable and use refRange > whenever I want to use it with map and others. > > But I got a compiler warning when doing so l

Re: Stuck with DMD, and Unit-Threaded

2017-04-17 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2017-04-17 at 11:03 +0200, Jacob Carlborg via Digitalmars-d- learn wrote: Thanks for the pointers to the example, I shall peruse. I now have the SCons build working fine (OK so there are bugs in the application code highlighted by the integration test bugs), so the D code is not wrong. Th

refRange with non copyable struct

2017-04-17 Thread Jerry via Digitalmars-d-learn
Hello guys, so I wanted to have a noncopyable range on the stack. So my thoughts was to make it non copyable and use refRange whenever I want to use it with map and others. But I got a compiler warning when doing so like this: import std.range; void main() { NonCopyable v;

Re: hidden passing of __FILE__ and __LINE__ into function

2017-04-17 Thread Dmitry via Digitalmars-d-learn
On Monday, 17 April 2017 at 14:23:50 UTC, Jonathan M Davis wrote: So, if you're okay with explicitly instantiating your variadic function template instead of having the types inferred, then it Yes, it's my case. That's a game engine, so some kilobytes isn't a problem. Moreover, possible that fu

Re: hidden passing of __FILE__ and __LINE__ into function

2017-04-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 17, 2017 13:45:18 Dmitry via Digitalmars-d-learn wrote: > On Monday, 17 April 2017 at 10:55:30 UTC, Jonathan M Davis wrote: > > They works, but it results in a new template being instantiated > > for every call, so you really shouldn't use __FILE__ or > > __LINE__ as template argum

Re: Can't pass data from filter to each

2017-04-17 Thread Stanislav Blinov via Digitalmars-d-learn
On Monday, 17 April 2017 at 10:02:22 UTC, Suliman wrote: New question. Can I put result of filtering in itself without creation of new variables like x: auto x = MySQLTablesRange.array.filter!(a=>a[0].coerce!string.canFind("_")); No. filter is simply a wrapper around the source range, it doe

Re: hidden passing of __FILE__ and __LINE__ into function

2017-04-17 Thread Dmitry via Digitalmars-d-learn
On Monday, 17 April 2017 at 10:55:30 UTC, Jonathan M Davis wrote: They works, but it results in a new template being instantiated for every call, so you really shouldn't use __FILE__ or __LINE__ as template arguments if you can avoid it. Does it matter if I anyway use template (S...) ? And what

Re: check Input

2017-04-17 Thread dennis via Digitalmars-d-learn
thank you all! i will try

Re: check Input

2017-04-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 17 April 2017 at 11:51:45 UTC, dennis wrote: Hi, try to build a little programm, but need to know how to check the input. For example: input only numbers: 0 - 9 but 1.5 for example is ok. thanks I will point you to Ali's book (free), it goes through the basics of input and out

Re: check Input

2017-04-17 Thread Nafees via Digitalmars-d-learn
On Monday, 17 April 2017 at 11:51:45 UTC, dennis wrote: Hi, try to build a little programm, but need to know how to check the input. For example: input only numbers: 0 - 9 but 1.5 for example is ok. thanks How I would do it: Run a loop, checking if the characters in input are within the

check Input

2017-04-17 Thread dennis via Digitalmars-d-learn
Hi, try to build a little programm, but need to know how to check the input. For example: input only numbers: 0 - 9 but 1.5 for example is ok. thanks

Re: Can't build simple project. Very strange errors

2017-04-17 Thread Suliman via Digitalmars-d-learn
On Friday, 14 April 2017 at 15:53:18 UTC, Rene Zwanenburg wrote: On Friday, 14 April 2017 at 15:42:33 UTC, Suliman wrote: On Friday, 14 April 2017 at 15:40:18 UTC, Rene Zwanenburg wrote: On Friday, 14 April 2017 at 15:31:21 UTC, Suliman wrote: On Friday, 14 April 2017 at 15:22:49 UTC, Rene Zwan

Re: hidden passing of __FILE__ and __LINE__ into function

2017-04-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 17, 2017 10:58:36 Basile B. via Digitalmars-d-learn wrote: > On Monday, 17 April 2017 at 10:55:30 UTC, Jonathan M Davis wrote: > > On Monday, April 17, 2017 10:30:35 Basile B. via > > > > Digitalmars-d-learn wrote: > >> On Monday, 17 April 2017 at 10:22:47 UTC, Dmitry wrote: > > vo

Re: hidden passing of __FILE__ and __LINE__ into function

2017-04-17 Thread Basile B. via Digitalmars-d-learn
On Monday, 17 April 2017 at 10:55:30 UTC, Jonathan M Davis wrote: On Monday, April 17, 2017 10:30:35 Basile B. via Digitalmars-d-learn wrote: On Monday, 17 April 2017 at 10:22:47 UTC, Dmitry wrote: void error(string msg, string file = __FILE__, size_t line = __LINE__) { ... } That's what

Re: hidden passing of __FILE__ and __LINE__ into function

2017-04-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 17, 2017 10:30:35 Basile B. via Digitalmars-d-learn wrote: > On Monday, 17 April 2017 at 10:22:47 UTC, Dmitry wrote: > > Hi there. > > > > Currently for messages about errors I use code like this: > > void add(string name, ref Scene scene) > > { > > > > if (name in

Re: hidden passing of __FILE__ and __LINE__ into function

2017-04-17 Thread Dmitry via Digitalmars-d-learn
On Monday, 17 April 2017 at 10:30:35 UTC, Basile B. wrote: when used as template value parameter, __FILE__ and __LINE__evaluate to the file and line of the call site. So help yourself ans use something like this: void error(string f = __FILE__, int l = __LINE__)(string msg){} Thank you, Basi

Re: hidden passing of __FILE__ and __LINE__ into function

2017-04-17 Thread Basile B. via Digitalmars-d-learn
On Monday, 17 April 2017 at 10:22:47 UTC, Dmitry wrote: Hi there. Currently for messages about errors I use code like this: void add(string name, ref Scene scene) { if (name in listOfScenes) { EError(__FILE__, __LINE__, "scene already exists".L, quoted(name)

hidden passing of __FILE__ and __LINE__ into function

2017-04-17 Thread Dmitry via Digitalmars-d-learn
Hi there. Currently for messages about errors I use code like this: void add(string name, ref Scene scene) { if (name in listOfScenes) { EError(__FILE__, __LINE__, "scene already exists".L, quoted(name)); } ... } Is there way for avoid using

Re: Can't pass data from filter to each

2017-04-17 Thread Suliman via Digitalmars-d-learn
New question. Can I put result of filtering in itself without creation of new variables like x: auto x = MySQLTablesRange.array.filter!(a=>a[0].coerce!string.canFind("_"));

Can't pass data from filter to each

2017-04-17 Thread Suliman via Digitalmars-d-learn
I am writing lambda function. I need filter data at first step and than do dome operation on them (for start simply print on the screen. I wrote next code: MySQLTablesRange.filter!(a=>a[0].coerce!string.canFind("_")).each!(a => to!int(a[0].coerce!string.split("_")[1]).writeln); But it's seem

Re: Stuck with DMD, and Unit-Threaded

2017-04-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-04-16 10:20, Russel Winder via Digitalmars-d-learn wrote: There are points when you need to ask someone for help… I am trying to get Dub to build integration tests from test-source as a separate thing from building unit tests from source. The latter is easy and works, as does building th

Re: SFML gcc - MacOS

2017-04-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-04-16 10:11, Joel wrote: I've got Xcode, do I enter `xcode-select --install` in the terminal? Yes. That will get you access to Clang, the linker and other tools on the command line. It will also create /usr/include needed to build C/C++ code from the command line. -- /Jacob Carlbo

Re: Stuck with DMD, and Unit-Threaded

2017-04-17 Thread Russel Winder via Digitalmars-d-learn
The report below was about using ldc2 on Fedora Rawhide. I get the same problem using dmd on Debian Sid. So I guess we are looking at Dub (and likely my use it it and dub.sdl file) as the problem. On Sun, 2017-04-16 at 09:20 +0100, Russel Winder wrote: > There are points when you need to ask someo

Re: Stuck with DMD, and Unit-Threaded

2017-04-17 Thread Russel Winder via Digitalmars-d-learn
On Sun, 2017-04-16 at 12:04 +0300, drug via Digitalmars-d-learn wrote: > […] > Try to add version for `integrationtest` to exclude `main` from > building  > like you did with unittests version. In dub.sdl add versions  > "integrationtests" for correspondence configuration and in  > `source\main.d`