Re: Associative array of const items

2016-07-01 Thread QAston via Digitalmars-d-learn
On Thursday, 30 June 2016 at 17:08:45 UTC, Jonathan Marler wrote: Is there a way to have an associative array of const values? I thought it would have been: const(T)[K] map; map[x] = y; but the second line gives Error: cannot modify const expression. I would think that the const(T)[K] would

Re: Cast vs Virtual Method vs TypeId?

2016-06-30 Thread QAston via Digitalmars-d-learn
On Thursday, 30 June 2016 at 00:25:53 UTC, Jonathan Marler wrote: I'd like to hear peoples thoughts on the various solutions for the following problem. Say you have some hierarchy of classes like: class GameObject { // ... } class Entity : GameObject { // ... } class Player : Entity {

Re: mutable keyword

2016-05-19 Thread QAston via Digitalmars-d-learn
On Thursday, 19 May 2016 at 20:44:54 UTC, ciechowoj wrote: Is there D equivalent of C++'s mutable keyword? Like the one that allows to modify a field of struct from constant method. Or some alternative solution? There isn't an equivalent of mutable keyword because D const differs from C++

Re: GC allocation

2016-04-21 Thread QAston via Digitalmars-d-learn
here: https://github.com/QAston/transducers-dlang/blob/master/source/transduced/transducers.d#L797 you can see there various variants of doing the same operation, using closure, function and struct.

Re: GC allocation

2016-04-21 Thread QAston via Digitalmars-d-learn
On Thursday, 21 April 2016 at 15:22:15 UTC, Alex wrote: Hi all! timing my program with valgrind/cachegrind and using -vgc option of the compiler found the message: "using closure causes GC allocation" The question is: does the usage of the closure causes the GC allocation on every usage of

Re: How to be more careful about null pointers?

2016-03-29 Thread QAston via Digitalmars-d-learn
On Monday, 28 March 2016 at 21:01:19 UTC, cy wrote: I finally found the null pointer. It took a week. I was assigning "db = db" when I should have been assigning "this.db = db". Terrible, I know. But... I invoked db.find_chapter.bindAll(8,4), when db was a null pointer. There was no null

Re: Solution to "statement is not reachable" depending on template variables?

2016-03-19 Thread QAston via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 11:18:36 UTC, Johan Engelen wrote: Hi all, I've found discussions, but not an actual "recommended" solution for the problem of "statement is not reachable" warnings in templates with early returns, e.g.: ``` bool nobool(T...)() { foreach (i, U; T) {

Re: Solution to "statement is not reachable" depending on template variables?

2016-03-19 Thread QAston via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 17:08:20 UTC, Johan Engelen wrote: On Wednesday, 16 March 2016 at 11:47:35 UTC, QAston wrote: import std.meta; template isBool(U)() = is(U == bool); static if (!allSatisfy!(isBool, T)) { return true; // no longer emits a warning } Something like this should

Re: alias template parameter

2016-01-23 Thread QAston via Digitalmars-d-learn
On Friday, 21 June 2013 at 14:08:43 UTC, Sergei Nosov wrote: Hi! I've been thinking about how alias template parameters work and I'm really confused =) It makes perfect sense for literals, names, etc. But what I can't get is how does it work for delegates. If I have a function auto

Re: Partial application of compile time args type deduction

2016-01-20 Thread QAston via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 00:50:49 UTC, Ali Çehreli wrote: On 01/19/2016 04:22 PM, QAston wrote: [...] Is this it? If so, is it already in std.functional? (I could not find it. :) ) auto appendMapped(alias f, R, T)(R r, T elem) { r ~= f(elem); return r; } int minus(int i

Re: Overload dispatch by templated interface type doesn't seem to work

2016-01-20 Thread QAston via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 14:01:23 UTC, QAston wrote: To me this suggests that the dispatch by templated interface type Visitor!(RETURN) doesn't work. IMO the order of interfaces shouldn't matter here and the code should simply work. Any ideas? I'm on 2069.2 and when i remove one

Overload dispatch by templated interface type doesn't seem to work

2016-01-20 Thread QAston via Digitalmars-d-learn
Hi, I have the following code: interface Visitable(RETURN) { RETURN accept(Visitor!RETURN); } interface Exp : Visitable!string, Visitable!int { } interface Visitor(RETURN) { RETURN visitLit(Lit e); RETURN visitAdd(Add e); } class Lit : Exp { int val;

Partial application of compile time args type deduction

2016-01-19 Thread QAston via Digitalmars-d-learn
Hi, I have the following code: auto appendMapped(alias f, R, T)(R r, T elem) { r ~= f(elem); return r; } int minus(int i) { return -i; } unittest { int[] ar; // here I do partial application of minus function alias appendMinus(S,T) =

Re: Partial application of compile time args type deduction

2016-01-19 Thread QAston via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 00:12:16 UTC, Ali Çehreli wrote: On 01/19/2016 03:37 PM, QAston wrote: Hi, I have the following code: auto appendMapped(alias f, R, T)(R r, T elem) { r ~= f(elem); return r; } int minus(int i) { return -i; } unittest { int[] ar

Re: Theoretical Best Practices

2015-08-14 Thread QAston via Digitalmars-d-learn
On Friday, 14 August 2015 at 09:21:56 UTC, DarthCthulhu wrote: I only want to access the logger object when the program is compiled with the -debug option, so I don't want to pass it along to the object constructor or set a member as a reference to it (which is both tedious and pointless if

Re: How to run opengl tutorials

2015-08-08 Thread QAston via Digitalmars-d-learn
On Sunday, 2 August 2015 at 10:04:54 UTC, nikolai wrote: Yes, I was so excited about Dlang that i forgot to paste the error: Here's the link to imagescreen http://prntscr.com/7zwe6h Can't help you with your problem, but I have another tip: Shift-right-click inside a dir- open cmd window here

Re: Array start index

2015-08-04 Thread QAston via Digitalmars-d-learn
On Monday, 3 August 2015 at 21:32:05 UTC, DLearner wrote: Looks like 0-base is fixed, to avoid problems with existing code. But nothing stops _adding_ to the language by allowing int[x:y] foo to mean valid symbols are foo[x], foo[x+1],..., foo[y]. Plus rule that int[:y] means valid symbols

Re: Array start index

2015-08-02 Thread QAston via Digitalmars-d-learn
On Saturday, 1 August 2015 at 23:02:51 UTC, bachmeier wrote: But what type of programming are you doing? Even after decades of programming and trying out dozens of languages, zero-based indexing still gets me at times when the arrays I work with represent vectors and matrices. Especially when

Re: question about the semantics of unshared variables

2015-07-16 Thread QAston via Digitalmars-d-learn
On Thursday, 16 July 2015 at 07:43:10 UTC, Jonathan M Davis wrote: [...] On linux you can alter the limit by using ulimit command. -a option shows the current limits.

Re: Classes. C++ to D

2015-05-03 Thread QAston via Digitalmars-d-learn
On Sunday, 3 May 2015 at 17:35:42 UTC, Dennis Ritchie wrote: Hi, How can I rewrite this code to the D? - #include string #include iostream class A { public: std::string a() { return std::string(foo); } }; class B { public: std::string b(){ return

traits getOverload of a template method

2014-02-06 Thread QAston
How do i get aliases to overloads of a template method like Class A { int a(T)(T tq,T tw); int a(T)(T tq); } __traits(getOverloads, A, a(int))doesnt work

Re: universal databade connector as jdbc

2013-12-11 Thread QAston
On Wednesday, 11 December 2013 at 10:49:43 UTC, bioinfornatics wrote: Hi, Little question, I'm looking a jdbc like in D ? Does this exists ? Thanks https://github.com/buggins/ddbc - see readme for more info.

Re: mixed type list?

2013-11-20 Thread QAston
On Wednesday, 20 November 2013 at 11:07:27 UTC, seany wrote: Is there any way to represent mixed data (of various types) as a single array? In scilab, we have list, and you can do list(integer, stringvar ) etc. Can you do something similar in D? An idea is to use a struct wil all

Re: Compiling an app to a single binary - possible?

2013-11-15 Thread QAston
On Friday, 15 November 2013 at 15:27:45 UTC, Jacek Furmankiewicz wrote: One of the nice features of Go is that when you compile an app, it pulls in ALL the dependencies (i.e. the full SDK + all libraries your app depends on) and generates a single binary (around 2 MB for a Hello World app).

Re: genetically modified slices - is it possible?

2013-11-15 Thread QAston
On Friday, 15 November 2013 at 15:12:23 UTC, Alexandr Druzhinin wrote: 15.11.2013 22:09, Adam D. Ruppe пишет: You could make it work like this: auto slice3 = array[ slice1.length + (slice1.ptr - array.ptr) .. (slice2.ptr - array.ptr)];

Re: Source code of a method.

2013-10-27 Thread QAston
On Saturday, 26 October 2013 at 22:56:20 UTC, TheFlyingFiddle wrote: I kind of did the same thing here in the Mockable mixin: https://github.com/nomad-software/dunit Instead of wrapping i simply extended the target class so i have access to 'super.bar()'. Then i can add the specialisation code

Re: Source code of a method.

2013-10-27 Thread QAston
call that a simple example, but it's all i have by hand: https://github.com/QAston/DMocks-revived/blob/master/dmocks/object_mock.d I use this technique to mock structs and final classes.

Re: Source code of a method.

2013-10-26 Thread QAston
On Saturday, 26 October 2013 at 16:36:35 UTC, TheFlyingFiddle wrote: Is there a way to extract the source code of a method at compiletime? Short and to the point answer: no.

Re: VisualD import

2013-09-12 Thread QAston
On Wednesday, 11 September 2013 at 22:15:07 UTC, Rainer Schuetze wrote: On 11.09.2013 23:42, Lemonfiend wrote: On Wednesday, 11 September 2013 at 20:36:39 UTC, Rainer Schuetze wrote: On 11.09.2013 18:13, Lemonfiend wrote: Oops, I forgot to say what I actually did. I added derelict to

Re: static foreach and inline if

2013-07-28 Thread QAston
On Saturday, 27 July 2013 at 17:14:35 UTC, JS wrote: I'd like to have foreach and inline if in templates: inline if is available as std.traits.Select

Re: Build / Package system

2013-07-26 Thread QAston
On Wednesday, 30 May 2012 at 08:13:34 UTC, Sputnik wrote: There is a build and/or package managment system for D2 that is working? I googled, and I only can find things like dsss or cmaked that don't get updated from a long time ago. I really need to manage to get a project to compile in

Need a way to get compressed mangling of a symbol.

2013-07-16 Thread QAston
I'd like to dynamically load procedures from a dll in my app. To load a symbol from a DLL i need it's mangled name. D currently offers .mangleof which I currently use to generate the name. It works very good, but only for short symbols. Is there any way to get the final mangled name of a

Re: Need a way to get compressed mangling of a symbol.

2013-07-16 Thread QAston
On Tuesday, 16 July 2013 at 13:58:10 UTC, Adam D. Ruppe wrote: The reason I snipped the implementations here is the backend is under a more restrictive license so I don't want to get into copying that. But with just what I've said here combined with guess+check against dmd's output it might be

Re: for loop parens

2013-07-12 Thread QAston
On Saturday, 13 July 2013 at 04:56:19 UTC, Jonathan M Davis wrote: On Saturday, July 13, 2013 06:42:57 QAston wrote: On Friday, 12 July 2013 at 20:46:21 UTC, ixid wrote: Yes, I don't expect anyone to change their opinion though frankly the anti-groups opinions feel more like attachment

Re: for loop parens

2013-07-12 Thread QAston
On Saturday, 13 July 2013 at 04:42:58 UTC, QAston wrote: Also, i don't know what's wrong with parens - 2 additional keystrokes? I didn't see a for loop i a long time - ranges + foreach are everywhere. And foreach is 4 chars more to type than for :P. Replying to myself, but well

How can i increase max number recursive template expansions?

2013-07-07 Thread QAston
I have a large enum in my code (opcodes for a protocol) - using std.traits.EnumMembers gives me a recursive template error. How can i increase max number recursive template expansions?

Re: How can i increase max number recursive template expansions?

2013-07-07 Thread QAston
On Sunday, 7 July 2013 at 20:28:12 UTC, John Colvin wrote: On Sunday, 7 July 2013 at 20:22:59 UTC, Simen Kjaeraas wrote: On 2013-07-07, 21:55, QAston wrote: I have a large enum in my code (opcodes for a protocol) - using std.traits.EnumMembers gives me a recursive template error. How can i

Re: Why there is too many uneccessary casts?

2013-06-11 Thread QAston
On Tuesday, 11 June 2013 at 16:18:54 UTC, Adam D. Ruppe wrote: I'd be extremely annoyed if that required a cast. It's bleeding obvious that you want it to assign back there To me u = u + k is as obvious as u += k, but that's probably not a thing anyone would be much concerned about :)

Re: GtkD No GSettings schemas installed

2013-04-29 Thread QAston
On Sunday, 28 April 2013 at 17:18:48 UTC, Mike Wey wrote: On 04/28/2013 04:32 PM, QAston wrote: On Monday, 15 April 2013 at 18:10:00 UTC, Mike Wey wrote: On 04/15/2013 05:45 PM, Josh wrote: On Sunday, 14 April 2013 at 13:34:07 UTC, Mike Wey wrote: So it looks like the shemas are installed

Re: GtkD No GSettings schemas installed

2013-04-28 Thread QAston
On Monday, 15 April 2013 at 18:10:00 UTC, Mike Wey wrote: On 04/15/2013 05:45 PM, Josh wrote: On Sunday, 14 April 2013 at 13:34:07 UTC, Mike Wey wrote: So it looks like the shemas are installed properly. You could try running the gsettings app from a different location than where it's