Simplest way to convert an array into a set

2023-02-13 Thread Matt via Digitalmars-d-learn
Obviously, there is no "set" object in D, but I was wondering what the quickest way to remove duplicates from an array would be. I was convinced I'd seen a "unique" method somewhere, but I've looked through the documentation for std.array, std.algorithm AND std.range, and I've either missed

A potential use-case for template mixins?

2023-02-06 Thread Matt via Digitalmars-d-learn
I am (still) writing a 3D graphics engine, and was considering my choices for a scene graph. Originally, I was going to use classes derived from my base SceneNode class for the nodes of the graph, but would this instead be a better situation to use template mixins instead of potentially

How to write a library

2023-01-21 Thread Matt via Digitalmars-d-learn
I am trying to write a graphics engine for my university capstone project, and really wanted to give it a try in D, as both a talking point, and because I love the language. I'm using dub to build the library, and the demo application that'll use it. However, I've come across a problem. In

Re: Why does choose not work here

2019-08-01 Thread Matt via Digitalmars-d-learn
On Thursday, 1 August 2019 at 21:12:51 UTC, ag0aep6g wrote: `choose`'s parameters aren't lazy. So the second argument is evaluated even when `previous is null`. That means `intervalRange` is called on a null `previous`. And that fails, of course, because `intervalRange` can't access `starts`

Why does choose not work here

2019-08-01 Thread Matt via Digitalmars-d-learn
I'm having some trouble with a "Program exited with code -1073741819" error in some code I'm writing and I would appreciate any help/insight. The problem stems from some incompatibility between the Phobos function "choose" and the template function "myFilter" which returns a range. The code

Re: Why in Phobos is empty() sometimes const and sometimes not

2019-07-30 Thread Matt via Digitalmars-d-learn
On Tuesday, 30 July 2019 at 05:30:30 UTC, Jonathan M Davis wrote: In principle, it's good to use const when you know that data isn't going to change, but that gets far more complicated when you're dealing with generic code or even with classes, since as soon as you use const, everything used

Re: Why in Phobos is empty() sometimes const and sometimes not

2019-07-29 Thread Matt via Digitalmars-d-learn
On Monday, 29 July 2019 at 19:38:34 UTC, Jonathan M Davis wrote: On Monday, July 29, 2019 11:32:58 AM MDT Matt via Digitalmars-d-learn wrote: Because const ranges are basically useless, there really isn't much point in putting const on any range functions even if it would work

Why in Phobos is empty() sometimes const and sometimes not

2019-07-29 Thread Matt via Digitalmars-d-learn
I've noticed that for some ranges in Phobos empty is marked const (e.g. iota) but for other ranges (e.g. multiwayMerge) it is not const. Is there a reason why? Isn't empty guaranteed not to alter the data of the range and so should be const? This is causing me considerable headaches as I try

Re: D generates large assembly for simple function

2018-01-27 Thread Matt via Digitalmars-d-learn
Godbolt link: https://godbolt.org/g/t5S976

D generates large assembly for simple function

2018-01-27 Thread Matt via Digitalmars-d-learn
Playing around with Godbolt, D seems to generate an embarassing amount of assembly for a simple function (50ish for squaring an int vs 4 for C++ and 7 for Rust). Even Go compiles to less assembly. Is there something I'm missing?

Re: A potential danger to dub

2017-09-22 Thread Matt via Digitalmars-d
On Saturday, 16 September 2017 at 17:09:34 UTC, David Gileadi wrote: Let me preface this by saying I love package managers and think dub is one of the best things with dlang. However they can also sometimes be dangerous, as this PyPI incident[1] shows: several Python packages were uploaded

Re: Netflix opensources its first D library: Vectorflow

2017-08-03 Thread Matt via Digitalmars-d-announce
Meanwhile, the blog post Laeeth gave you shows Mir doing better on matrix multiplication benchmarks than Eigen, significantly better when dealing with complex numbers. I mean by now we should all be jaded enough not to simply take toy benchmarks as gospel for which is actually fastest in a

Re: Netflix opensources its first D library: Vectorflow

2017-08-02 Thread Matt via Digitalmars-d-announce
Also note, one of the main advantages of Eigen is the whole lazy evaluation of expressions for compound operations. I haven't dug in the source, but it's my understanding it's done through a lot of compile time C++ template hacking

Re: Netflix opensources its first D library: Vectorflow

2017-08-02 Thread Matt via Digitalmars-d-announce
That seems like a good start. I'll probably start contributing within a few weeks. In the long run the goal should probably be to have a "go-to" set of LA libraries, with appropriate data structures that have friendly bindings to GPU LA computations with DCompute.

Re: Netflix opensources its first D library: Vectorflow

2017-08-02 Thread Matt via Digitalmars-d-announce
On Wednesday, 2 August 2017 at 21:31:19 UTC, Walter Bright wrote: https://www.reddit.com/r/programming/comments/6r6dwp/netflix_opensources_its_first_d_library_vectorflow/ Speakng of D in data science (where I think it can get traction), is there a standardized linear algebra library in D?

Re: Toward Go 2 (or D needs to collect experience reports)

2017-07-14 Thread Matt via Digitalmars-d
The one thing I got from that blog post is that the HN and reddit discussion was overwhelmingly about generics, and how the Go leadership seems to not give a damn about what its user community wants...

Re: Win10 defender still sees dmd.exe and rdmd.exe as malicious

2017-06-30 Thread Matt via Digitalmars-d
On Wednesday, 28 June 2017 at 14:21:24 UTC, Mike Parker wrote: On Monday, 26 June 2017 at 02:55:17 UTC, Matt wrote: Which version of the compiler? Which version of Windows? I'm on Windows 10 with 2.074.1 currently and never seen it with any version of DMD. DMD is 2.074.1, windows10 pro

Re: Win10 defender still sees dmd.exe and rdmd.exe as malicious

2017-06-29 Thread Matt via Digitalmars-d
On Wednesday, 28 June 2017 at 14:21:24 UTC, Mike Parker wrote: On Monday, 26 June 2017 at 02:55:17 UTC, Matt wrote: Which version of the compiler? Which version of Windows? I'm on Windows 10 with 2.074.1 currently and never seen it with any version of DMD. DMD is 2.074.1, windows10 pro

Re: Win10 defender still sees dmd.exe and rdmd.exe as malicious

2017-06-25 Thread Matt via Digitalmars-d
Which version of the compiler? Which version of Windows? I'm on Windows 10 with 2.074.1 currently and never seen it with any version of DMD. DMD is 2.074.1, windows10 pro (10.0.14393)

Win10 defender still sees dmd.exe and rdmd.exe as malicious

2017-06-25 Thread Matt via Digitalmars-d
Hey guys, New user here. I know the first 5 minutes experience is important, just to note that rdmd.exe and executables created with dmd.exe are flagged as malicious by windows defender. It's easy to create an exception in the windows defender settings, but I thought I would let you know.

Randomisation of array order

2015-08-02 Thread Matt via Digitalmars-d-learn
I was planning to use a dynamic array of indices to represent a deck of cards, and was wondering if there was any easy way to shuffle the arrays contents? I checked the library docs, but came to the conclusion that sorting arrays is a much more common operation :) If anyone has a suggestion

Re: Randomisation of array order

2015-08-02 Thread Matt via Digitalmars-d-learn
...And then I realised that I hadn't looked inside std.random. Question solved, because I am a dumbass.

Re: Dconf Video / Projector Information

2015-05-18 Thread Matt via Digitalmars-d
On Tuesday, 19 May 2015 at 04:58:20 UTC, Matt wrote: On Monday, 18 May 2015 at 23:19:33 UTC, Andrei Alexandrescu wrote: On 5/18/15 10:59 AM, Brian Schott wrote: I'm considering adding a demo or two to my talk. Does anybody know what kind of video setup we will have? More specifically: * Is

Re: Dconf Video / Projector Information

2015-05-18 Thread Matt via Digitalmars-d
On Monday, 18 May 2015 at 23:19:33 UTC, Andrei Alexandrescu wrote: On 5/18/15 10:59 AM, Brian Schott wrote: I'm considering adding a demo or two to my talk. Does anybody know what kind of video setup we will have? More specifically: * Is the conference being streamed? If so, will there be a

Removing structs from assoc array while iterating over it

2015-03-16 Thread Matt via Digitalmars-d-learn
I am creating a simple SDL_Texture manager, and was wondering if the following code would work: --- // 'list' is am assoc array of a struct containing a pointer and ref counter. // max_list_length is set to 20 if it's ever found to be 0 // compact list if(list.length == max_list_length){

Re: embedding Pyd in Windows program

2015-03-14 Thread Matt via Digitalmars-d-learn
On Saturday, 14 March 2015 at 00:28:59 UTC, Ellery Newcomer wrote: On Friday, 13 March 2015 at 19:05:59 UTC, Matt wrote: example code, see if I can figure it out, but if you can advise, that would be fantastic. Thank you for all the help so far, it's really been appreciated My penitence for

Re: embedding Pyd in Windows program

2015-03-13 Thread Matt via Digitalmars-d-learn
On Friday, 13 March 2015 at 16:30:07 UTC, Matt wrote: Thank you, adding the subConfigurations section to dub.json seems to allow the program to compile and run successfully. However, to test the code, I first tried in the main program: --- py_eval!string(import sys\nprint(sys.path)); ---

Re: OutputDebugString()

2015-03-13 Thread Matt via Digitalmars-d-learn
On Friday, 13 March 2015 at 21:12:52 UTC, Robert M. Münch wrote: Hi, I want to use the Windows OutputDebugString() which is not defined anywhere. How do I declare such missing Windows API functions myself? And with which libaries do I then need to link? Does DMD contain all necessary Windows

Re: embedding Pyd in Windows program

2015-03-13 Thread Matt via Digitalmars-d-learn
On Friday, 13 March 2015 at 01:40:34 UTC, Ellery Newcomer wrote: On 03/11/2015 07:59 PM, Matt wrote: Right, copying site.py into my program's working dir sorts out the missing module error, but I now get a syntax error: file=sys.stderr) ^ SyntaxError: invalid syntax Error

Re: embedding Pyd in Windows program

2015-03-13 Thread Matt via Digitalmars-d-learn
On Friday, 13 March 2015 at 14:21:15 UTC, Ellery Newcomer wrote: On Friday, 13 March 2015 at 09:38:45 UTC, Matt wrote: I used the ~0.9.4 branch in dub, and I'm not sure how to change configuration. Do you mean I should be using ~master or ~develop? nope. configurations are a different

Re: embedding Pyd in Windows program

2015-03-11 Thread Matt via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 19:32:05 UTC, Matt wrote: I'm trying to build a simple platformer using SDL2 and python to script entities, but I'm struggling to include Pyd. I'm using DMD v2.066.1, with dub as the package manager, and derelict for the SDL2 bindings. Now, when I add Pyd to my

embedding Pyd in Windows program

2015-03-11 Thread Matt via Digitalmars-d-learn
I'm trying to build a simple platformer using SDL2 and python to script entities, but I'm struggling to include Pyd. I'm using DMD v2.066.1, with dub as the package manager, and derelict for the SDL2 bindings. Now, when I add Pyd to my dub.json everything works fine, but as soon as I add

Re: embedding Pyd in Windows program

2015-03-11 Thread Matt via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 21:45:20 UTC, Matt wrote: On Wednesday, 11 March 2015 at 19:32:05 UTC, Matt wrote: I'm trying to build a simple platformer using SDL2 and python to script entities, but I'm struggling to include Pyd. I'm using DMD v2.066.1, with dub as the package manager, and

Re: Example usage of the core.sync classes

2015-01-03 Thread Matt via Digitalmars-d-learn
On Friday, 2 January 2015 at 18:52:11 UTC, Benjamin Thaut wrote: Am 02.01.2015 um 19:45 schrieb Vlad Levenfeld: My personal favorite method is to use the primitives in core.atomic with a double or triple buffer. To double buffer, keep two buffers in an array (data[][] or something) and an

Re: Example usage of the core.sync classes

2015-01-03 Thread Matt via Digitalmars-d-learn
On Saturday, 3 January 2015 at 22:10:49 UTC, Vlad Levenfeld wrote: On Saturday, 3 January 2015 at 15:44:16 UTC, Matt wrote: Right, I've been looking at core.atomic, but it has very little documentation, and it's territory I haven't explored, yet. Any chance of some pointers along the way?

Example usage of the core.sync classes

2015-01-02 Thread Matt via Digitalmars-d-learn
I'm trying to write a small 3D engine, and wanted to place the physics in a separate thread to the graphics, using events, possibly std.concurrency, to communicate between them. How, then, do I pass large amounts of data between threads? I'm thinking the physics world state (matrix for each

Exception thrown while trying to read file

2014-10-03 Thread Matt via Digitalmars-d-learn
I am building a PE-COFF file reader, just for education purposes, and I keep getting a ConvException come up, stating: --- Unexpected ' --- Now, I have no idea how I'm getting this. The code at that point looks like the following: --- // look for the identifier // this gives us the

Re: Exception thrown while trying to read file

2014-10-03 Thread Matt via Digitalmars-d-learn
On Friday, 3 October 2014 at 13:48:41 UTC, thedeemon wrote: On Friday, 3 October 2014 at 11:30:02 UTC, Matt wrote: I am building a PE-COFF file reader file.seek(0x3c, SEEK_SET); file.readf(%d, offs); // this is the problem line Does anyone else see whatever it is that I'm doing wrong? readf

Loading Symbols from Loaded Libraries

2014-09-01 Thread Matt via Digitalmars-d-learn
If I were to use Runtime.loadLibrary(), it claims to merge any D GC in the shared lib with the current process' GC. Do I need to version away symbol loading code for each platform? Or is there already code in Phobos that allows us to do this independent of platform?

mismatched function return type inference of string and double

2014-08-03 Thread matt via Digitalmars-d-learn
So I just started learning D this weekend, and I'm trying to understand why the following example will not work... Essentially what I am trying to do is cast the templated child stored in the parent container as the correct form, return some T value, and use auto to return the correct value

What is the status of DLL programming in D 2.065?

2014-07-26 Thread Matt via Digitalmars-d
Are we able to create DLLs easily enough in D now? Do we still need to tell our D DLLs to share their GCs with the calling EXE? And is the wiki page fully up to date on the matter? If not where can we find the up to date information? Or should we be using core.runtime.Runtime.loadLibrary()?

Re: Source File and Position of User Defined Type

2014-06-11 Thread Matt via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 20:58:41 UTC, Nordlöw wrote: Is there a way to, programatically (trait), lookup the source file and position of a user defined type either dynamically or, even better, statically? I don't know about the source file, per se, but std.traits has the

Getting an access violation before main starts

2014-06-10 Thread Matt via Digitalmars-d
I was wondering if anyone could help with a problem I'm having. My program compiles properly, and has all up-to-date files and DLLs (SDL2, SDL2-image, SDL2-ttf, all the other DLLs that are required by these). However, when I run it, I get object.Error: Access Violation, which, of course,

Re: Getting an access violation before main starts

2014-06-10 Thread Matt via Digitalmars-d
On Wednesday, 11 June 2014 at 00:05:25 UTC, safety0ff wrote: On Wednesday, 11 June 2014 at 00:00:47 UTC, Matt wrote: Both Window and Input are my own classes, which I've checked for leaks, and don't appear to have any. They are basically wrappers around SDL functionality. I can include the

Re: Getting an access violation before main starts

2014-06-10 Thread Matt via Digitalmars-d
On Wednesday, 11 June 2014 at 01:52:49 UTC, Kapps wrote: The digitalmars.D.learn newsgroup is a more appropriate place for this, but as for your issue, one thing to keep in mind is that static constructors are run before main: import std.stdio; static this() { writeln(Foo); } void

Re: Basic dynamic array question. Use of new versus no new.

2014-06-10 Thread Matt via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 02:30:01 UTC, WhatMeWorry wrote: In Mr. Cehreli's book it says Additionally, the length of dynamic arrays can be changed by assigning a value to this property: int[] array; // initially empty array.length = 5; // now has 5 elements while in Mr. Alexandrescu's

Re: problem with Access Violation, and I'm not sure where

2014-06-10 Thread Matt via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 02:59:40 UTC, Matt wrote: I previously asked this over in the DigitalMars.D board(http://forum.dlang.org/thread/huftyrtbomaimuqkm...@forum.dlang.org#post-hrqvqlzzbkgafvjdtjnb:40forum.dlang.org), but it was suggested I ask it over here instead. I have the

Re: storing pointers in Variants

2014-04-27 Thread Matt via Digitalmars-d-learn
On Sunday, 27 April 2014 at 00:48:53 UTC, Ali Çehreli wrote: I think the following is a start: import std.variant; class MyClass { Variant[string] store; void attach(T)(string key, ref T var) { store[key] = var; } void set(T)(string key, T value) {

storing pointers in Variants

2014-04-26 Thread Matt via Digitalmars-d-learn
I am trying to create a class that can do the following: --- int sample = 42; // myObj is an instance of the class I'm writing myObj.attach (othername, sample); myObj.set (othername, 69); writeln (myObj.get (othername), \t, sample); // should produce '69 69' --- Currently, my class