Re: Pointer to template types?

2014-04-28 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 28 April 2014 at 10:40:49 UTC, Chris wrote: So there is no way of filling an array with something like Person!(string) *pptr; foreach(person; people) { buf ~= person; } Person!(string)*[] arr; Like this?

Re: Is it possible to check if a type is an instance of a template?

2014-05-05 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 5 May 2014 at 23:28:58 UTC, Nordlöw wrote: template IsAFoo(T) { static if (is(T t == Foo!U, U)) { enum IsAFoo = true; } else { enum IsAFoo = false; } } Can we make Foo a template parameters aswell, here? I tried this template IsA(T, K) { static if (is(T

Re: Implicit static-dynamic arr and modifying

2014-05-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 6 May 2014 at 02:17:06 UTC, Nick Sabalausky wrote: So all is well, and deliberately so. Pardon the noise. IMO it's not. I once had a particularly nasty bug because of this: struct S { @safe: string str; this(string data) {

Re: Any chance to avoid monitor field in my class?

2014-05-07 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 7 May 2014 at 14:44:57 UTC, Yuriy wrote: Hello, is there a way of reducing size of an empty class to just vtbl? I tried to declare it as extern(C++) which works, but has a nasty side effect of limited mangling. May I ask what your use case is? Perhaps there's another solution

Re: sort struct of arrays

2014-05-09 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 9 May 2014 at 15:52:51 UTC, John Colvin wrote: On Friday, 9 May 2014 at 14:23:41 UTC, Luís Marques wrote: If you have an array of structs, such as... struct Foo { int x; int y; } Foo[] foos; ...and you wanted to sort the foos then you'd do something

Re: DerelictAL with alut?

2014-05-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 23 May 2014 at 08:17:28 UTC, Jack wrote: Erm excuse me. Does the current DerelictAL come with alut bindings? If not, does it come with libaudio then? I saw this very old page on the internet about DerelictAL having some alut bindings:

Re: DerelictAL with alut?

2014-05-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 23 May 2014 at 09:01:24 UTC, Jack wrote: On Friday, 23 May 2014 at 08:36:29 UTC, Rene Zwanenburg wrote: On Friday, 23 May 2014 at 08:17:28 UTC, Jack wrote: Erm excuse me. Does the current DerelictAL come with alut bindings? If not, does it come with libaudio then? I saw this very

Re: DerelictAL with alut?

2014-05-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 23 May 2014 at 09:30:17 UTC, Mike Parker wrote: On 5/23/2014 6:11 PM, Rene Zwanenburg wrote: http://kcat.strangesoft.net/alure-docs/files/alure-cpp.html Hrm. I looked all over the ALURE homepage for a link to online docs. Thanks for posting it. Yeah it's a bit hidden. You can

Re: Issue with contracts and assertions

2014-05-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 23 May 2014 at 13:45:07 UTC, Andre wrote: Hi, for the attached code I noticed some strange behaviors. I compile the programm with: dmd main -unittest The expected assertion of the method c pre condition is not raised. It is only raised if class A not implements interface I. On the

Re: Issue with contracts and assertions

2014-05-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 23 May 2014 at 14:38:27 UTC, Andre wrote: Am 23.05.2014 16:34, schrieb Rene Zwanenburg: In case there is a reason that the assertion is not run, if feels very dangerous for me that all assertions can be disabled by mistake just by adding an interface to a class. At least a compiler

Re: derelict glfw won't set callbacks

2014-05-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Saturday, 24 May 2014 at 13:31:46 UTC, Vlad Levenfeld wrote: Any attempt to set callbacks in GLFW returns a null and the callback doesn't work. The first enforcement fails in this example: DerelictGLFW3.load (); enforce (glfwSetErrorCallback (error_callback)); enforce (glfwInit (),

Re: How to get array length

2014-05-25 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 25 May 2014 at 06:50:14 UTC, kaz wrote: On Thursday, 22 May 2014 at 23:26:02 UTC, Ali Çehreli wrote: On 05/22/2014 04:22 PM, kaz wrote: Is there a way to get the length of an array out of slice bracket in D? Tks. If you mean the length of the original array, no. Of course, the

Re: How to debug ?

2014-05-25 Thread Rene Zwanenburg via Digitalmars-d-learn
On Saturday, 24 May 2014 at 15:48:11 UTC, Derix wrote: To debug you nee to use -g flag to compiler Thanks, but how ? I don't use Eclipse, but for debugging you usually have to do two things. As mentioned before you need to have debug information in the executable. Dub will generate debug

Is there any way to differentiate between a type and an alias?

2014-05-25 Thread Rene Zwanenburg via Digitalmars-d-learn
Given alias GLenum = uint; void glSomeFunction(GLenum, uint); Now, is there some way to differentiate between GLenum and uint when using ParameterTypeTuple!glSomeFunction? I'm writing a function which shows the arguments a GL function was called with when an error occurs. The GLenum needs

Re: Is there any way to differentiate between a type and an alias?

2014-05-25 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 25 May 2014 at 14:40:06 UTC, Steven Schveighoffer wrote: On Sun, 25 May 2014 04:04:09 -0700, Rene Zwanenburg renezwanenb...@gmail.com wrote: Given alias GLenum = uint; void glSomeFunction(GLenum, uint); Now, is there some way to differentiate between GLenum and uint when using

Re: installing Mango with DMD instead of ldc

2014-05-26 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 26 May 2014 at 10:48:09 UTC, JJDuck wrote: On Monday, 26 May 2014 at 09:08:53 UTC, John Colvin wrote: What are your requirements? There may be an alternative library you could use. I did some research , D2 + phobos + tango + mango + encryption can give me what I want. Vibe.d

Re: overloading operations for enums

2014-05-26 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 26 May 2014 at 16:54:02 UTC, Dominikus Dittes Scherkl wrote: Hello. I want to create some finite algebra, where the elements are enumerated but operations on them are defined (with composition tables). e.g.: enum color = { white, yellow, red, blue, orange, violet, green, black

Re: Is there any way to differentiate between a type and an alias?

2014-06-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 27 May 2014 at 18:05:24 UTC, Steven Schveighoffer wrote: I get it. I don't necessarily agree with that, but it's not my library :) I think it would be difficult to achieve without changing the actual function definition. Perhaps you could wrap the functions with your own, and use

Re: Delegate, scope and associative array

2014-06-02 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 2 June 2014 at 20:09:12 UTC, Edwin van Leeuwen wrote: I'm probably missing something basic, but I am confused by what is going on in the following code. unittest { size_t delegate()[size_t] events; foreach( i; 1..4 ) { events[i] = { return i; }; } writeln(

Re: When is a slice not a slice?

2014-06-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 6 June 2014 at 08:17:43 UTC, Alix Pexton wrote: On 05/06/2014 8:58 PM, Steven Schveighoffer wrote: On Thu, 05 Jun 2014 15:56:00 -0400, Philippe Sigaud via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: enum b = DataAndView(1); assert (!sameTail(b.data,

Re: Weird behaviour when using -release in dmd

2014-06-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 6 June 2014 at 10:10:25 UTC, Mikko Aarnos wrote: Hello all, I have a program which works perfectly when compiled without -release: parser a implies b equivalent not b implies not a Input: ((a implies b) equivalent ((not b) implies (not a))) CNF: (not a) or b) or (not b)) and

Re: Create const regex?

2014-06-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 6 June 2014 at 12:01:55 UTC, AntonSotov wrote: const r1 = regex(bla); matchFirst( big string, r1 ); // ERROR! immutable r2 = regex(bla); // ERROR! Why can I not use const/immutable regex? Not sure, but I suspect Regex has some internal state which is mutated during matching.

Re: Working on a library: request for code review

2014-06-12 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 12 June 2014 at 15:46:12 UTC, Mike wrote: On Thursday, 12 June 2014 at 00:20:28 UTC, cal wrote: Might it be worth stitching things together into a proper image processing package? Well I started working on TGA because I was disappointed that no image abstraction is present in

Re: Working on a library: request for code review

2014-06-12 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 18:29:27 UTC, Mike wrote: Here's the link to the repo: http://bit.ly/1mIuGhv I usually don't trust shortened URL's. Can you please post full URL's when not constrained by a character limit? Any feedback would be great! First of all, I like your coding style.

Re: one of the weirdest bugs ever - request for testing

2014-06-12 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 12 June 2014 at 22:14:23 UTC, captaindet wrote: On 2014-06-12 14:20, captaindet wrote: before i file it, i'd like to know if it is still around in the latest DMD version and/or if other platforms and 64bit code is affected as well. thanks andrew, philippe, i had the suspicion

Re: Working on a library: request for code review

2014-06-16 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 16 June 2014 at 19:42:14 UTC, Mike wrote: I have refactored the code as recommended. I have also modified the not-yet-reviewed writers part to take advantage of the same approach (preallocated static-sized buffer) rather than allocate slices in loops. Hoping to hear something

Re: Working on a library: request for code review

2014-06-16 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 16 June 2014 at 19:42:14 UTC, Mike wrote: I have refactored the code as recommended. I have also modified the not-yet-reviewed writers part to take advantage of the same approach (preallocated static-sized buffer) rather than allocate slices in loops. Hoping to hear something

Re: Working on a library: request for code review

2014-06-18 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 18 June 2014 at 13:42:32 UTC, Rene Zwanenburg wrote: On Wednesday, 18 June 2014 at 09:41:01 UTC, Marc Schütz wrote: On Tuesday, 17 June 2014 at 18:35:34 UTC, Mike wrote: Thanks, will work on fixes tonight. The current method will not detect an error when the image type is not

Re: Working on a library: request for code review

2014-06-18 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 16 June 2014 at 23:04:33 UTC, Rene Zwanenburg wrote: The writeCompressed function can probably be simplified using std.algorithm but it's not straightforward. I'll need to ponder it for a while. Here's a version using std.algorithm and std.range. I think it's easier to understand

Re: Working on a library: request for code review

2014-06-19 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 19 June 2014 at 12:06:58 UTC, Marc Schütz wrote: On Wednesday, 18 June 2014 at 14:05:12 UTC, Rene Zwanenburg wrote: On Tuesday, 17 June 2014 at 13:07:33 UTC, Marc Schütz wrote: On Monday, 16 June 2014 at 23:04:33 UTC, Rene Zwanenburg wrote: This one depends on taste, but these

Re: DUB linking problem on WinXp

2014-06-19 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 19 June 2014 at 15:12:10 UTC, Orfeo wrote: The problem was on ddb 0.2.1 ... if I remove it I can compile Did you try a full rebuild? dub --force sometimes helps, especially when you've upgraded your compiler.

Re: Working on a library: request for code review

2014-06-21 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 20 June 2014 at 11:15:20 UTC, Mike wrote: Do you think it's ready for a v0.1 release? It be willing to add it to dub if it passes general D coding stardards. Sure, go for it :). Dub package versioning should be done using SemVer so there are some restrictions on how to number a

Re: popcnt instruction

2014-06-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 17:05:24 UTC, Justin Whear wrote: On Tue, 24 Jun 2014 16:34:42 +, Archibald wrote: Hello, I need to use the popcnt processor instruction in a performance critical section. Is there a way to do this in D? D's inline assembler is described here:

Re: Assosiative array pop

2014-06-26 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 25 June 2014 at 14:17:50 UTC, Meta wrote: Then to pop the first element, just do 'arr = arr[1..$]'. Or import std.array to get the range primitives for slices: import std.array; void main() { auto arr = [1, 2, 3, 4]; arr.popFront(); assert(arr.front == 2); }

Re: close program by code

2014-06-26 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 26 June 2014 at 10:40:00 UTC, John Colvin wrote: On Thursday, 26 June 2014 at 09:58:50 UTC, FreeSlave wrote: On Thursday, 26 June 2014 at 09:05:23 UTC, pgtkda wrote: How can i close my application by code? Do you mean exit status? Just call exit function from C library.

Re: Conflict between function and template with the same name

2014-06-29 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 29 June 2014 at 07:16:10 UTC, Uranuz wrote: Is there any reason why function and template conflict. They using different syntax to *call*. For template we have *!* but for function we don't have it. So why compiler is not able to see the difference? I suspect this is by design.

Re: Conflict between function and template with the same name

2014-06-29 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 29 June 2014 at 08:52:36 UTC, Uranuz wrote: import std.stdio; string getByName(string name) { return smth; } template getByName(string name) { enum getByName = .getByName(name); } void main() { writeln(getByName!(name)); } Thanks a lot! Very interesting.

Re: Thread-safety and lazy-initialization of libraries

2014-06-30 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 30 June 2014 at 21:32:34 UTC, Sergey Protko wrote: On Monday, 30 June 2014 at 21:05:32 UTC, bearophile wrote: Sergey Protko: libmpg123 has mpg123_init and mpg123_exit functions, which are not thread-safe, so we should to call them only once per process. Most of useful libraries

Re: How to test templates for equality?

2014-07-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 1 July 2014 at 05:58:19 UTC, Uranuz wrote: Thanks for quick response. I really forget to look into language __traits statement. Another option: enum isFoo(T) = is(T == Foo!P, P...); By using such an is-expression you get the parameters Foo was instantiated with as an added

Re: Integer max value

2014-07-02 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 2 July 2014 at 08:39:06 UTC, pgtkda wrote: Is there a way to get the max size of an integer? int.max The same exists for other built-ins and enums.

Re: dependency graph

2014-07-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Saturday, 5 July 2014 at 15:33:51 UTC, Vlad Levenfeld wrote: A colleague of mine had asked me if I could produce some kind of object/module dependency type of graph for a D project I've got. I'm not sure what these are called but I've seen them before for inheritance hierarchies in C++

Re: Converting a POD struct to a class at compile-time ?

2014-07-16 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 16 July 2014 at 18:27:31 UTC, Klb wrote: On Wednesday, 16 July 2014 at 18:09:10 UTC, Adam D. Ruppe wrote: On Wednesday, 16 July 2014 at 17:43:03 UTC, Klb wrote: auto names = __traits(allMembers, S); Error: static variable _names_field_0 cannot be read at compile time. The

Calling dynamically bound functions from weakly pure function

2014-07-18 Thread Rene Zwanenburg via Digitalmars-d-learn
For all intents and purposes, the following code can be weakly pure: struct VAO { }

Re: Calling dynamically bound functions from weakly pure function

2014-07-18 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 18 July 2014 at 15:57:40 UTC, John Colvin wrote: On Friday, 18 July 2014 at 14:15:46 UTC, Rene Zwanenburg wrote: For all intents and purposes, the following code can be weakly pure: struct VAO { } urrmm. Did you mean to post more than that? Haha yup. Not sure what happened

Re: Calling dynamically bound functions from weakly pure function

2014-07-22 Thread Rene Zwanenburg via Digitalmars-d-learn
On Saturday, 19 July 2014 at 11:12:00 UTC, Marc Schütz wrote: Casting to pure would break purity if the called function is not actually pure. AFAIU, the problem is that the mutable function pointers are not accessible from inside the pure function at all, in which case the solution is to cast

Re: D may disappoint in the presence of an alien Garbage Collector?

2014-07-28 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 28 July 2014 at 19:57:38 UTC, Carl Sturtivant wrote: Suppose I want to use D as a system programming language to work with a library of functions written in another language, operating on dynamically typed data that has its own garbage collector, such as an algebra system or the

Re: How to easily construct objects with multi-param constructors from lazy ranges?

2014-08-05 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 5 August 2014 at 15:13:37 UTC, Rene Zwanenburg wrote: clean looking code to parse Wavefont OBJ files [0]. [0] http://en.wikipedia.org/wiki/Wavefront_.obj_file

How to easily construct objects with multi-param constructors from lazy ranges?

2014-08-05 Thread Rene Zwanenburg via Digitalmars-d-learn
Here's something which I've run into a few times now without finding a pretty solution. When parsing a text file using lazy ranges and algorithms you will have to convert a string range to an object at some point. In this particular case I was curious to see if I could write clean looking

Re: How to easily construct objects with multi-param constructors from lazy ranges?

2014-08-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 5 August 2014 at 19:21:44 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: Some range which takes an at compile time known number of elements from an input range and provides opIndex seems perfect to me, but as far as I know there's no such thing in Phobos. There is chunks:

Re: How to easily construct objects with multi-param constructors from lazy ranges?

2014-08-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 08:00:32 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: Yea, but that won't work for forward ranges. It only provides opIndex if the underlying range provides it. Since the chunk size is a runtime parameter it can't implement opIndex efficiently for

Re: Downloading Files in D

2014-09-11 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 11 September 2014 at 17:37:24 UTC, Nordlöw wrote: On Thursday, 11 September 2014 at 14:30:39 UTC, Jacob Carlborg wrote: If you don't want to worry about dependencies on libcurl you can use Tango [1] [2]. You can see how I use Tango to download files in DVM [3] Ok, thanks. And I

Re: find all public properties at compile time

2014-09-30 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 29 September 2014 at 20:21:43 UTC, gedaiu wrote: Hi, There is a way to determine all public properties (not methods) from a struct/class at compile time? I seen that there are traits to get only methods but not properties. Am I wrong? thanks, Bogdan You can get the function

Re: Simple timing

2014-11-17 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 17 November 2014 at 16:24:10 UTC, Paul wrote: I'm trying to write a program that involves simple timing; I like to be able to execute some function at a point no sooner than, say, 3500 milliseconds from now so I need to read the current 'system time' in ticks and calculate the

Re: Sum informations in file....

2014-11-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 24 November 2014 at 20:23:57 UTC, Suliman wrote: thanks! But how I can skip first line? My varian: auto lines = foo.txt.File .byLine .filter!(f=f[0] != f[0]); With 'drop' from std.range: auto lines = foo.txt.File .byLine

Re: Classes and @disable this()

2015-02-08 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 8 February 2015 at 16:28:21 UTC, fra wrote: On Sunday, 8 February 2015 at 16:22:36 UTC, fra wrote: Missclick... Anywya: class Something { @disable this(); this(int i) {} } produces an undefined reference error. I guess it has to do with classes implicitly inheriting from

Re: Undefined symbol?

2015-02-19 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 19 February 2015 at 01:29:39 UTC, Tofu Ninja wrote: I am not sure what could be the offending obj. I re downloaded dmd and phobos(pre compiled for windows), cleaned out all my builds and removed all of the tempfiles for dub that I could find. Have you tried running dub with

Re: Can't understand how to compare DateTime with opCmp

2015-02-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 1 February 2015 at 15:04:39 UTC, Suliman wrote: I need to compare to DateTime. I looked at docs and found opCmp for DateTime type. The problem is that I can't understand how to use it. http://dlang.org/phobos/std_datetime.html#DateTime opCmp(in DateTime rhs); what is rhs? I am

Re: import std.random fails

2015-01-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 6 January 2015 at 20:26:25 UTC, ixid wrote: Dmd latest non-beta, with the latest VisualD. Debug build. Debug build and no additional or non default settings. Hmm.. Did you verify that the D installation directory was completely empty after uninstalling? Does VisualD have some

Re: How to prevent sensitive information is displayed when the extension 'exe' is modified to 'txt' on windows?

2015-01-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 6 January 2015 at 17:32:29 UTC, Adam D. Ruppe wrote: On Tuesday, 6 January 2015 at 17:15:28 UTC, FrankLike wrote: How to prevent sensitive information is displayed when the extension 'exe' is modified to 'txt' on windows? If the data is in the program, it is visible to anyone you

Re: import std.random fails

2015-01-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 5 January 2015 at 15:59:17 UTC, ixid wrote: On Friday, 31 August 2012 at 22:52:13 UTC, Jonathan M Davis wrote: On Saturday, September 01, 2012 00:40:25 deed wrote: import std.random void main() {} --- results in: Error 42: Symbol Undefined

Re: Derelict Assimp not loading mesh properly? (Maybe index buffer)

2015-03-07 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 6 March 2015 at 02:41:19 UTC, Bennet wrote: I wrote a custom OBJ file importer which worked fairly well however was not robust enough to support everything. I've decided to give AssImp a shot. I followed some tutorials and have set up my code to read in the vertices, tex coords,

Re: BigInt and xor

2015-03-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 15:45:36 UTC, Dennis Ritchie wrote: Tell me, please, how can I replace this code? import std.conv : to; import std.bigint : BigInt; import std.string : format; import std.stdio : writeln; void main() { BigInt[10] bitArr; ulong n =

Re: std.typecons.Flag -- public import for API users?

2015-03-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Saturday, 21 March 2015 at 23:16:39 UTC, rcorre wrote: If I am developing a library and some of my functinos take a std.typecons.Flag as an argument, should I 'public import std.typecons: Flag, Yes, No'? It seems like it would be a pain for users of the library to have to import this

Re: DerelictGL3.reload() returns wrong (?) GLVersion (GL32, should be 33)

2015-03-29 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 29 March 2015 at 01:27:01 UTC, Koi wrote: Hello, today i implemented OpenGL instancing, and it crashed when calling glVertexAttribDivisor (OpenGL 3.3). So i checked DerelictGL3.reload() and it returned GLVersion.GL32, not GL33. My graphic card (NVidia GT 240) should support

Re: Convert hex to binary

2015-04-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 24 April 2015 at 19:15:04 UTC, Ivan Kazmenko wrote: On Friday, 24 April 2015 at 18:55:07 UTC, Steven Schveighoffer wrote: Thanks to all of you for the solutions, but what if the hex-string exceeds the limit of ulong, for instance 123456789ABCDEF0123456789ABCDEF1234. How to convert

Re: Convert hex to binary

2015-04-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 24 April 2015 at 18:55:07 UTC, Steven Schveighoffer wrote: On 4/24/15 2:50 PM, nrgyzer wrote: On Friday, 24 April 2015 at 18:45:55 UTC, Jesse Phillips wrote: On Friday, 24 April 2015 at 18:14:07 UTC, nrgyzer wrote: Hi, I'm looking for a function that converts my hex-string to a

Re: Implementing Iterator to support foreach

2015-04-08 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 09:02:08 UTC, bearophile wrote: tcak: I am planning to implement Iterator class. But looking at foreach statement, it takes a range only. Unless you are just experimenting, it's better to not go against a language and its std lib. Bye, bearophile Also, why

Re: Covariant callback functions, or assigning base class members through a subclass reference

2015-07-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 14 July 2015 at 15:35:04 UTC, Kagamin wrote: Template Base on Derived: class Derived : Base!Derived { } Sure, but that would make Base!Derived and Base!AnotherSubClass different types. What I'd like to end up with is a Base[], being able to call foo() on the array members.

Covariant callback functions, or assigning base class members through a subclass reference

2015-07-14 Thread Rene Zwanenburg via Digitalmars-d-learn
Given the following code: class Base { alias CallbackType = void delegate(Base); CallbackType callback; void foo() { callback(this); } } class Derived : Base { } void main() { auto d = new Derived();

Re: Covariant callback functions, or assigning base class members through a subclass reference

2015-07-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 14 July 2015 at 17:26:32 UTC, Steven Schveighoffer wrote: On 7/14/15 11:28 AM, Rene Zwanenburg wrote: Given the following code: class Base { alias CallbackType = void delegate(Base); CallbackType callback; void foo() { callback(this); } } class

Is this a bug?

2015-09-11 Thread Rene Zwanenburg via Digitalmars-d-learn
The following fails to compile with an 'cannot deduce function from argument types' error. When using an array of something other than TypeInfo_Class everything works as expected. void main() { import std.algorithm.mutation : remove; TypeInfo_Class[] arr;

Re: Is this a bug?

2015-09-11 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 11 September 2015 at 11:26:49 UTC, anonymous wrote: On Friday 11 September 2015 12:33, Rene Zwanenburg wrote: The following fails to compile with an 'cannot deduce function from argument types' error. When using an array of something other than TypeInfo_Class everything works as

Re: Testing Return Value Optimization (RVO)

2015-09-27 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 27 September 2015 at 13:55:02 UTC, chmike wrote: Can someone please explain me why this doesn't work as I would expect RVO to work ? I'm not an expert on the subject so this may contain some inaccuracies, but the gist of it is: As the name implies, NRVO is an optimization and

Re: gl3n does not seem to have an ortho function like glm. Any replacements?

2015-10-04 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 4 October 2015 at 21:30:43 UTC, WhatMeWorry wrote: I'm porting some C++/OpenGL/glm code over to D, And I've run into a glm::ortho function. glm::mat4 projection = glm::ortho(0.0f, static_cast(WIDTH), 0.0f, static_cast (HEIGHT)); gl3n is great for vecs and mats but does not

Re: Derelict SFML2 - structs are forward referenced

2015-12-26 Thread Rene Zwanenburg via Digitalmars-d-learn
On Saturday, 26 December 2015 at 09:48:29 UTC, Lucien wrote: Hello. I want to use Derelict-SFML2 to create a simple window. But when I compile (linked with dub and derelict-util), I have the following error: src/app.d(30,20): Error: variable myproject.main.window no definition of struct

Re: Range and poolTask

2016-06-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 6 June 2016 at 09:32:30 UTC, moechofe wrote: I wonder if it is possible to write something like this: --- // taskPool.distribute -- take a range and distribute entries to different threads. dirEntries().distribute(function(R1,R2)(R1 from,R2 to){ from .filter!xxx

Re: Range and poolTask

2016-06-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 6 June 2016 at 10:26:11 UTC, moechofe wrote: The functions passed to map or amap take the type of the element of the range as argument, but not a range itself. Right. I don't think I understand what the semantics of your example would be though.. Could you elaborate a bit?

Re: What's up with GDC?

2016-06-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 13 June 2016 at 20:21:28 UTC, Joerg Joergonson wrote: Are you running some other program that might be sending a lot of broadcast messages? Not that I know of. I haven't tried running it outside VS though so it might be doing something weird. I'll investigate further when I get

Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 09:48:19 UTC, TheDGuy wrote: But if i execute the app my hand (in the windows command window or my double click) it works as expected (so no error)? Why is that? My first guess would be that Coedit does not use the directory where the executable is located as

Re: Benchmark Dlang vs Node vs Ruby

2016-05-27 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote: Hi guys, In my journey of learning about D I tried to benchmark D with Vibe.d vs node with express and Ruby with Sinatra. And the results are pretty surprising. I have to admit that I though D was more faster than that. How is this even

Re: Benchmark Dlang vs Node vs Ruby

2016-05-27 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 27 May 2016 at 15:18:38 UTC, llaine wrote: - And how can I minimize allocations? My previous post still allocates though, through that call to array at the end. I'm not sure how to completely remove all allocations (I'm not that familiar with vibe.d), but I strongly suspect it's

Re: Benchmark Dlang vs Node vs Ruby

2016-05-27 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 27 May 2016 at 15:04:31 UTC, llaine wrote: My level of D is really slow, so can you help me to improve this? :) Here's an alternative getCompanies. Untested so it may contain some mistakes. Company[] getCompanies() { auto conn = client.lockConnection(); immutable result =

Re: Using referenceCounters

2016-06-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 18:14:33 UTC, Begah wrote: I started using reference counters for my assets in my application : - Images - Models - For my resource manager I started out with something similar to what you're describing, but I eventually changed the design which turned

Re: Creating a "fixed-range int" with opDispatch and/or alias this?

2016-06-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 19:59:51 UTC, Mark Isaacson wrote: FWIW, the fixed range int part of this question is just an example, I'm mostly just interested in whether this idea is possible without a lot of bloat/duplication. I suspect not.. Here's how std.typecons.Proxy is doing it:

Re: Preferred method of creating objects, structs, and arrays with deterministic memory management

2016-06-01 Thread Rene Zwanenburg via Digitalmars-d-learn
I was wondering: what's the preferred method for deterministic memory management? You may be interested in RefCounted. It only works for structs, not classes, but it's still useful. - Classes/Structs have constructors and destructors. I am unconfident with my knowledge as to how this works

Re: Base64 of String without casting

2016-06-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 09:31:51 UTC, tcak wrote: I understand that Base64 uses Ranges, and since String is seen and used as unicode by Ranges (please tell me if I am wrong). I am guessing, for this reason, auto btoa = std.base64.Base64.encode("Blah"); doesn't work. You need to be

Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 10:31:18 UTC, TheDGuy wrote: Thanks a lot for your answer, getcwd() returns the path where coedit is located on my harddrive: C:\Program Files (x86)\Coedit_32\coedit.2update6.win32 How can i change that? I'm not familiar with Coedit, but the run options seem to

Re: Out of order execution

2016-06-16 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 16 June 2016 at 01:57:19 UTC, Joerg Joergonson wrote: Is there an efficient lazy way to make this happen? No, I don't see how that would work. Suppose I can't run the loop twice for performance reasons(there is other stuff in it) and I don't want to store the state and call

Re: Templated class defaults and inheritence

2016-06-19 Thread Rene Zwanenburg via Digitalmars-d-learn
On Saturday, 18 June 2016 at 17:48:47 UTC, Joerg Joergonson wrote: class foo(T) if (is(T : subfoo)) X; FYI this can also be done in the template parameter list: class foo(T : subfoo){}

Re: How to use a char[] buffer in D

2016-06-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 23 June 2016 at 05:59:10 UTC, Andrew Chapman wrote: Perfect, thank you! :-) Works like a charm. On Wednesday, 22 June 2016 at 22:41:24 UTC, H. S. Teoh wrote: On Wed, Jun 22, 2016 at 09:57:04PM +, Andrew Chapman via Digitalmars-d-learn wrote: Maybe try: if (buffer[]

Re: call to super trashes pointer?

2016-02-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 23 February 2016 at 09:16:08 UTC, Nicholas Wilson wrote: struct A { int blah; } class B { A* a; this(A* _a) { writeln(_a) a =_a; } } class C : B { this(A* _a) { writeln(_a) super(_a); } } int main(string[] args) { A

Re: Cannot link using DMD nightly

2016-02-28 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 28 February 2016 at 19:02:21 UTC, Matt Elkins wrote: Any suggestions? I don't know how to fix that error, but 2.070.1 has been released and contains a fix for your issue: http://dlang.org/changelog/2.070.1.html

Re: Const vs Non const method

2016-02-25 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 25 February 2016 at 10:44:49 UTC, Andrea Fontana wrote: Check this simple code: http://dpaste.dzfl.pl/2772c9144f1c I can't understand how to minimize code duplication for function like get(). Of course on real case body is much bigger and complex than that. The only way I found

Re: Can DUB --combined builds be faster?

2016-03-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 14 March 2016 at 11:03:41 UTC, Guillaume Piolat wrote: I'm cargo-culting the use of --combined with DUB because I somehow think inlining will be better in this way. (For thos who don't use DUB, what it does is compiling the whole program with a single compiler invokation instead of

Re: immutable array in constructor

2016-03-18 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 17 March 2016 at 10:11:43 UTC, Jeff Thompson wrote: This is a simplified example from a larger class I have where I need an immutable constructor. This is because I need to construct an object an pass it to other functions which take an immutable object. So, how to keep an

Re: Continuous integral range predicate

2016-03-31 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 31 March 2016 at 11:33:36 UTC, Nordlöw wrote: Is there a function in Phobos to check if a range of integral elements is adjacent, that is x[i+1] == x[i] + 1 where x[i] is the i:th element of the range. (untested) std.algorithm.findAdjacent!((a, b) => a !=

Re: VibeCustomMain not working

2016-04-07 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 7 April 2016 at 13:40:17 UTC, Rene Zwanenburg wrote: That's possible of course, but I'd expect something so fundamental breaking to be noticed sooner. Just to make sure, could you run dub with --force to rule out that it's picking up some stale object files from somewhere? And

Re: VibeCustomMain not working

2016-04-07 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 7 April 2016 at 13:25:29 UTC, Jerry wrote: I generated a visuald project and tried that. Now suddenly it is working as expected. So I guess it's a bug in dub. That's possible of course, but I'd expect something so fundamental breaking to be noticed sooner. Just to make sure,

Re: @nogc inconsistent for array comparison depending on mutability of elements

2016-04-08 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 8 April 2016 at 09:56:41 UTC, Nick Treleaven wrote: If the comparison with b shouldn't be allowed, I suggest we add opEquals to std.range.only. This removes a need to import std.algorithm.equal and reduces bracket nesting: assert(b == only(1, 2)); equal[1] can compare ranges of

Re: Issue with 2.071: Regression or valid error?

2016-04-08 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 8 April 2016 at 08:26:11 UTC, Daniel Kozak wrote: On Friday, 8 April 2016 at 06:08:38 UTC, 9il wrote: On Thursday, 7 April 2016 at 15:55:16 UTC, Steven Schveighoffer wrote: Wow, totally agree with you. Compiler shouldn't make you jump through this hoop: void foo(Cat cat) {

  1   2   >