Re: Constructor - the both look the same

2016-03-12 Thread Joel via Digitalmars-d-learn
On Saturday, 12 March 2016 at 08:11:10 UTC, Iakh wrote: On Saturday, 12 March 2016 at 07:43:59 UTC, Joel wrote: Why does it come up with this? source/setup.d(40,16): Error: constructor inputjex.InputJex.this (Vector2!float pos, int fontSize, InputType type = cast(InputType)0) is not callable

Re: Using tango or other static lib in static lib

2016-03-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 March 2016 at 22:34:19 UTC, Voitech wrote: At beginning I want to say that I'm Java devloper so most of linking, joining, dependent classes, libs could be solve with simple 3 click in eclipse so please be patient with me :). I'm using Mono-D under Ubuntu 14.04 to create my

Re: Constructor - the both look the same

2016-03-12 Thread Joel via Digitalmars-d-learn
On Saturday, 12 March 2016 at 23:43:33 UTC, Joel wrote: On Saturday, 12 March 2016 at 08:11:10 UTC, Iakh wrote: On Saturday, 12 March 2016 at 07:43:59 UTC, Joel wrote: Why does it come up with this? source/setup.d(40,16): Error: constructor inputjex.InputJex.this (Vector2!float pos, int

Re: Bikeshed: Implementing a command queue.

2016-03-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 12 March 2016 at 15:10:16 UTC, maik klein wrote: I wanted to implement a simple command queue in D. To give a bit of context, I want to create a command queue for opengl. Instead of interacting directly with opengl, you will create commands, put them in a queue and then the

Re: Using tango or other static lib in static lib

2016-03-12 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 13 March 2016 at 01:06:33 UTC, Mike Parker wrote: it. Assuming both files live in the same directory, they can be compiled with this command: Somehow I deleted that line: dmd main.d something.d

Is there a sorted map?

2016-03-12 Thread stunaep via Digitalmars-d-learn
Is there any sorted map in D? I need a map and I need to be able to get the highest key in the map. In java I would use a TreeMap and use map.lastKey(), but since associative arrays are not sorted that would be O(n). I know about RedBlackTree, but that's a set and it must be a map.

Why is it not possible to write to a file from a const member function ?

2016-03-12 Thread user42 via Digitalmars-d-learn
Hi I have the following snippet to illustrate my problem/question: class X { import std.stdio: write, File, stdout; private File* f = void p(string s) const { f.write(s); } } class Y { private string s = "Y"; override string toString() const { return s; } }

Clearing associative array.

2016-03-12 Thread ciechowoj via Digitalmars-d-learn
Could someone explain to me, why following code does not compile? int main() { string[string] x = [ "foo" : "bar" ]; x.clear(); x = []; return 0; } Errors: main.d(7): Error: no property 'clear' for type 'string[string]' main.d(8): Error: cannot implicitly

Re: Clearing associative array.

2016-03-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 March 2016 at 12:34:16 UTC, ciechowoj wrote: If above doesn't work how am I supposed to clear the array? `x = string[string].init;` is somewhat ugly. Read the Tip of the Week section here: http://arsdnet.net/this-week-in-d/dec-13.html Short answer: use `= null` to clear the

Re: Clearing associative array.

2016-03-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 March 2016 at 12:59:02 UTC, ciechowoj wrote: Nice article :), thanks. But still, what about clear()? In the documentation https://dlang.org/spec/hash-map.html#properties there is written that associative arrays have clear property. I don't think that actually works... might be

Re: Why is it not possible to write to a file from a const member function ?

2016-03-12 Thread user42 via Digitalmars-d-learn
On Saturday, 12 March 2016 at 15:32:39 UTC, Mike Parker wrote: On Saturday, 12 March 2016 at 14:02:31 UTC, user42 wrote: Why is this thing not compiling ? Or, in other words, how is is possible to log something to a file from a const member function ? Const member functions functions are

Re: Why does array loses it internal capacity on length change?

2016-03-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 March 2016 at 09:56:48 UTC, Uldis wrote: Why is this happening, how to avoid it? Details here: http://dlang.org/d-array-article.html it is so one slice can never stomp over the contents of another slice when you append to it. array.assumeSafeAppend() can override it.

Re: Filling an array

2016-03-12 Thread Alex via Digitalmars-d-learn
On Saturday, 12 March 2016 at 15:44:00 UTC, Mike Parker wrote: On Saturday, 12 March 2016 at 14:33:19 UTC, Alex wrote: //arr[] = 1; The question is, why the commented out line throws the error: Error: cannot implicitly convert expression (1) of type int to Nullable!uint[], while the

Bikeshed: Implementing a command queue.

2016-03-12 Thread maik klein via Digitalmars-d-learn
I wanted to implement a simple command queue in D. To give a bit of context, I want to create a command queue for opengl. Instead of interacting directly with opengl, you will create commands, put them in a queue and then the renderer will read those commands and execute the correct OpenGl

Re: Why is it not possible to write to a file from a const member function ?

2016-03-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 March 2016 at 14:02:31 UTC, user42 wrote: Why is this thing not compiling ? Or, in other words, how is is possible to log something to a file from a const member function ? Const member functions functions are not allowed to mutate any member state at all. This includes

Re: Filling an array

2016-03-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 March 2016 at 14:33:19 UTC, Alex wrote: //arr[] = 1; The question is, why the commented out line throws the error: Error: cannot implicitly convert expression (1) of type int to Nullable!uint[], while the line after that works. Looks like a bug somewhere. The work

Re: Clearing associative array.

2016-03-12 Thread ciechowoj via Digitalmars-d-learn
On Saturday, 12 March 2016 at 12:42:04 UTC, Adam D. Ruppe wrote: On Saturday, 12 March 2016 at 12:34:16 UTC, ciechowoj wrote: If above doesn't work how am I supposed to clear the array? `x = string[string].init;` is somewhat ugly. Read the Tip of the Week section here:

Filling an array

2016-03-12 Thread Alex via Digitalmars-d-learn
Hi all! I have, maybe, a silly question.. Not sure, if https://forum.dlang.org/post/ibxhuqamgclrcatsy...@forum.dlang.org has something to do with the topic Having the following code: import std.typecons; import std.algorithm; void main() { uint[] arr_ref; arr_ref.length = 5;

Re: BZ2 library

2016-03-12 Thread stunaep via Digitalmars-d-learn
On Saturday, 12 March 2016 at 10:10:44 UTC, Basile B. wrote: On Saturday, 12 March 2016 at 09:53:36 UTC, stunaep wrote: [...] "dflags" : ["lib\\libbzip2.lib"] is only if you want to compile as 32 bit AND in OMF, so the -m32mscoff switch must NOT be set (I see that someone else explained you

Re: BZ2 library

2016-03-12 Thread stunaep via Digitalmars-d-learn
On Saturday, 12 March 2016 at 07:56:03 UTC, Mike Parker wrote: [...] If I do "dflags" : ["lib/libbzip2.lib"] as Basile B. suggested instead of pragma, I get the same error on x86_64 as I do on x86

Why does array loses it internal capacity on length change?

2016-03-12 Thread Uldis via Digitalmars-d-learn
While writing a structs function that I wanted to minimize allocations and use an internal preallocated buffer, but I noticed that arrays are losing their capacity when its length is changed. For example: void main() { int[] a; a.reserve = 1024; void dump(in ref

Re: BZ2 library

2016-03-12 Thread Basile B. via Digitalmars-d-learn
On Saturday, 12 March 2016 at 09:53:36 UTC, stunaep wrote: On Saturday, 12 March 2016 at 07:56:03 UTC, Mike Parker wrote: [...] On Saturday, 12 March 2016 at 09:04:08 UTC, stunaep wrote: On Saturday, 12 March 2016 at 07:56:03 UTC, Mike Parker wrote: [...] If I do "dflags" :

Re: BZ2 library

2016-03-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 March 2016 at 06:50:59 UTC, stunaep wrote: On Saturday, 12 March 2016 at 06:07:25 UTC, Mike Parker wrote: [...] I used visual studio 2013 to build the libraries With dflag -m64 and dub flag --arch=x86_64, this happens You shouldn't specify -m64 in your configuration. DUB

Re: Constructor - the both look the same

2016-03-12 Thread Iakh via Digitalmars-d-learn
On Saturday, 12 March 2016 at 07:43:59 UTC, Joel wrote: Why does it come up with this? source/setup.d(40,16): Error: constructor inputjex.InputJex.this (Vector2!float pos, int fontSize, InputType type = cast(InputType)0) is not callable using argument types (Vector2!float, int, InputType)

Re: Why does array loses it internal capacity on length change?

2016-03-12 Thread Jack Applegame via Digitalmars-d-learn
Why is this happening...? For safety reasons. Your array can be shared between parts of application. ...how to avoid it? https://dlang.org/library/object/assume_safe_append.html

Re: BZ2 library

2016-03-12 Thread stunaep via Digitalmars-d-learn
On Saturday, 12 March 2016 at 07:56:03 UTC, Mike Parker wrote: [...] On Saturday, 12 March 2016 at 09:04:08 UTC, stunaep wrote: On Saturday, 12 March 2016 at 07:56:03 UTC, Mike Parker wrote: [...] If I do "dflags" : ["lib/libbzip2.lib"] as Basile B. suggested instead of pragma, I get the

Re: Filling an array

2016-03-12 Thread Alex via Digitalmars-d-learn
On Saturday, 12 March 2016 at 16:37:25 UTC, user42 wrote: On Saturday, 12 March 2016 at 14:33:19 UTC, Alex wrote: /snip I thought this was supposed to halt with an error rather than compile and set all members to 1. The syntax, to me anyways, doesn't really communicate the intention of: set

Re: Filling an array

2016-03-12 Thread user42 via Digitalmars-d-learn
On Saturday, 12 March 2016 at 14:33:19 UTC, Alex wrote: /snip I thought this was supposed to halt with an error rather than compile and set all members to 1. The syntax, to me anyways, doesn't really communicate the intention of: set all members to 1. //arr[] = 1; Whereas the

Re: Filling an array

2016-03-12 Thread ag0aep6g via Digitalmars-d-learn
On 12.03.2016 16:44, Mike Parker wrote: arr[] = cast(Nullable!uint)1; Nicer than a cast: construct a Nullable!int. arr[] = Nullable!uint(1);

Re: Filling an array

2016-03-12 Thread Alex via Digitalmars-d-learn
On Saturday, 12 March 2016 at 19:35:30 UTC, ag0aep6g wrote: On 12.03.2016 16:44, Mike Parker wrote: arr[] = cast(Nullable!uint)1; Nicer than a cast: construct a Nullable!int. arr[] = Nullable!uint(1); ok... so... this makes the error very strange, then... almost senseless...

Using tango or other static lib in static lib

2016-03-12 Thread Voitech via Digitalmars-d-learn
At beginning I want to say that I'm Java devloper so most of linking, joining, dependent classes, libs could be solve with simple 3 click in eclipse so please be patient with me :). I'm using Mono-D under Ubuntu 14.04 to create my project it would be a library for further development process,

Re: Bikeshed: Implementing a command queue.

2016-03-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 12 March 2016 at 15:10:16 UTC, maik klein wrote: I wanted to implement a simple command queue in D. To give a bit of context, I want to create a command queue for opengl. Instead of interacting directly with opengl, you will create commands, put them in a queue and then the