Strong typing and physical units

2020-07-27 Thread Cecil Ward via Digitalmars-d-learn
I found an earlier post somewhere about work someone has done on physical units such as kg, volts and so forth. It would be very good to catch bugs such as volts_t v = input_current; But that isn’t nearly enough. With strong typing where we can create arbitrary subtypes that are chosen

Re: Templates and SIMD - examining types

2020-07-27 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 22 July 2020 at 22:21:47 UTC, Dennis wrote: On Wednesday, 22 July 2020 at 21:58:16 UTC, Cecil Ward wrote: I need to then work out what is the size of the internal units within the 128-bit value, size in bytes,1 or 2, at compile time. You can use the .sizeof property on the

Re: Help with Ranges

2020-07-27 Thread Charles via Digitalmars-d-learn
On Monday, 27 July 2020 at 18:15:26 UTC, Steven Schveighoffer wrote: On 7/27/20 1:10 PM, Charles wrote: [...] Let's talk about a concrete example, so you can see why: int[] arr = [21, 83, 45, 60]; [...] I had very incorrect model of how ranges function, and after reading your post along

Re: Help with Ranges

2020-07-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/27/20 1:10 PM, Charles wrote: Still, I'm confused since, as far as I know, map wraps its source, i.e. the array in this case, which is sortable. It seems to me the only reason I can't sort MapResult is because it doesn't have the proper interface. Let's talk about a concrete example,

Re: Help with Ranges

2020-07-27 Thread Charles via Digitalmars-d-learn
On Monday, 27 July 2020 at 16:52:51 UTC, H. S. Teoh wrote: On Sun, Jul 26, 2020 at 07:10:41AM +, Charles via Digitalmars-d-learn wrote: Suppose I have the following line of code where arr is an array, doSomething is some predicate that does a lot of processing on each element, sort must

Re: Help with Ranges

2020-07-27 Thread Charles via Digitalmars-d-learn
On Sunday, 26 July 2020 at 14:56:35 UTC, Steven Schveighoffer wrote: A map that returns an lvalue would be sortable, but you would be sorting the processed elements, and probably not the original elements. Indeed, but that's what I want: sort the process elements. Otherwise, I'd place sort

Re: Contributing to D wiki

2020-07-27 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jul 27, 2020 at 11:39:32AM +, John Burton via Digitalmars-d-learn wrote: [...] > I tried looking there for information and examples of getting glfw3 > statically linked into my program using LDC and didn't really find > anything. > > I wonder if adding a page for static linking tips

Re: Help with Ranges

2020-07-27 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jul 26, 2020 at 07:10:41AM +, Charles via Digitalmars-d-learn wrote: > Suppose I have the following line of code where arr is an array, > doSomething is some predicate that does a lot of processing on each > element, sort must come after the mapping, and there are more > operations

Re: Contributing to D wiki

2020-07-27 Thread aberba via Digitalmars-d-learn
On Monday, 27 July 2020 at 11:39:32 UTC, John Burton wrote: On Wednesday, 15 July 2020 at 22:18:47 UTC, H. S. Teoh wrote: On Wed, Jul 15, 2020 at 09:27:22PM +, tastyminerals via Digitalmars-d-learn wrote: [...] [...] Why not? It's a *wiki*. Wikis are intended for the user community

Re: Why are std.bitmanip.bitfields so big ?

2020-07-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/27/20 5:49 AM, wjoe wrote: struct A {     mixin(bitfields!(    bool, "flag1",    1,    bool, "flag2",    1,    uint, "", 6)); } Is this inside a function? If so, put `static` on it. What you are seeing is the 8-byte frame pointer that comes from inner structs so

Re: Using D within a rust codebase

2020-07-27 Thread Ali Çehreli via Digitalmars-d-learn
On 7/27/20 4:43 AM, Ali Çehreli wrote: On 7/27/20 3:50 AM, Jacob Carlborg wrote:> On 2020-07-27 03:03, Paul > The D runtime needs to be initialized first [1]. Then it should be > terminated as well [2]. > > [1] https://dlang.org/phobos/core_runtime.html#.rt_init [...] pragma

Re: Using D within a rust codebase

2020-07-27 Thread Ali Çehreli via Digitalmars-d-learn
On 7/27/20 3:50 AM, Jacob Carlborg wrote:> On 2020-07-27 03:03, Paul Backus wrote: > >> extern(C) void hello() >> { >> import std.stdio: writeln; >> writeln("Hello from D!"); >> } > > The D runtime needs to be initialized first [1]. Then it should be > terminated as well [2]. > > [1]

Re: Contributing to D wiki

2020-07-27 Thread John Burton via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 22:18:47 UTC, H. S. Teoh wrote: On Wed, Jul 15, 2020 at 09:27:22PM +, tastyminerals via Digitalmars-d-learn wrote: [...] D wiki is badly outdated. This is not a fact but a gut feeling after reading through some of its pages. I was wondering who's owning it

Re: Using D within a rust codebase

2020-07-27 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-07-27 03:03, Paul Backus wrote: extern(C) void hello() { import std.stdio: writeln; writeln("Hello from D!"); } The D runtime needs to be initialized first [1]. Then it should be terminated as well [2]. [1] https://dlang.org/phobos/core_runtime.html#.rt_init [2]

Re: Static link of glfw3 library fails for me

2020-07-27 Thread John Burton via Digitalmars-d-learn
On Monday, 27 July 2020 at 08:53:25 UTC, Mike Parker wrote: On Monday, 27 July 2020 at 07:30:42 UTC, John Burton wrote: For reference I got this to work by doing the following :- 1) Installed visual studio build tools. I could not get this to work at all with the linker etc that comes with

Why are std.bitmanip.bitfields so big ?

2020-07-27 Thread wjoe via Digitalmars-d-learn
From the API documentation: Create a bitfield pack of eight bits, which fit in one ubyte. [...] struct A { mixin(bitfields!( bool, "flag1",1, bool, "flag2",1, uint, "", 6)); } A a; writeln(a.flag1); // 0 a.flag1 = 1; writeln(a.flag1); // 1 a.flag1 = 0;

Re: Good way to send/receive UDP packets?

2020-07-27 Thread wjoe via Digitalmars-d-learn
On Thursday, 23 July 2020 at 13:29:47 UTC, Kagamin wrote: On Wednesday, 22 July 2020 at 16:14:24 UTC, wjoe wrote: If you send a UDP datagram to a single address, however, it will still be delivered to every program on that PC which receives UDP datagrams from that port. Normally binding two

Re: Static link of glfw3 library fails for me

2020-07-27 Thread Mike Parker via Digitalmars-d-learn
On Monday, 27 July 2020 at 07:30:42 UTC, John Burton wrote: For reference I got this to work by doing the following :- 1) Installed visual studio build tools. I could not get this to work at all with the linker etc that comes with ldc2. 2) Copied the glfw3.lib vs2019 version file into my

Re: Static link of glfw3 library fails for me

2020-07-27 Thread John Burton via Digitalmars-d-learn
On Sunday, 26 July 2020 at 12:24:06 UTC, John Burton wrote: On Sunday, 26 July 2020 at 10:41:27 UTC, Mike Parker wrote: On Sunday, 26 July 2020 at 08:28:29 UTC, John Burton wrote: And I get the following errors from the link :- lld-link: error: undefined symbol: __GSHandlerCheck lld-link: