Re: Classes and Structs, Memory management questions

2016-09-02 Thread ikod via Digitalmars-d-learn
On Friday, 2 September 2016 at 08:43:45 UTC, dom wrote: Since garbage collection is a very nice feature that I wouldn't wanna miss for certain scenarios I think D should give us the opportunity to determine how an object is allocated. In the example above putting it on the stack is probably

Re: Using OpenGL

2016-09-02 Thread Mike Parker via Digitalmars-d-learn
On Friday, 2 September 2016 at 20:38:15 UTC, Darren wrote: I'm trying to teach myself OpenGL but I'm not sure how to set it up exactly. I used "dub init" to create a project, I downloaded glew32.dll and glfw.dll and put them in this folder. I added "derelict-gl3": "~>1.0.19" and

Using OpenGL

2016-09-02 Thread Darren via Digitalmars-d-learn
I'm trying to teach myself OpenGL but I'm not sure how to set it up exactly. I used "dub init" to create a project, I downloaded glew32.dll and glfw.dll and put them in this folder. I added "derelict-gl3": "~>1.0.19" and "derelict-glfw3": "~>3.1.0" to dependencies, and imported them in the

Re: Hash table element existence check

2016-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/16 3:38 PM, Illuminati wrote: I am trying to create a hash table and would like an efficient way to be able to know if an element exists to test for collisions. You mean you are writing your own hash table, or you want to use a D hash table (associative array)? I could keep a

Hash table element existence check

2016-09-02 Thread Illuminati via Digitalmars-d-learn
I am trying to create a hash table and would like an efficient way to be able to know if an element exists to test for collisions. I could keep a bitarray, but wasting around 12% space. I could use pointers(null check) to elements but this creates fragmentation. It is not terrible, just

Re: opAssign return type

2016-09-02 Thread Q. Schroll via Digitalmars-d-learn
On Friday, 2 September 2016 at 17:33:22 UTC, Steven Schveighoffer wrote: On 9/2/16 1:18 PM, Q. Schroll wrote: When overloading assignment, I've been taught in my C++ course to return a reference to the lvalue being assigned to. This is easily possible in D, but in Phobos it is used rarely and

Re: opAssign return type

2016-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/16 1:18 PM, Q. Schroll wrote: When overloading assignment, I've been taught in my C++ course to return a reference to the lvalue being assigned to. This is easily possible in D, but in Phobos it is used rarely and in Ali Çehreli's Book it is neither taught to do so. Sure, you can do

opAssign return type

2016-09-02 Thread Q. Schroll via Digitalmars-d-learn
When overloading assignment, I've been taught in my C++ course to return a reference to the lvalue being assigned to. This is easily possible in D, but in Phobos it is used rarely and in Ali Çehreli's Book it is neither taught to do so. Is there any reason to it? To me it seems very obvious

Re: Classes and Structs, Memory management questions

2016-09-02 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 2 September 2016 at 08:43:45 UTC, dom wrote: from what i got Classes are always reference types and structs are value types in D. i am wondering why that is. for me the main difference between classes and structs is not how they are allocated, but that one has inhertiance, and the

Re: Equivalent of FirstOrDefault with ranges

2016-09-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 2 September 2016 at 06:56:07 UTC, Lutger wrote: I was looking for something like FirstOrDefault* from .NET in phobos. For example, I have this piece of code: string findBobOrReturnNull(string[] names) { auto r = names.find("bob"); if(r.empty) return null; return r.front;

Re: Classes and Structs, Memory management questions

2016-09-02 Thread Mike Parker via Digitalmars-d-learn
On Friday, 2 September 2016 at 08:43:45 UTC, dom wrote: from what i got Classes are always reference types and structs are value types in D. i am wondering why that is. for me the main difference between classes and structs is not how they are allocated, but that one has inhertiance, and the

Re: Classes and Structs, Memory management questions

2016-09-02 Thread dom via Digitalmars-d-learn
On Friday, 2 September 2016 at 08:59:38 UTC, Andrea Fontana wrote: On Friday, 2 September 2016 at 08:54:33 UTC, dom wrote: i haven't read it fully yet, but i think this DIP contains some or all of my concerns https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md Check this:

Re: Classes and Structs, Memory management questions

2016-09-02 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 2 September 2016 at 08:54:33 UTC, dom wrote: i haven't read it fully yet, but i think this DIP contains some or all of my concerns https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md Check this: https://dlang.org/phobos/std_experimental_allocator.html

Re: Classes and Structs, Memory management questions

2016-09-02 Thread dom via Digitalmars-d-learn
i haven't read it fully yet, but i think this DIP contains some or all of my concerns https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md

Re: Equivalent of FirstOrDefault with ranges

2016-09-02 Thread Cauterite via Digitalmars-d-learn
On Friday, 2 September 2016 at 06:56:07 UTC, Lutger wrote: You could do: names.find("bob").chain(only(``)).front; It's not very expressive though.

Classes and Structs, Memory management questions

2016-09-02 Thread dom via Digitalmars-d-learn
from what i got Classes are always reference types and structs are value types in D. i am wondering why that is. for me the main difference between classes and structs is not how they are allocated, but that one has inhertiance, and the other hasn't. Supporting inheritance has some overhead,

Re: DUB, link automatically right object for platform and archi

2016-09-02 Thread Basile B. via Digitalmars-d-learn
On Friday, 2 September 2016 at 03:24:58 UTC, rikki cattermole wrote: On 02/09/2016 6:01 AM, Basile B. wrote: [...] What's wrong in my description ? For starters Ouch... buildSettings is just a name given to a group of properties. It doesn't actually go INTO the dub file. Thx much, this

Equivalent of FirstOrDefault with ranges

2016-09-02 Thread Lutger via Digitalmars-d-learn
I was looking for something like FirstOrDefault* from .NET in phobos. For example, I have this piece of code: string findBobOrReturnNull(string[] names) { auto r = names.find("bob"); if(r.empty) return null; return r.front; } assert(findBobOrReturnNull(["alice", "bob"]) == "bob");

Re: Different array rotation algorithms benchmark

2016-09-02 Thread Miguel L via Digitalmars-d-learn
On Thursday, 1 September 2016 at 13:16:19 UTC, Johan Engelen wrote: On Thursday, 1 September 2016 at 10:37:18 UTC, Miguel L wrote: Also, forgot to specify I am using LDC with -05. And the version of LDC too please ;-) LDC version is: ldc2-1.1.0-beta2-win64-msvc