Re: D RAII with postblit disabled

2018-03-28 Thread Norm via Digitalmars-d-learn
On Thursday, 29 March 2018 at 04:16:55 UTC, Adam D. Ruppe wrote: On Thursday, 29 March 2018 at 04:12:38 UTC, Norm wrote: Is there a way to do this in D, or does it require special "create" functions for every struct that has a RAII-like struct as a member? You'll have to do it all the way up

Re: D RAII with postblit disabled

2018-03-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 29 March 2018 at 04:12:38 UTC, Norm wrote: Is there a way to do this in D, or does it require special "create" functions for every struct that has a RAII-like struct as a member? You'll have to do it all the way up (unless you can use a constructor with an argument and call that

Re: D RAII with postblit disabled

2018-03-28 Thread Norm via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 02:43:15 UTC, Adam D. Ruppe wrote: On Tuesday, 27 March 2018 at 02:35:23 UTC, Norm wrote: What's the best way to do this in D? I'd also add `@disable this();` and then a `static O make() { return O(theAllocator.make!int(99)); }` than you construct it with that s

Re: Static Foreach + Marking "compile time" variables

2018-03-28 Thread Chris Katko via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 23:42:26 UTC, Simen Kjærås wrote: On Wednesday, 28 March 2018 at 23:02:53 UTC, Chris Katko wrote: There's many things that can be done to make the code easier to follow. These lines: [...] [...] WOW. Thank you. That's the kind of tricks for (or more properly:

Re: Static Foreach + Marking "compile time" variables

2018-03-28 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 23:02:53 UTC, Chris Katko wrote: There's many things that can be done to make the code easier to follow. These lines: static if (!hasPosition) { assert(0, "Need to pass a position!"); } Can be replaced with thi

Re: unittests, dub and libraries

2018-03-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 28, 2018 21:29:22 Jesse Phillips via Digitalmars-d-learn wrote: > On Wednesday, 28 March 2018 at 03:07:23 UTC, Jonathan M Davis > > wrote: > > Run > > > > dub test > > > > The problem is that an executable needs a main, and a library > > doesn't have one, whereas when you'r

Re: Static Foreach + Marking "compile time" variables

2018-03-28 Thread Chris Katko via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 17:42:45 UTC, Steven Schveighoffer wrote: On 3/28/18 11:46 AM, Chris Katko wrote: enum hasRotate = anySatisfy!( isa(pos), a);  //if of type "pos" anySatisfy!(isa!pos, a) anySatisfy takes a template alias (in this case, an instantiation of isa with a speci

Re: unittests, dub and libraries

2018-03-28 Thread Jesse Phillips via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 21:29:22 UTC, Jesse Phillips wrote: And a note on the reverse, if you have an executable project $ dub test won't build in the app.d file since it contains main and dub test wants to avoid running your main function. For reference: https://github.com/dlang/dub/i

Re: unittests, dub and libraries

2018-03-28 Thread Jesse Phillips via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 03:07:23 UTC, Jonathan M Davis wrote: Run dub test The problem is that an executable needs a main, and a library doesn't have one, whereas when you're testing a library, you need an executable. So, a main must be inserted - e.g. with the -main flag to dmd.

Re: vibe.d & nginx

2018-03-28 Thread bauss via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 20:34:52 UTC, Adam D. Ruppe wrote: On Wednesday, 28 March 2018 at 19:42:24 UTC, bauss wrote: Can I just create multiple server sections in the config, even on the same port? Or is there something I have to be aware of? Multiple nginx configs can live on the same

Re: vibe.d & nginx

2018-03-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 19:42:24 UTC, bauss wrote: Can I just create multiple server sections in the config, even on the same port? Or is there something I have to be aware of? Multiple nginx configs can live on the same external port, though they will need to be running on different in

Re: vibe.d & nginx

2018-03-28 Thread bauss via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 19:42:24 UTC, bauss wrote: I know how to setup nginx to a single vibe.d application, but what if I host multiple vibe.d applications on the same host. How can I forward them using nginx correctly? Can I just create multiple server sections in the config, even on

Re: Building application with LDC and -flto=thin fails in link stage

2018-03-28 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 17:03:07 UTC, Seb wrote: dub supports dflags and lflags in the config file. lflags are the linker commands. Please read the thread. `lflags` is for passing flags to the _linker_ (i.e. those flags are prefixed with -L when passed to the _compiler_) Here, what

vibe.d & nginx

2018-03-28 Thread bauss via Digitalmars-d-learn
I know how to setup nginx to a single vibe.d application, but what if I host multiple vibe.d applications on the same host. How can I forward them using nginx correctly? Can I just create multiple server sections in the config, even on the same port? Or is there something I have to be aware of

Re: Static Foreach + Marking "compile time" variables

2018-03-28 Thread Chris Katko via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 17:08:39 UTC, Chris Katko wrote: On Wednesday, 28 March 2018 at 15:49:39 UTC, Chris Katko wrote: On Wednesday, 28 March 2018 at 15:46:42 UTC, Chris Katko wrote: [...] Whoops! Wrong error message. That's if I replace isa(pos) with IsIntegral. [...] Okay, the

Re: Static Foreach + Marking "compile time" variables

2018-03-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/28/18 11:46 AM, Chris Katko wrote: enum hasRotate = anySatisfy!( isa(pos), a);  //if of type "pos" anySatisfy!(isa!pos, a) anySatisfy takes a template alias (in this case, an instantiation of isa with a specific type), and then applies the template to all the elements of the alias

Re: Static Foreach + Marking "compile time" variables

2018-03-28 Thread Chris Katko via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 15:49:39 UTC, Chris Katko wrote: On Wednesday, 28 March 2018 at 15:46:42 UTC, Chris Katko wrote: [...] Whoops! Wrong error message. That's if I replace isa(pos) with IsIntegral. [...] Okay, the key appears to be here: funct2(123); //a function call void fu

Re: Building application with LDC and -flto=thin fails in link stage

2018-03-28 Thread Seb via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 16:42:23 UTC, Johan Engelen wrote: On Tuesday, 27 March 2018 at 22:10:33 UTC, Per Nordlöw wrote: On Tuesday, 27 March 2018 at 22:00:42 UTC, Johan Engelen wrote: Indeed. Please try to manually link first (without dub) by modifying the command on which dub errors:

Re: Building application with LDC and -flto=thin fails in link stage

2018-03-28 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 22:10:33 UTC, Per Nordlöw wrote: On Tuesday, 27 March 2018 at 22:00:42 UTC, Johan Engelen wrote: Indeed. Please try to manually link first (without dub) by modifying the command on which dub errors: ``` ldmd2 -flto=thin -of.dub/build/application-release-nobounds-

Re: Fixing 18615, how to handle @safe/pure/nothrow test breakage due to object.opEquals?

2018-03-28 Thread SimonN via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 15:04:27 UTC, Kagamin wrote: See line 1957, attributes are not inferred. Wow, that hit my blind spot. :-O Thanks. I've moved the RebindableCommon.opEquals outside of the attributes and all tests pass, as expected. -- Simon

Re: Static Foreach + Marking "compile time" variables

2018-03-28 Thread Chris Katko via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 15:46:42 UTC, Chris Katko wrote: On Wednesday, 28 March 2018 at 08:05:55 UTC, Simen Kjærås wrote: On Wednesday, 28 March 2018 at 07:45:59 UTC, Chris Katko wrote: I have a static foreach that goes through the parameter list and if it sees a class like "rotate", ide

Re: Static Foreach + Marking "compile time" variables

2018-03-28 Thread Chris Katko via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 08:05:55 UTC, Simen Kjærås wrote: On Wednesday, 28 March 2018 at 07:45:59 UTC, Chris Katko wrote: I have a static foreach that goes through the parameter list and if it sees a class like "rotate", ideally, I want it to mark a boolean "has_rotate=true" Then simpl

Re: "in" no longer "scope" since 2.079.0?

2018-03-28 Thread Kagamin via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 09:58:11 UTC, bauss wrote: So now "in" is basically just an alias and serves no real purpose or is there a plan to eventually make "in" mean something other than just "const"? At this point it's the spec that serves no real purpose, sometimes in is scope, sometime

Re: Fixing 18615, how to handle @safe/pure/nothrow test breakage due to object.opEquals?

2018-03-28 Thread Kagamin via Digitalmars-d-learn
See line 1957, attributes are not inferred.

Fixing 18615, how to handle @safe/pure/nothrow test breakage due to object.opEquals?

2018-03-28 Thread SimonN via Digitalmars-d-learn
Hi, I'm trying to fix Bugzilla 18615, Rebindable!A doesn't use class A's opEquals (returns a is b instead) [1]. The fix looks reasonably obvious, my code is at [2]. Most of the added lines is the unittest; the essence of the fix is: struct RebindableCommon(/* ... */) { // ...

Re: Manipulate slice or specific element of range and return range

2018-03-28 Thread Timoses via Digitalmars-d-learn
On Thursday, 22 March 2018 at 07:34:18 UTC, David Bennett wrote: On Thursday, 22 March 2018 at 04:49:39 UTC, Seb wrote: ``` alias lowercased = (m, n) => m.take(n).asLowerCase.chain(m.drop(n)); ``` ``` string input = "My Capital String"; auto lower1 = input.take(1).asLowerCase.chain(input.dr

can be (){yield();} mark as @trusted?

2018-03-28 Thread ikod via Digitalmars-d-learn
Hello, I have very short function with only Fiber.yield() inside it, like: void f1() { yield(); } This function is called inside @safe function f2: void f2() @safe { f1(); } Can f1 be marked as @trusted so that I can keep @safe for the whole hierarchy of calls? Thanks!

Re: get classname in static member

2018-03-28 Thread number via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 10:10:19 UTC, Simen Kjærås wrote: So to get the class name you'd generally use typeof(this).stringof. ... And could somebody explain to me why 'typeid(this).stringof' is returning 'typeid(this)'? Because that's what you're asking for. :p typeid returns the ru

Re: get classname in static member

2018-03-28 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 09:44:35 UTC, number wrote: Is there a way to get the classname without specifying the class in the first place as required by classinfo and fullyQualifiedName? extracting it from __FUNCTION__ wouldn't work outside a function, i.e. for a classfield, and 'this' do

Re: get classname in static member

2018-03-28 Thread bauss via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 09:44:35 UTC, number wrote: And could somebody explain to me why 'typeid(this).stringof' is returning 'typeid(this)'? stringof will return a string equivalent to the expression or symbol's representation, not its definition. Meaning: (212 + 221).stringof == "2

get classname in static member

2018-03-28 Thread number via Digitalmars-d-learn
Is there a way to get the classname without specifying the class in the first place as required by classinfo and fullyQualifiedName? extracting it from __FUNCTION__ wouldn't work outside a function, i.e. for a classfield, and 'this' doesn't work in static members. It's just about simple debug

Re: Checking if a structs .init value is zero bits only

2018-03-28 Thread Per Nordlöw via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 01:39:40 UTC, Seb wrote: Have a look at: https://github.com/dlang/phobos/pull/6024 (review/feedbackon this PR is welcome!) Exactly what I wanted. Thanks! In use here https://github.com/nordlow/phobos-next/blob/41b9e0dcfbb4eed6b2ee52d0465425556f14c00f/src/open_

Re: Static Foreach + Marking "compile time" variables

2018-03-28 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 07:45:59 UTC, Chris Katko wrote: I have a static foreach that goes through the parameter list and if it sees a class like "rotate", ideally, I want it to mark a boolean "has_rotate=true" Then simply later on, once I've parsed the list, I pick an output path:

Static Foreach + Marking "compile time" variables

2018-03-28 Thread Chris Katko via Digitalmars-d-learn
I have a static foreach that goes through the parameter list and if it sees a class like "rotate", ideally, I want it to mark a boolean "has_rotate=true" Then simply later on, once I've parsed the list, I pick an output path: static if(has_rotate && has_position && has_scale) { /

Re: Checking if a structs .init value is zero bits only

2018-03-28 Thread Per Nordlöw via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 00:50:31 UTC, Ali Çehreli wrote: On 03/27/2018 05:15 PM, Per Nordlöw wrote: Is there a way to check if a struct `S` can be initialized using zero bits only, so that we can allocate and initialize an array of `S` in one go using `calloc`? If not, what should such