Get static fields!

2018-06-15 Thread DigitalDesigns via Digitalmars-d-learn
tupleof does not return static fields as does not Fields. Currently the only method seems to be use allMembers, but that returns members requiring filtering, which there is no good filtering checks. I'd simply like to get all the fields of a type, static and non-static.

Storing temp for later use with ranges

2018-06-15 Thread DigitalDesigns via Digitalmars-d-learn
Does ranges have the ability to store a temp value in a "range like way" that can be used later? The idea is to avoid having to create temp variables. A sort of range with "memory"

Can't start application on heroku

2018-06-15 Thread crimaniak via Digitalmars-d-learn
Hi all! The first try to host application on Heroku provider. The application is started and starts to listen in 3 seconds on the port, provided by heroku-buildpack-d. But the server doesn't detect listening and stops the application. On the local machine, the application works as expected.

Re: What is the point of nothrow?

2018-06-15 Thread jmh530 via Digitalmars-d-learn
On Friday, 15 June 2018 at 17:29:39 UTC, bauss wrote: [snip] There is a reason that I have not gotten rid of this: http://diamondmvc.org/docs/logging/#database-logging It just _works_ most of the time and really helpful when you do not have access to the server and/or the standard

Re: What is the point of nothrow?

2018-06-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/15/18 1:27 PM, bauss wrote: On Friday, 15 June 2018 at 17:25:18 UTC, wjoe wrote: On Thursday, 14 June 2018 at 22:27:42 UTC, bauss wrote: On Thursday, 14 June 2018 at 19:06:07 UTC, Jonathan M Davis wrote: So in case of a thrown Error, you can catch it and log it to a database. No, you

Re: What is the point of nothrow?

2018-06-15 Thread wjoe via Digitalmars-d-learn
On Friday, 15 June 2018 at 17:27:13 UTC, bauss wrote: On Friday, 15 June 2018 at 17:25:18 UTC, wjoe wrote: On Thursday, 14 June 2018 at 22:27:42 UTC, bauss wrote: On Thursday, 14 June 2018 at 19:06:07 UTC, Jonathan M Davis wrote: So in case of a thrown Error, you can catch it and log it to a

Re: What is the point of nothrow?

2018-06-15 Thread wjoe via Digitalmars-d-learn
On Friday, 15 June 2018 at 08:13:44 UTC, Kagamin wrote: On Wednesday, 13 June 2018 at 17:08:26 UTC, wjoe wrote: My question was more like what's the benefit of having thrown Errors corrupt your program state rendering it useless for debugging ? D allows various levels of performance and

Re: What is the point of nothrow?

2018-06-15 Thread bauss via Digitalmars-d-learn
On Friday, 15 June 2018 at 17:25:18 UTC, wjoe wrote: On Thursday, 14 June 2018 at 22:27:42 UTC, bauss wrote: On Thursday, 14 June 2018 at 19:06:07 UTC, Jonathan M Davis wrote: So in case of a thrown Error, you can catch it and log it to a database. No, you can't. Once the Error was thrown

Re: What is the point of nothrow?

2018-06-15 Thread bauss via Digitalmars-d-learn
On Friday, 15 June 2018 at 17:27:13 UTC, bauss wrote: On Friday, 15 June 2018 at 17:25:18 UTC, wjoe wrote: On Thursday, 14 June 2018 at 22:27:42 UTC, bauss wrote: On Thursday, 14 June 2018 at 19:06:07 UTC, Jonathan M Davis wrote: So in case of a thrown Error, you can catch it and log it to a

Re: What is the point of nothrow?

2018-06-15 Thread wjoe via Digitalmars-d-learn
On Thursday, 14 June 2018 at 22:27:42 UTC, bauss wrote: On Thursday, 14 June 2018 at 19:06:07 UTC, Jonathan M Davis wrote: So in case of a thrown Error, you can catch it and log it to a database. No, you can't. Once the Error was thrown the program is in invalid state and you can't assume

Re: comparing nullables

2018-06-15 Thread Alex via Digitalmars-d-learn
On Friday, 15 June 2018 at 16:49:47 UTC, bauss wrote: https://github.com/dlang/phobos/pull/6583 Thanks a lot.

Re: comparing nullables

2018-06-15 Thread bauss via Digitalmars-d-learn
On Friday, 15 June 2018 at 15:00:38 UTC, Alex wrote: Hi all, do you see any valid reason why the last line yields an error: import std.typecons; void main() { void* ptr1; void* ptr2; assert(ptr1 is null); assert(ptr2 is null); assert(ptr1 == ptr2);

Re: Implementing a tree with recursive Algebraic

2018-06-15 Thread Kamil Koczurek via Digitalmars-d-learn
On Friday, 15 June 2018 at 14:57:33 UTC, Adam D. Ruppe wrote: You can make the tree store a *pointer* to a tree though. That's the traditional way to do it and it works here too. Oh, alright. I changed Tree to be a class instead of a struct and it seems to work just fine now. Thanks a lot!

comparing nullables

2018-06-15 Thread Alex via Digitalmars-d-learn
Hi all, do you see any valid reason why the last line yields an error: import std.typecons; void main() { void* ptr1; void* ptr2; assert(ptr1 is null); assert(ptr2 is null); assert(ptr1 == ptr2); Nullable!uint val1; Nullable!uint val2;

Re: Implementing a tree with recursive Algebraic

2018-06-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 15 June 2018 at 14:53:13 UTC, Kamil Koczurek wrote: Can I somehow fix this, or is my approach inherently flawed? A tree there would be storing a copy of a tree which is storing a copy of a tree... where would it end? You can make the tree store a *pointer* to a tree though.

Implementing a tree with recursive Algebraic

2018-06-15 Thread Kamil Koczurek via Digitalmars-d-learn
Hi, I'm trying to implement a simple tree and this 3-liner was my initial idea: struct Tree(T) { Algebraic!(Tree, T)[] content; } But it doesn't work and I get the following error message: /.../variant.d(...): Error: struct `app.Tree` no size because of forward reference

Re: Why std.array : array needs pure postblit?

2018-06-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/15/18 7:56 AM, Andrea Fontana wrote: On Friday, 15 June 2018 at 11:48:59 UTC, Andrea Fontana wrote: On Friday, 15 June 2018 at 11:25:49 UTC, Basile B. wrote: Hello, i've tested locally and it can works by making `Appender.reserve()` and `Appender.ensureAddable()` function templates.

Re: Create an Algebraic type at compile time and more

2018-06-15 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 15 June 2018 at 10:53:35 UTC, uknys wrote: On Friday, 15 June 2018 at 07:27:22 UTC, Simen Kjærås wrote: [snip] Yeah I saw that Algebraic doesn't work at compile time, then I thought of using an Interface with one function (execute()) and making Hello and Toto as classes

Re: Why std.array : array needs pure postblit?

2018-06-15 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 15 June 2018 at 11:48:59 UTC, Andrea Fontana wrote: On Friday, 15 June 2018 at 11:25:49 UTC, Basile B. wrote: Hello, i've tested locally and it can works by making `Appender.reserve()` and `Appender.ensureAddable()` function templates. That was my idea too. But I wonder if

Re: Docs for subpackages?

2018-06-15 Thread Guillaume Piolat via Digitalmars-d-learn
On Thursday, 14 June 2018 at 04:39:16 UTC, 9il wrote: On Wednesday, 13 June 2018 at 14:56:10 UTC, 9il wrote: Hi, I am trying to build a large project that is split into dozen of sub-packages. How I can do it using dub without writing my own doc scripts? --combined does not help here. Best

Re: Why std.array : array needs pure postblit?

2018-06-15 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 15 June 2018 at 11:25:49 UTC, Basile B. wrote: Hello, i've tested locally and it can works by making `Appender.reserve()` and `Appender.ensureAddable()` function templates. That was my idea too. But I wonder if pureness of reserve and ensureAddable have a particular reason.

Re: Why std.array : array needs pure postblit?

2018-06-15 Thread Basile B. via Digitalmars-d-learn
On Friday, 15 June 2018 at 11:24:42 UTC, Basile B. wrote: On Friday, 15 June 2018 at 11:15:03 UTC, Andrea Fontana wrote: Check this code: https://run.dlang.io/is/PoluHI It won't work, because array appender requires a pure postblit. Why? Can we remove this limitation? Andrea Hello, i've

Re: Why std.array : array needs pure postblit?

2018-06-15 Thread Basile B. via Digitalmars-d-learn
On Friday, 15 June 2018 at 11:15:03 UTC, Andrea Fontana wrote: Check this code: https://run.dlang.io/is/PoluHI It won't work, because array appender requires a pure postblit. Why? Can we remove this limitation? Andrea Hello, i've tested locally and it can works by making

Why std.array : array needs pure postblit?

2018-06-15 Thread Andrea Fontana via Digitalmars-d-learn
Check this code: https://run.dlang.io/is/PoluHI It won't work, because array appender requires a pure postblit. Why? Can we remove this limitation? Andrea

Re: Create an Algebraic type at compile time and more

2018-06-15 Thread uknys via Digitalmars-d-learn
On Friday, 15 June 2018 at 07:27:22 UTC, Simen Kjærås wrote: On Thursday, 14 June 2018 at 19:15:38 UTC, uknys wrote: [...] First off - Algebraic doesn't work at compile-time[0]: // Error: memcpy cannot be interpreted at compile time, because it has no available source code enum a =

Re: What is the point of nothrow?

2018-06-15 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 17:08:26 UTC, wjoe wrote: My question was more like what's the benefit of having thrown Errors corrupt your program state rendering it useless for debugging ? D allows various levels of performance and safety. Though I'd say Errors not working in debug mode is

Re: Create an Algebraic type at compile time and more

2018-06-15 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 14 June 2018 at 19:15:38 UTC, uknys wrote: Hello, I wanted to know if such code was possible : alias Operation = Algebraic!(/* All type that implements X UDA */) struct X { int opcode; Operation h; } @X(0x01, Hello(3)) @X(0x02, Hello(4)) struct Hello { int Hello; }

Re: Class qualifier vs struct qualifier

2018-06-15 Thread David Bennett via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 07:35:25 UTC, RazvanN wrote: Hello, I'm having a hard time understanding whether this inconsistency is a bug or intended behavior: immutable class Foo {} immutable struct Bar {} void main() { import std.stdio : writeln; Foo a; Bar b;