Re: LDC / BetterC / _d_run_main

2018-03-09 Thread Mike Franklin via Digitalmars-d-learn
On Saturday, 10 March 2018 at 02:25:38 UTC, Richard wrote: Hi, I've been trying to see if I can get an mbed project to work with Dlang basically compiling D code for use on a Cortex-M Proccessor You might be interested in the following, if you're not already aware: *

Re: LDC / BetterC / _d_run_main

2018-03-09 Thread Adam D. Ruppe via Digitalmars-d-learn
Eh, you can simplify it a lot by just writing your own C main (legal with or without betterC btw) --- import core.stdc.stdio; extern(C) int main(int argc, char** argv) { printf("hello world, %s\n", argc > 1 ? argv[1] : "user"); return 0; } --- that should work with any

LDC / BetterC / _d_run_main

2018-03-09 Thread Richard via Digitalmars-d-learn
Hi, I've been trying to see if I can get an mbed project to work with Dlang basically compiling D code for use on a Cortex-M Proccessor So far I've been using the latest release of LDC with the -BetterC Flag From what I can gather, normally without -BetterC it works like this: * main() -

Re: Generic Property Implementation

2018-03-09 Thread Mike Franklin via Digitalmars-d-learn
On Friday, 9 March 2018 at 14:46:04 UTC, Simen Kjærås wrote: This is the best I've come up with in the current language: struct S { int n; mixin property!("field", "get => this.n", "set => this.n = set"); } Not bad. Not good, but not bad either. Sadly, there are issues: 1) Wrong

Re: Returning constant / literal struct value (pod)

2018-03-09 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 09, 2018 at 09:30:53PM +, Cecil Ward via Digitalmars-d-learn wrote: > Can we return a literal struct value straight from a return statement? > > ie something like > mystruct_t myfunc() > { // ... blah > return { field1: val1, field2: val2; }; > } > assuming that the

Re: Compile-time variadic equality

2018-03-09 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 9 March 2018 at 19:24:03 UTC, Nordlöw wrote: I'm looking for a function (that probably should be placed in std.meta) named something like `areEqual` that checks whether all it's arguments are equal or not. Is there such as function already in Phobos? My usage is static if

Re: What's the proper way to add a local file dependence to dub?

2018-03-09 Thread crimaniak via Digitalmars-d-learn
On Sunday, 4 March 2018 at 16:46:56 UTC, Marc wrote: then copy it to sources folder? ... Also, symlinks are power tool for organizing your files without copying.

Returning constant / literal struct value (pod)

2018-03-09 Thread Cecil Ward via Digitalmars-d-learn
Can we return a literal struct value straight from a return statement ? ie something like mystruct_t myfunc() { // ... blah return { field1: val1, field2: val2; }; } assuming that the return type is defined suitably, and the struct is just a C struct, plain-old-data (ie not a

Re: does the shared keyword work with mutable structs?

2018-03-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, March 09, 2018 19:33:26 WhatMeWorry via Digitalmars-d-learn wrote: > On Friday, 9 March 2018 at 10:42:47 UTC, Kagamin wrote: > > To make a struct noncopyable, add @disable this(this); to it, > > then compiler will give an error on an attempt to copy it. > > I tried the @disable

Re: does the shared keyword work with mutable structs?

2018-03-09 Thread WhatMeWorry via Digitalmars-d-learn
On Friday, 9 March 2018 at 10:42:47 UTC, Kagamin wrote: To make a struct noncopyable, add @disable this(this); to it, then compiler will give an error on an attempt to copy it. I tried the @disable this(this); but now it doesn't even compile? Error: template std.concurrency.spawn cannot

Re: Compile-time variadic equality

2018-03-09 Thread Nordlöw via Digitalmars-d-learn
On Friday, 9 March 2018 at 19:24:03 UTC, Nordlöw wrote: I'm looking for a function (that probably should be placed in std.meta) named something like `areEqual` that checks whether all it's arguments are equal or not. Is there such as function already in Phobos? My usage is static if

Compile-time variadic equality

2018-03-09 Thread Nordlöw via Digitalmars-d-learn
I'm looking for a function (that probably should be placed in std.meta) named something like `areEqual` that checks whether all it's arguments are equal or not. Is there such as function already in Phobos? My usage is static if (allEqual!(staticMap!(ElementEncodingType, Rs))) { //

Re: Build an AliasSeq from memberFunction return types

2018-03-09 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 9 March 2018 at 17:47:46 UTC, Timoses wrote: To retrieve the member names the following (and filtering for only the functions) does the job: alias members = aliasSeqOf!([__traits(allMembers, S)]); This can be simplified to alias members = Alias!(__traits(allMembers, S));

Build an AliasSeq from memberFunction return types

2018-03-09 Thread Timoses via Digitalmars-d-learn
Hi, I feel like starting to dig deeper into D. And I got lost : D. I would like to reflect on defined bitfields: struct S { mixin!(bitfields!( , , , ... )); } which produces something like this in the back scenes: struct S { uint storage;

Re: How to fake a const method ?

2018-03-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, March 09, 2018 14:12:10 Basile B. via Digitalmars-d-learn wrote: > On Friday, 9 March 2018 at 13:47:34 UTC, Basile B. wrote: > > I would need this to work: > > > > ``` > > struct Foo > > { > > > > TypeInfo typeCache; > > > > TypeInfo getTypeCache() > > { > > > >

Re: complex arithmetic in D: multiple questions

2018-03-09 Thread bachmeier via Digitalmars-d-learn
On Friday, 9 March 2018 at 14:41:47 UTC, J-S Caux wrote: Going further, I'm really wondering what the plan is as far as Complex is concerned. Right now it just feels neglected (half-done/aborted transition from creal etc to Complex, lots of missing basic functions etc), and is one major

Re: complex arithmetic in D: multiple questions

2018-03-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 9 March 2018 at 14:41:47 UTC, J-S Caux wrote: Is this a case for a bug report? Seems pretty bizarre to do that, like an oversight/neglect. Yes if there's not one there for it already. OK thanks. I looked at libmir, and saw many good things there. I was wondering: is it still

Re: Generic Property Implementation

2018-03-09 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 9 March 2018 at 01:22:15 UTC, Mike Franklin wrote: * binary assignment operators (e.g. +=) * unary assignment operators (e.g. ++) * @safe, @nogc, and -betterC compatible * at least as good code generation as that proposed in the DIP when optimizations are enabled. * And should be

Re: complex arithmetic in D: multiple questions

2018-03-09 Thread J-S Caux via Digitalmars-d-learn
On Friday, 9 March 2018 at 13:56:33 UTC, Nicholas Wilson wrote: - I would expect the D `Complex!double` case to work faster than the `real` one. Why is it the other way around? [I can accept (and use) D with Complex!real running 1/3 the speed of C++ (but with increased accuracy), but I'd also

Re: How to fake a const method ?

2018-03-09 Thread Basile B. via Digitalmars-d-learn
On Friday, 9 March 2018 at 13:47:34 UTC, Basile B. wrote: I would need this to work: ``` struct Foo { TypeInfo typeCache; TypeInfo getTypeCache() { alias NotThePoint = ubyte; if (typeCache is null) typeCache = typeid(NotThePoint); return

Re: How to fake a const method ?

2018-03-09 Thread Basile B. via Digitalmars-d-learn
On Friday, 9 March 2018 at 13:54:07 UTC, Basile B. wrote: On Friday, 9 March 2018 at 13:47:34 UTC, Basile B. wrote: - `type()` really has to be const because it's used in an opEquals that's used by an AA (key is const so opEquals has to as well) And the most annoying is that the non reduced

Re: complex arithmetic in D: multiple questions

2018-03-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 9 March 2018 at 12:34:40 UTC, J-S Caux wrote: Please bear with me, this is a long question! To explain, I'm a scientist considering switching from C++ to D, but before I do, I need to ensure that I can: - achieve execution speeds comparable to C++ (for the same accuracy; I can

Re: How to fake a const method ?

2018-03-09 Thread Basile B. via Digitalmars-d-learn
On Friday, 9 March 2018 at 13:47:34 UTC, Basile B. wrote: - `type()` really has to be const because it's used in an opEquals that's used by an AA (key is const so opEquals has to as well) And the most annoying is that the non reduced Foo has a custom toHash that hashes a payload so the cast

[vibe.d/dub] Linker error

2018-03-09 Thread Chris via Digitalmars-d-learn
I got this error msg today (see below): DUB version 1.8.0, built on Mar 3 2018 vibe.d version 0.8.3 dmd 2.078.3 (the same with 2.079.0 and 2.077.0) .dub/build/server64_72_debug-debug-linux.posix-x86_64-dmd_2079-CAC4A12AC8FE4B4625A9511E4EFEB8F6/anscealai.o: In function

How to fake a const method ?

2018-03-09 Thread Basile B. via Digitalmars-d-learn
I would need this to work: ``` struct Foo { TypeInfo typeCache; TypeInfo getTypeCache() { alias NotThePoint = ubyte; if (typeCache is null) typeCache = typeid(NotThePoint); return typeCache; } TypeInfo type() const { alias

complex arithmetic in D: multiple questions

2018-03-09 Thread J-S Caux via Digitalmars-d-learn
Please bear with me, this is a long question! To explain, I'm a scientist considering switching from C++ to D, but before I do, I need to ensure that I can: - achieve execution speeds comparable to C++ (for the same accuracy; I can accept a slight slowdown, call it 30%, to get a few more

Re: does the shared keyword work with mutable structs?

2018-03-09 Thread Kagamin via Digitalmars-d-learn
To make a struct noncopyable, add @disable this(this); to it, then compiler will give an error on an attempt to copy it.

Re: does the shared keyword work with mutable structs?

2018-03-09 Thread Kagamin via Digitalmars-d-learn
spawn doesn't infer `ref` storage class and copies eventBuffer by value.