Re: Auto-testing of GitHub pull requests

2013-09-25 Thread simendsjo
On Wednesday, 25 September 2013 at 06:51:44 UTC, Jacob Carlborg wrote: On 2013-09-24 18:25, Brad Roberts wrote: https://github.com/braddr/d-tester Could you add a link to this on the test results page? I always forget where this code is located. http://d.puremagic.com/test-results/

Re: Auto-testing of GitHub pull requests

2013-09-25 Thread simendsjo
On Wednesday, 25 September 2013 at 11:29:16 UTC, Jacob Carlborg wrote: On 2013-09-25 09:30, simendsjo wrote: http://d.puremagic.com/test-results/ I know where the test results are. But, what I'm forgetting is where the code is which implements these test results. I want this page: http

Decouple package modules with package interfaces

2013-09-24 Thread simendsjo
I just came across a problem where I either has a cyclic dependency, pass around three delegates, implement an interface or somehow hack some communication between two modules. A simple way would be to add an interface, but interfaces require implementations to be public. The methods should

Re: Decouple package modules with package interfaces

2013-09-24 Thread simendsjo
On Tuesday, 24 September 2013 at 07:08:24 UTC, Jonathan M Davis wrote: On Tuesday, September 24, 2013 08:54:42 simendsjo wrote: I just came across a problem where I either has a cyclic dependency, pass around three delegates, implement an interface or somehow hack some communication between two

Re: Multiline String Literals without linefeeds?

2013-09-23 Thread simendsjo
On Monday, 23 September 2013 at 09:42:59 UTC, bearophile wrote: John Carter: is there a similar mechanism in D? Or should I do... string foo = long string without linefeeds ; Genrally you should do: string foo = long ~ string ~ without ~ linefeeds;

Re: User defined attributes use

2013-09-23 Thread simendsjo
On Monday, 23 September 2013 at 07:47:32 UTC, Jacob Carlborg wrote: On 2013-09-20 16:12, simendsjo wrote: You could of course fix this in a library too. enum AttributeUsage { struct_ = 1 0, class_ = 1 1, //etc } struct attribute { AttributeUsage usage; } Then the library could give

Cannot use locat x as parameter to non-global template y

2013-09-22 Thread simendsjo
God, I hate these errors. Tried updating dmd head, and these started popping up. Now I have to move all templates out...

Re: Cannot use locat x as parameter to non-global template y

2013-09-22 Thread simendsjo
On Sunday, 22 September 2013 at 12:26:03 UTC, bearophile wrote: simendsjo: God, I hate these errors. Tried updating dmd head, and these started popping up. Now I have to move all templates out... Can you show a small example of code that gives that error? Bye, bearophile Nope. I cannot

Re: Cannot use locat x as parameter to non-global template y

2013-09-22 Thread simendsjo
On Sunday, 22 September 2013 at 12:26:03 UTC, bearophile wrote: simendsjo: God, I hate these errors. Tried updating dmd head, and these started popping up. Now I have to move all templates out... Can you show a small example of code that gives that error? Bye, bearophile dustmite

Regression or bugfix?

2013-09-22 Thread simendsjo
In 2.063.2, (T!int).stringof == T!(int). In current head, it's T!int. Even (T!(int)).stringof == T!int. So is this a regression bug or a bugfix?

Re: Cannot use locat x as parameter to non-global template y

2013-09-22 Thread simendsjo
On Sunday, 22 September 2013 at 13:36:48 UTC, simendsjo wrote: On Sunday, 22 September 2013 at 12:26:03 UTC, bearophile wrote: simendsjo: God, I hate these errors. Tried updating dmd head, and these started popping up. Now I have to move all templates out... Can you show a small example

Re: Regression or bugfix?

2013-09-22 Thread simendsjo
On Sunday, 22 September 2013 at 13:50:00 UTC, simendsjo wrote: In 2.063.2, (T!int).stringof == T!(int). In current head, it's T!int. Even (T!(int)).stringof == T!int. So is this a regression bug or a bugfix? Added a ticket so it doesn't get lost: http://d.puremagic.com/issues/show_bug.cgi

Syntax for heap allocated void initialized arrays

2013-09-21 Thread simendsjo
This is incorrect, but what is the correct syntax? The arrays page only says it's an advanced feature, but doesn't show the syntax. int[] a = new int[1](void);

Re: Syntax for heap allocated void initialized arrays

2013-09-21 Thread simendsjo
On Saturday, 21 September 2013 at 10:40:07 UTC, bearophile wrote: simendsjo: This is incorrect, but what is the correct syntax? The arrays page only says it's an advanced feature, but doesn't show the syntax. int[] a = new int[1](void); The simplest way to allocate a void-initialized GC

Is there a way to see if .init has been set by the user?

2013-09-21 Thread simendsjo
I want to know if a variable has changed .init, but I don't know if it's possible if the .init value is the same. Does anyone have a solution for this? int a; int b = 0; pragma(msg, a.init); // 0 pragma(msg, b.init); // 0 // how can I see that b has = 0?

Re: Syntax for heap allocated void initialized arrays

2013-09-21 Thread simendsjo
On Saturday, 21 September 2013 at 11:36:32 UTC, bearophile wrote: simendsjo: Thanks. uninitializedArray works well for my need. uninitializedArray is the wrong function to use in 99.9% of the times. std.array docs probably have not explained you well enough the risks of its usage. Bye

Re: Is there a way to see if .init has been set by the user?

2013-09-21 Thread simendsjo
On Saturday, 21 September 2013 at 13:55:00 UTC, Dicebot wrote: On Saturday, 21 September 2013 at 13:48:00 UTC, simendsjo wrote: On Saturday, 21 September 2013 at 13:38:44 UTC, Dicebot wrote: On Saturday, 21 September 2013 at 13:30:19 UTC, simendsjo wrote: I'm though of using if for aggregates

Re: Is there a way to see if .init has been set by the user?

2013-09-21 Thread simendsjo
On Saturday, 21 September 2013 at 15:43:11 UTC, Maxim Fomin wrote: On Saturday, 21 September 2013 at 11:13:57 UTC, simendsjo wrote: I want to know if a variable has changed .init, but I don't know if it's possible if the .init value is the same. Does anyone have a solution for this? int

Re: User defined attributes use

2013-09-20 Thread simendsjo
On Friday, 20 September 2013 at 07:57:43 UTC, Jacob Carlborg wrote: On 2013-09-20 08:59, ilya-stromberg wrote: Can I explicitly specify when I can use attribute? Something like this: @attribute(field) struct matches(string mustMatch) { } string wrongAttribute { } class Foo {

Re: User defined attributes use

2013-09-16 Thread simendsjo
On Monday, 16 September 2013 at 06:47:40 UTC, ilya-stromberg wrote: On Sunday, 15 September 2013 at 18:31:40 UTC, simendsjo wrote: On Sunday, 15 September 2013 at 17:34:06 UTC, matovitch wrote: Hi everyone, I read the documentation about user defined attributes, but I don't see their uses

Re: User defined attributes use

2013-09-16 Thread simendsjo
On Monday, 16 September 2013 at 10:29:12 UTC, matovitch wrote: All your examples are great, thank you ! Is there a way to omit validate such that the compiler would call it implicitly ? For example : class C { ... } void fun(@nonNull C c) { ... }; C c; fun(c); //compilation error since

Re: User defined attributes use

2013-09-15 Thread simendsjo
On Sunday, 15 September 2013 at 17:34:06 UTC, matovitch wrote: Hi everyone, I read the documentation about user defined attributes, but I don't see their uses. Ok, it'a a template expression you can link to a declaration, but what are they useful for ? (not sure about the syntax ;-)) Can

Dustmiting compiler crash on windows

2013-09-14 Thread simendsjo
Ref: http://d.puremagic.com/issues/show_bug.cgi?id=11022 I'm trying to dustmite a compiler crash (with assertion), but on windows, *every* time the compiler crashes, I get a dialog stating abnormal program termination. This means I have to sit at my computer pressing space every time

Re: Dustmiting compiler crash on windows

2013-09-14 Thread simendsjo
On Saturday, 14 September 2013 at 09:32:09 UTC, simendsjo wrote: Ref: http://d.puremagic.com/issues/show_bug.cgi?id=11022 I'm trying to dustmite a compiler crash (with assertion), but on windows, *every* time the compiler crashes, I get a dialog stating abnormal program termination

Re: Get constructor for a class

2013-09-14 Thread simendsjo
On Saturday, 14 September 2013 at 11:00:26 UTC, Jacob Carlborg wrote: On 2013-09-14 00:10, simendsjo wrote: But I doubt many people here agree D2 is in beta and will allow breaking existing code in ways that changing the aforementioned features would do. DMD breaks code in every single

Re: What is the preferred method for testing the existence of a key in an associative array?

2013-09-14 Thread simendsjo
On Saturday, 14 September 2013 at 10:50:17 UTC, Jacob Carlborg wrote: On 2013-09-13 16:17, Orvid King wrote: Well, I usually do it as: int[string] someCache; int getValue(string key) { if (auto val = key in someCache) return *val; return someCache[key] = -3; } That doesn't

Errors compiling in release mode (phobos bug..?)

2013-09-14 Thread simendsjo
Compiling with --build=unittest and debug works, but not --build=release: $ dub build --build=debug Checking dependencies in 'C:\code\d\myapp' Building configuration application, build type debug Copying files... Running dmd (compile)... Compiling diet template 'about.dt' (compat)... Linking...

Re: Get constructor for a class

2013-09-14 Thread simendsjo
On Saturday, 14 September 2013 at 11:45:38 UTC, Namespace wrote: On Saturday, 14 September 2013 at 11:29:33 UTC, simendsjo wrote: On Saturday, 14 September 2013 at 11:00:26 UTC, Jacob Carlborg wrote: On 2013-09-14 00:10, simendsjo wrote: But I doubt many people here agree D2 is in beta

Re: What does __parameters return?

2013-09-13 Thread simendsjo
On Thursday, 12 September 2013 at 21:33:48 UTC, Andrej Mitrovic wrote: On 9/12/13, simendsjo simend...@gmail.com wrote: Thanks. I just ended up using both is(__parameters and is(function to fetch the parameter names. Sometimes it seems things are added to D without a very thorough design phase

Get constructor for a class

2013-09-13 Thread simendsjo
allMembers returns this, but trying to get this or __ctor using getMember fails. Is there any way to get this method?

Re: What does __parameters return?

2013-09-13 Thread simendsjo
On Friday, 13 September 2013 at 07:42:48 UTC, Jacob Carlborg wrote: On 2013-09-13 08:33, simendsjo wrote: Didn't know you could call __traits(identifier for the __parameter values. __parameters is practically undocumented, and doesn't even have an example. It's documented here: http

DMD crashes without giving any info

2013-09-13 Thread simendsjo
What should I do when DMD keeps crashing and doesn't give me any output? I'm using dmd 2.063.2 on win8. This is all that -v gives me before crashing.. binaryC:\dmd\windows\bin\dmd.exe version v2.063.2 configC:\dmd\windows\bin\sc.ini parse app I've tried compiling just object

Re: DMD crashes without giving any info

2013-09-13 Thread simendsjo
On Friday, 13 September 2013 at 12:45:06 UTC, nazriel wrote: On Friday, 13 September 2013 at 12:41:44 UTC, simendsjo wrote: What should I do when DMD keeps crashing and doesn't give me any output? I'm using dmd 2.063.2 on win8. This is all that -v gives me before crashing.. binaryC:\dmd

Re: DMD crashes without giving any info

2013-09-13 Thread simendsjo
On Friday, 13 September 2013 at 12:53:17 UTC, bearophile wrote: simendsjo: What should I do when DMD keeps crashing and doesn't give me any output? I suggest to look for stack overflows in the program (and/or increase the stack space). Since some time it has stopped giving a stack overflow

Re: Get constructor for a class

2013-09-13 Thread simendsjo
On Friday, 13 September 2013 at 13:16:12 UTC, Gary Willoughby wrote: On Friday, 13 September 2013 at 09:12:53 UTC, simendsjo wrote: allMembers returns this, but trying to get this or __ctor using getMember fails. Is there any way to get this method? foreach (func; __traits(getOverloads, T

Re: DMD crashes without giving any info

2013-09-13 Thread simendsjo
On Friday, 13 September 2013 at 12:45:06 UTC, nazriel wrote: On Friday, 13 September 2013 at 12:41:44 UTC, simendsjo wrote: (...) Is there any way to get more verbose info from dmd? Run it via GDB, OllyDBG, [putyourfavouritedebugerhere] The error is Access Violation when reading 0004

Re: DMD crashes without giving any info

2013-09-13 Thread simendsjo
Added a bug report: http://d.puremagic.com/issues/show_bug.cgi?id=11023

Re: Get constructor for a class

2013-09-13 Thread simendsjo
On Friday, 13 September 2013 at 14:02:15 UTC, Gary Willoughby wrote: On Friday, 13 September 2013 at 13:31:34 UTC, simendsjo wrote: On Friday, 13 September 2013 at 13:16:12 UTC, Gary Willoughby wrote: On Friday, 13 September 2013 at 09:12:53 UTC, simendsjo wrote: allMembers returns

Re: Get constructor for a class

2013-09-13 Thread simendsjo
On Friday, 13 September 2013 at 15:27:42 UTC, Namespace wrote: On Friday, 13 September 2013 at 15:16:36 UTC, H. S. Teoh wrote: On Fri, Sep 13, 2013 at 04:16:30PM +0200, simendsjo wrote: On Friday, 13 September 2013 at 14:02:15 UTC, Gary Willoughby wrote: [...] (...) The syntax

What does __parameters return?

2013-09-12 Thread simendsjo
The documentation says the parameter tuple of a function, delegate, or function pointer. This includes the parameter types, names, and default values. .. but what type is it? Error: argument (int i, char c, string s, bool b = false) to typeof is not an expression How am I supposed to get

Cannot access frame of insert whatever here

2013-09-12 Thread simendsjo
I haven't done any D coding since May, but picked up my little toy code again now. Last time I had a lot of hassle with not being able to store/access symbols through templates, and I got the same thing now. Am I the only one hitting these all the time? I'm basically playing around with

Re: What does __parameters return?

2013-09-12 Thread simendsjo
On Thursday, 12 September 2013 at 19:41:26 UTC, H. S. Teoh wrote: On Thu, Sep 12, 2013 at 08:44:29PM +0200, simendsjo wrote: (...) .. but what type is it? Error: argument (int i, char c, string s, bool b = false) to typeof is not an expression How am I supposed to get the parameter names

cast(size_t)c != 0, but c is null

2013-05-14 Thread simendsjo
Very newbie question coming up :) How does D mark null values for classes? `c is null` returns true, but `c` isn't 0. So how does D know `c is null`? class C {} C c; assert(c is null); assert(cast(size_t)c == 0); // fails.

Re: cast(size_t)c != 0, but c is null

2013-05-14 Thread simendsjo
On Tuesday, 14 May 2013 at 12:20:00 UTC, Andrej Mitrovic wrote: On Tuesday, 14 May 2013 at 12:18:20 UTC, simendsjo wrote: Very newbie question coming up :) How does D mark null values for classes? `c is null` returns true, but `c` isn't 0. So how does D know `c is null`? class C {} C c

Re: mysql

2013-04-18 Thread simendsjo
On Tuesday, 16 April 2013 at 21:09:42 UTC, gedaiu wrote: On Monday, 15 April 2013 at 19:25:19 UTC, simendsjo wrote: On Monday, 15 April 2013 at 17:34:07 UTC, gedaiu wrote: Hi, Can anyone help me to connect to mysql from D? Thanks! You can use Steve Teales native library. The most up

Re: mysql

2013-04-15 Thread simendsjo
On Monday, 15 April 2013 at 17:34:07 UTC, gedaiu wrote: Hi, Can anyone help me to connect to mysql from D? Thanks! You can use Steve Teales native library. The most up-to-date version is here: https://github.com/rejectedsoftware/mysql-native It relies on vibes async sockets though. You'll

CTFE cannot be used when a struct has uninitialized static array union members?

2013-04-14 Thread simendsjo
This is probably not a minimal test-case, and I haven't tested with more types, but it shows the problem. // This works struct S { this(int i) { a = i; } union { int a = void; int b = void; } } unittest { auto s = S(1); assert(s.a == s.b);

Re: CTFE cannot be used when a struct has uninitialized static array union members?

2013-04-14 Thread simendsjo
Filed a bug. http://d.puremagic.com/issues/show_bug.cgi?id=9932

Re: Vector operations cannot be nothrow?

2013-04-14 Thread simendsjo
On Saturday, 13 April 2013 at 19:11:42 UTC, bearophile wrote: simendsjo: void f() nothrow { // Error: _arrayExpSliceAddass_i is not nothrow int[3] d; d[] += 3; } Currently those ops are not nothrow. I think they will eventually become nothrow... Bye, bearophile

Vector operations cannot be nothrow?

2013-04-13 Thread simendsjo
void f() nothrow { // Error: _arrayExpSliceAddass_i is not nothrow int[3] d; d[] += 3; }

Re: recursive equal, and firstDifference functions

2013-03-19 Thread simendsjo
On Tuesday, 19 March 2013 at 08:25:45 UTC, timotheecour wrote: we need a std.algorithm.equalRecurse(T1,T2)(T1 a, T2 b) that compares recursively a and b; its behavior should be: if opEqual is defined, call it else, if its a range, call std.algorithm.equal (ie compare nb elements, then each

this member for structs with methods

2013-03-17 Thread simendsjo
When a struct contains methods, __traits(allMembers reports a member called this. What is this? void main() { struct S { int i; } struct A { int i; void f() {} } pragma(msg, __traits(allMembers, S)); // i pragma(msg, __traits(allMembers, A)); // i, f, this }

template cannot use local as parameter to non-global template

2013-03-17 Thread simendsjo
I get a lot of these errors, and they can be quite tricky to get around and hurts my API.. Is this a temporary restriction in DMD, or is it another reason why this doesn't work? Error: template instance template!local cannot use local 'local' as parameter to non-global template

Re: this member for structs with methods

2013-03-17 Thread simendsjo
On Sunday, 17 March 2013 at 13:30:29 UTC, Maxim Fomin wrote: On Sunday, 17 March 2013 at 12:16:08 UTC, simendsjo wrote: When a struct contains methods, __traits(allMembers reports a member called this. What is this? void main() { struct S { int i; } struct A { int i; void f

Re: UDA status

2013-03-17 Thread simendsjo
On Sunday, 17 March 2013 at 14:46:59 UTC, Jacob Carlborg wrote: On 2013-03-11 21:41, simendsjo wrote: Some update.. Using a custom Tuple(T...) makes things a bit smoother. Here's my first working test with two templates: hasAttr to see if an attribute exists, and attrOfType to get all

Re: template cannot use local as parameter to non-global template

2013-03-17 Thread simendsjo
On Sunday, 17 March 2013 at 15:45:54 UTC, Timon Gehr wrote: On 03/17/2013 01:54 PM, simendsjo wrote: I get a lot of these errors, and they can be quite tricky to get around and hurts my API.. Is this a temporary restriction in DMD, or is it another reason why this doesn't work? Error

Re: template cannot use local as parameter to non-global template

2013-03-17 Thread simendsjo
On Sunday, 17 March 2013 at 16:21:25 UTC, Timon Gehr wrote: On 03/17/2013 05:15 PM, simendsjo wrote: On Sunday, 17 March 2013 at 15:45:54 UTC, Timon Gehr wrote: On 03/17/2013 01:54 PM, simendsjo wrote: I get a lot of these errors, and they can be quite tricky to get around and hurts my API

template instance is nested in both A and B

2013-03-17 Thread simendsjo
Anyone have any idea what this means? Error: template instance TupleWrapper!(i, i) TupleWrapper!(i, i) is nested in both S and D I don't have a minimal testcase, but I can try to create one if it's difficult to see otherwise.

.stringof might call function?

2013-03-16 Thread simendsjo
Why is the function called in the template at the line of .stringof? template t(alias fn) { static if(fn.stringof) // f(int i) isn't callable using () enum t = true; else enum t = false; } void main() { void f(int i) {} t!f; }

Re: .stringof might call function?

2013-03-16 Thread simendsjo
On Saturday, 16 March 2013 at 13:01:44 UTC, simendsjo wrote: Why is the function called in the template at the line of .stringof? template t(alias fn) { static if(fn.stringof) // f(int i) isn't callable using () enum t = true; else enum t = false; } void main

-cov doesn't check templated code

2013-03-14 Thread simendsjo
Code coverage doesn't work with templates. Is this by design? t.d: module t; template t(T) { static if(is(T == int)) alias int t; else static if(is(T == short)) alias short t; } unittest { t!int a = 10; assert(a == 10); }

Re: -cov doesn't check templated code

2013-03-14 Thread simendsjo
On Thursday, 14 March 2013 at 16:09:01 UTC, bearophile wrote: simendsjo: Code coverage doesn't work with templates. Is this by design? A code coverage tells how many time a line of code is run at run-time. But your template contains no code that is run at run-time. So you are looking

Re: -cov doesn't check templated code

2013-03-14 Thread simendsjo
On Thursday, 14 March 2013 at 16:26:21 UTC, bearophile wrote: simendsjo: Would be nice to easily see that the templates are being tested more properly though. Then add an enhancement request in bugzilla. Maybe there is a way to implement it. I remember someone asking for a compiler switch

Re: Passing several tuples (T...) to templates without expanding them

2013-03-13 Thread simendsjo
On Wednesday, 13 March 2013 at 11:21:53 UTC, simendsjo wrote: On Wednesday, 13 March 2013 at 11:13:55 UTC, monarch_dodra wrote: On Wednesday, 13 March 2013 at 10:34:14 UTC, simendsjo wrote: Say you have a tuple type: struct Tuple(T...) { alias T Tuple; } and a template template t

Re: What do you use to generate documentation?

2013-03-13 Thread simendsjo
On Wednesday, 13 March 2013 at 09:35:18 UTC, Andrea Fontana wrote: I've tried to build documentation using ddoc format and dmd. dmd -c -D -o- ... Generated documentation looks ugly and without stylesheet. Am I wrong? I expected a phobos-like documentation. So, what do you use to generate

Passing several tuples (T...) to templates without expanding them

2013-03-13 Thread simendsjo
Say you have a tuple type: struct Tuple(T...) { alias T Tuple; } and a template template t(alias A, alias B) { // something something } Given alias Tuple!(int, 1) A; alias Tuple!(int, 1) B; Is it possible to send this to template t as follows t!(A,

Re: Passing several tuples (T...) to templates without expanding them

2013-03-13 Thread simendsjo
On Wednesday, 13 March 2013 at 15:49:06 UTC, jerro wrote: and a template template t(alias A, alias B) { // something something } Given alias Tuple!(int, 1) A; alias Tuple!(int, 1) B; Is it possible to send this to template t as follows t!(A, B) without it expanding to t!(int, 1, int, 1) ?

Re: GC, memory leaks and 32/64 bit

2013-03-12 Thread simendsjo
On Tuesday, 12 March 2013 at 14:21:06 UTC, bearophile wrote: Benjamin Thaut: Thats not correct. Rainer Schuetze has finished it and is using it for VisualD. You can get a version of druntime which the percise GC from his github branch https://github.com/rainers/dmd I am glad to be wrong

UDA status

2013-03-11 Thread simendsjo
I've been trying UDAs today, but I'm hitting roadblocks all the time.. For instance: @(10) struct A; pragma(msg, __traits(getAttributes, A)); // Empty @(10) struct B {} pragma(msg, __traits(getAttributes, B)); // tuple(10) I've encountered several other things that has been

Re: UDA status

2013-03-11 Thread simendsjo
On Monday, 11 March 2013 at 19:03:49 UTC, simendsjo wrote: I've been trying UDAs today, but I'm hitting roadblocks all the time.. For instance: @(10) struct A; pragma(msg, __traits(getAttributes, A)); // Empty @(10) struct B {} pragma(msg, __traits(getAttributes, B)); // tuple

valgrind

2013-03-10 Thread simendsjo
I haven't used valgrind/cachegrind on C/C++ programs before, but I'm pretty sure it doesn't behave as expected on D code. I found this page to fix the mangling issue: http://wiki.dlang.org/Other_Dev_Tools, but all callgraphs is empty.

Re: valgrind

2013-03-10 Thread simendsjo
On Sunday, 10 March 2013 at 11:06:41 UTC, simendsjo wrote: I haven't used valgrind/cachegrind on C/C++ programs before, but I'm pretty sure it doesn't behave as expected on D code. I found this page to fix the mangling issue: http://wiki.dlang.org/Other_Dev_Tools, but all callgraphs is empty

Re: valgrind

2013-03-10 Thread simendsjo
On Sunday, 10 March 2013 at 11:58:39 UTC, Druzhinin Alexandr wrote: On 10.03.2013 18:11, simendsjo wrote: On Sunday, 10 March 2013 at 11:06:41 UTC, simendsjo wrote: I haven't used valgrind/cachegrind on C/C++ programs before, but I'm pretty sure it doesn't behave as expected on D code. I found

Re: Why don't underscores in numbers enforce proper formatting?

2013-03-06 Thread simendsjo
On Wednesday, 6 March 2013 at 21:06:43 UTC, ixid wrote: The underscores in values such as 1_000_000 aid readability but DMD doesn't see anything wrong with any placement of underscores as long as they follow a number. Is there any reason to allow uses like 1_00_000, which are typos or

Re: Using char* and C code

2013-03-06 Thread simendsjo
On Thursday, 7 March 2013 at 07:20:16 UTC, Jeremy DeHaan wrote: That's what toStringz is for, and it'll avoid appending the '\0' if it can (e.g. if the code unit one past the end of the string is '\0' as it is with string literals). I actually have a different question related to this

Re: __traits(compiles) + mixin

2013-03-05 Thread simendsjo
On Tuesday, 5 March 2013 at 08:09:37 UTC, cal wrote: On Tuesday, 5 March 2013 at 08:04:12 UTC, Andrej Mitrovic wrote: You can't test declarations inside of __traits(compiles), only expressions. It's in the docs: http://dlang.org/traits.html#compiles So why does this work: import std.conv;

Re: __traits(compiles) + mixin

2013-03-05 Thread simendsjo
On Tuesday, 5 March 2013 at 08:04:12 UTC, Andrej Mitrovic wrote: On Tuesday, 5 March 2013 at 07:53:15 UTC, cal wrote: I'm confused about this: import std.conv; void main() { enum s = `1`.to!int;; enum c = __traits(compiles, mixin({auto a = new ~s~;})); // line 1 mixin(auto a =

Interval type

2013-03-03 Thread simendsjo
I seem to remember phobos has an interval type so you can specify: Interval!((], 0, 10) myvalue; Interval!((0,10]) myvalue; // or perhaps like this.. and get enforce(value 0 value = 10); added automatically. I'm unable to find it though.. Is my memory playing tricks on me?

What xml libraries are people using?

2013-03-02 Thread simendsjo
Everyone says Don't use std.xml, and there are several other libraries. Which can you recommend? (I haven't looked closely at any of them, just some links found by googling) https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/dom.d

Ctor, setters and invariant

2013-03-02 Thread simendsjo
invariant is called when a method enters. This creates problems if the constructor calls a setter: import std.exception; struct S { private int _i; public: this(int i) { this.i = i; } @property void i(int v) { enforce(v 1); _i = v; } invariant() { assert(_i 1);

Re: gui libs

2013-02-28 Thread simendsjo
On Thursday, 28 February 2013 at 09:35:03 UTC, rho wrote: hi, what keeps me from using d, is that there is no compilable gui lib available. does dfl compile with the latest dmd? http://wiki.dlang.org/Libraries_and_Frameworks#GUI_Libraries I haven't used any of them in a while, but I think at

PostgreSQL driver

2013-02-25 Thread simendsjo
Does anyone have any experience using PostgreSQL with D? I've found several libraries, but I'm uncertain which is usable (if any..) https://github.com/zhaopuming/pqd https://github.com/denizzzka/dpq2

Re: Rang violation using AA's

2013-02-08 Thread simendsjo
On Friday, 8 February 2013 at 17:16:15 UTC, Nrgyzer wrote: Hi guys, I'm updated from DMD 2.060 to 2.061 and I just run into some trouble by using associative arrays. Let's say I've the following few lines: string[string] myValues; ref string getValue(string v) { return myValues[v]; }

Re: How to translate C# 'readonly' keyword into D

2013-02-04 Thread simendsjo
On Monday, 4 February 2013 at 09:02:31 UTC, o3o wrote: I'm a C# programmer, when I apply IoC pattern I use readonly keyword (http://msdn.microsoft.com/en-us/library/acdd6hb7%28v=vs.71%29.aspx) in this manner: :// C# code :interface IFoo { : void Fun(); :} : :class Foo: IFoo { : void Fun()

Re: How to translate C# 'readonly' keyword into D

2013-02-04 Thread simendsjo
On Monday, 4 February 2013 at 10:26:55 UTC, simendsjo wrote: On Monday, 4 February 2013 at 09:02:31 UTC, o3o wrote: I'm a C# programmer, when I apply IoC pattern I use readonly keyword (http://msdn.microsoft.com/en-us/library/acdd6hb7%28v=vs.71%29.aspx) in this manner: :// C# code

Re: Why is the 'protected' attribute considered useless?

2013-01-30 Thread simendsjo
On Wednesday, 30 January 2013 at 03:38:39 UTC, Chad Joan wrote: I've read more than once now that 'protected' is considered useless in D. Why is this? I'm not sure what articles you are referring to, but a couple of points it might think of: * Anything protected can be made public by derived

Re: Scope and with

2013-01-23 Thread simendsjo
On Wednesday, 23 January 2013 at 10:30:08 UTC, Namespace wrote: But AFAIK scope isn't fully implemented as storage class, or am I wrong? I think you are right. And I think it's the reason using 'in' parameters are discouraged.

Re: Scope and with

2013-01-23 Thread simendsjo
On Wednesday, 23 January 2013 at 13:43:58 UTC, mist wrote: On Wednesday, 23 January 2013 at 10:43:24 UTC, simendsjo wrote: On Wednesday, 23 January 2013 at 10:30:08 UTC, Namespace wrote: But AFAIK scope isn't fully implemented as storage class, or am I wrong? I think you are right. And I

Re: Something like godoc

2013-01-09 Thread simendsjo
On Wednesday, 9 January 2013 at 13:42:52 UTC, MrOrdinaire wrote: Hi, In Go, I can just install the documentation and later consult it using the godoc command, e.g. `godoc fmt Println` would give the documentation for the Println Function inside the fmt package. Is there anything like that

Re: Extensions to types loaded from a C library

2012-12-14 Thread simendsjo
On Friday, 14 December 2012 at 09:30:50 UTC, Jeremy DeHaan wrote: I was playing with some code in the Derelict project(mainly the SFML portion) and was wondering what would happen if I made some changes. Here's an example of what I mean. In the C code, the struct sfVector2f is defined as

Re: Pointer to string allows assigning int[]?

2012-11-12 Thread simendsjo
On Monday, 12 November 2012 at 21:03:51 UTC, cal wrote: Is the following a bug? import std.c.string, core.memory; void* makeNew(T)() { T t = T.init; void* ptr = GC.malloc(T.sizeof); memcpy(ptr, t, T.sizeof); return ptr; } void main() { alias string T; T* iptr =

Re: How to extend built-in types

2012-10-27 Thread simendsjo
On Friday, 26 October 2012 at 16:32:29 UTC, Jonathan M Davis wrote: On Friday, October 26, 2012 15:55:34 simendsjo wrote: So.. What do I need to implement for a struct to be a valid built-in type? All valid properties (min, max etc) and operators for that type? So, you want stuff like

Re: How to extend built-in types

2012-10-27 Thread simendsjo
On Saturday, 27 October 2012 at 10:07:20 UTC, Jonathan M Davis wrote: On Saturday, October 27, 2012 11:58:57 simendsjo wrote: The thing is that I often doesn't really care about the type, only that it exposes certain properties. Then create a template constraint (or eponymous template to use

How to extend built-in types

2012-10-26 Thread simendsjo
Not sure if this is a bug or intended behavior: import std.traits; struct S { int i; T opCast(T)() if(isFloatingPoint!T) { return cast(T)i; } } template myIsFloatingPoint(T) { enum myIsFloatingPoint = isFloatingPoint!T || __traits(compiles, {

Re: Extending library functions

2012-10-18 Thread simendsjo
On Thursday, 18 October 2012 at 11:31:47 UTC, tn wrote: Hi. I want to extend math library functions to work with my own type. However, the definition for my own type seems to prevent automated access to the original function. How can I fix this unexpected behavior? Simplified example:

Re: Extending library functions

2012-10-18 Thread simendsjo
On Thursday, 18 October 2012 at 12:10:17 UTC, tn wrote: On Thursday, 18 October 2012 at 11:43:40 UTC, simendsjo wrote: On Thursday, 18 October 2012 at 11:31:47 UTC, tn wrote: (...) You need to manually add std.math.exp2 to the overload set so importing external methods doesn't hijack your

Re: Workarounds for forward reference bugs

2012-10-06 Thread simendsjo
On Friday, 5 October 2012 at 15:16:10 UTC, Don Clugston wrote: On 05/10/12 16:33, simendsjo wrote: Are there any known workarounds for forward reference bugs? I see 80 bugs is filed, but I don't want to read all of them to find any workarounds. I cannot find anything on the wiki regarding

Re: Workarounds for forward reference bugs

2012-10-06 Thread simendsjo
On Saturday, 6 October 2012 at 10:17:34 UTC, simendsjo wrote: On Friday, 5 October 2012 at 15:16:10 UTC, Don Clugston wrote: On 05/10/12 16:33, simendsjo wrote: Are there any known workarounds for forward reference bugs? I see 80 bugs is filed, but I don't want to read all of them to find any

Workarounds for forward reference bugs

2012-10-05 Thread simendsjo
Are there any known workarounds for forward reference bugs? I see 80 bugs is filed, but I don't want to read all of them to find any workarounds. I cannot find anything on the wiki regarding this. So.. Any good ideas how to get around this?

object.error: Privileged Instruction

2012-09-22 Thread simendsjo
What does the message in the subject mean? Here's a testcase (tested on dmd 2.060 on win7 32-bit): import core.exception; import core.runtime; // comment out this, and no stacktrace is printed void myAssertHandler(string file, size_t line, string msg = null) { } static this() {

<    1   2   3   4   5   6   >