Re: Rust piece on integer safety

2016-04-30 Thread Ed via Digitalmars-d-learn
On Saturday, 30 April 2016 at 23:11:20 UTC, Laeeth Isharc wrote: All the design/discussion/implementation of this scheme for handling integer overflow would be wasted if it didn’t actually find any bugs in practice. I personally have had quite a few bugs found nearly as I write them, with expre

Re: Are structs saved in multi-thread delegate call?

2016-04-22 Thread ed via Digitalmars-d-learn
On Saturday, 23 April 2016 at 01:11:49 UTC, Ramon wrote: mmm, I figured the problem, but don't know how to solve it. my struct has a destructor which clears itself: struct json_value { ~this() { .ValueClear(&data); } } so how I can I put a struct in the heap? (not in the stack, as is the def

Re: Auto attributes for functions

2014-08-20 Thread ed via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 09:13:15 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: On Wed, 20 Aug 2014 01:38:52 + uri via Digitalmars-d-learn wrote: Hi all, Bit new to D so this might be a very naive question... Can the compiler auto infer function attributes? I am often ad

Re: Are there desktop appications being developed in D currently?

2014-08-08 Thread ed via Digitalmars-d-learn
d in looking at. http://forum.dlang.org/thread/mailman.470.1386845003.3242.digitalmar...@puremagic.com https://github.com/FeedBackDevs/feedback Cheers, ed

Re: Kernel in D

2014-06-05 Thread ed via Digitalmars-d-learn
On Thursday, 5 June 2014 at 11:07:54 UTC, 1100110 wrote: On 6/5/14, 6:05, 1100110 wrote: On 5/31/14, 7:57, ed wrote: On Saturday, 31 May 2014 at 07:28:32 UTC, Mineko wrote: So, I've gotten interested in kernel programming in D.. And as much as I like C/C++, I wanna try innovating, I&#x

Re: Segfault in shared object when writeln

2014-06-03 Thread ed via Digitalmars-d-learn
On Wednesday, 4 June 2014 at 04:46:59 UTC, ed wrote: On Wednesday, 4 June 2014 at 03:49:25 UTC, Harpo wrote: Hello I am having the following problem. I am trying to turn a program I have written into a shared object. I have ran into some problems however. When I use writeln instead of printf

Re: Segfault in shared object when writeln

2014-06-03 Thread ed via Digitalmars-d-learn
writeln requires the D runtime to be initialised. Check out http://dlang.org/phobos/core_runtime.html#.Runtime.initialize http://dlang.org/phobos/core_runtime.html#.Runtime.terminate Cheers, ed Cheers, ed

Re: Kernel in D

2014-05-31 Thread ed via Digitalmars-d-learn
loader issues I was having as well. Cheers, ed

Re: DFL is the best UIcontrols for D,compare it to dwt, tkd,dtk,dlangui,anchovy......

2014-05-14 Thread ed via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 06:14:16 UTC, FrankLike wrote: On Tuesday, 13 May 2014 at 23:26:20 UTC, ed wrote: On Tuesday, 13 May 2014 at 15:20:36 UTC, FrankLike wrote: DFL is just a thin wrapper around Win32, no surprise. I've found my apps written using DFL work quite fine in Linux via

Re: DFL is the best UIcontrols for D,compare it to dwt, tkd,dtk,dlangui,anchovy......

2014-05-13 Thread ed via Digitalmars-d-learn
3. DFL uses less LOC and reduces code complexity comapred to GTK-d and DWT Then the comparison between DFL and other GUI libraries would be interesting. Cheers, ed

Template delegate/function ptr struct member

2014-05-13 Thread ed via Digitalmars-d-learn
main() { auto s1 = S(&func); auto s2 = S(&Object.classinfo.create); // s1 is S!(void* function()) // s2 is S!(Object delegate() const); } --- Is this a good idea or am I way off? Thanks, ed

Re: question about passing associative array to a function

2014-05-11 Thread ed via Digitalmars-d-learn
=%s", &aa, aa); } void main() { string[int] aa; aa[1] = "one"; writefln("[MAIN1]&aa:%s=%s", &aa, aa); func(aa); writefln("[MAIN2]&aa:%s=%s", &aa, aa); } --- It is the same as passing a C++ shared_ptr<> by value. Cheers, ed

Re: Why is SysTime.init invalid?

2014-04-03 Thread ed
On Thursday, 3 April 2014 at 06:23:40 UTC, Jonathan M Davis wrote: On Tuesday, April 01, 2014 03:54:07 Jonathan M Davis wrote: On Tuesday, April 01, 2014 05:35:28 ed wrote: > OK, lazy me just read the std.satetime article again. It > appears > the design is for no invalid values

Re: Why is SysTime.init invalid?

2014-04-01 Thread ed
On Tuesday, 1 April 2014 at 10:54:41 UTC, Jonathan M Davis wrote: On Tuesday, April 01, 2014 05:35:28 ed wrote: OK, lazy me just read the std.satetime article again. It appears the design is for no invalid values and it is currently a known limitation due to CTFE. --- d_time_nan There is no

Re: Why is SysTime.init invalid?

2014-03-31 Thread ed
. --- I would still like to know if there is a way around this so I can have my struct default init. Thanks, ed

Why is SysTime.init invalid?

2014-03-31 Thread ed
ult struct ctor so I can init the SysTime member? If this is by design I don't think it should crash. A Date/Time error is often something user code can safely recover from. Thanks, ed

Re: best D equivalent to C'stimeval

2014-03-30 Thread ed
On Monday, 31 March 2014 at 06:25:40 UTC, Jonathan M Davis wrote: On Monday, March 31, 2014 05:09:22 ed wrote: Hi, Just wondering what the best replacement for C timeval is in D. I'm looking at std.datetime.SysTime, but std.datetime is huge so I'm not sure. If you want an o

best D equivalent to C'stimeval

2014-03-30 Thread ed
Hi, Just wondering what the best replacement for C timeval is in D. I'm looking at std.datetime.SysTime, but std.datetime is huge so I'm not sure. Thanks, ed

Re: CMake for D

2014-03-24 Thread ed
://github.com/dcarp/cmake-d You beat me to it :) I was going to github my version today at work but I'll drop it now and work from your repo. Thanks setting it up! Cheers, ed

Re: CMake for D

2014-03-23 Thread ed
n for CMake+D also. Cheers, ed

Re: to! converting 1D to 2D array

2014-03-14 Thread ed
On Friday, 14 March 2014 at 19:24:21 UTC, Chris Williams wrote: It looks like you might be right after all about the code being invalid D. It could be a bug when it compiles without the cast. I filed a bug report about it, see where it leads :D Thanks, ed

Re: Array initialisation vs assignment

2014-03-14 Thread ed
On Friday, 14 March 2014 at 23:10:57 UTC, bearophile wrote: ed: void main() { int[] a = [1,2,3,4]; int[2][2] b = a; // fine, does an array copy } Is it a bug or by design? That looks like a compiler bug. You are supposed to use a cast to do an assignment like that. Bye

Array initialisation vs assignment

2014-03-14 Thread ed
it a bug or by design? (and if by design why?) Cheers, ed

Re: to! converting 1D to 2D array

2014-03-14 Thread ed
aise a new question asking why this doesn't work as I expect: int[2][2] b; b=a; Thanks for your help on this one. It has forced me to drill into the internals a bit more, which is always a good thing :) Cheers, ed

Re: to! converting 1D to 2D array

2014-03-13 Thread ed
On Friday, 14 March 2014 at 04:18:18 UTC, ed wrote: On Thursday, 13 March 2014 at 18:17:03 UTC, Chris Williams wrote: On Thursday, 13 March 2014 at 03:31:09 UTC, ed wrote: On Thursday, 13 March 2014 at 00:15:19 UTC, Chris Williams wrote: [snip] It shouldn't and probably isn't wor

Re: to! converting 1D to 2D array

2014-03-13 Thread ed
On Thursday, 13 March 2014 at 18:17:03 UTC, Chris Williams wrote: On Thursday, 13 March 2014 at 03:31:09 UTC, ed wrote: On Thursday, 13 March 2014 at 00:15:19 UTC, Chris Williams wrote: [snip] It shouldn't and probably isn't working. It is working and in fact it is in a "c

Re: to! converting 1D to 2D array

2014-03-12 Thread ed
asts work perfectly albeit a little ugly :D Cheers, ed

Re: to! converting 1D to 2D array

2014-03-12 Thread ed
the to! function. I didn't realise this until after bearophile's reply :D Thanks, ed

Re: to! converting 1D to 2D array

2014-03-11 Thread ed
On Wednesday, 12 March 2014 at 02:14:45 UTC, bearophile wrote: ed: I am trying to convert a 1D array to a 2D array If you have a dynamic array (1D), you can convert it to a dynamic array of dynamic arrays (2D) using chunks: void main() { import std.stdio, std.range, std.algorithm

to! converting 1D to 2D array

2014-03-11 Thread ed
this the case and why would it be so? If not, what is happening here? Thanks, ed

Re: Get struct template types

2014-02-04 Thread ed
On Tuesday, 4 February 2014 at 11:01:01 UTC, Jakob Ovrum wrote: On Tuesday, 4 February 2014 at 09:30:22 UTC, ed wrote: Hi, given a struct like so: struct S(alias N, T) {...} is there a way to get the template parameters of S? Something like: S.typetuple[0] == N, S.typetuple[1] == T I&#x

Re: Get struct template types

2014-02-04 Thread ed
On Tuesday, 4 February 2014 at 09:46:01 UTC, evilrat wrote: On Tuesday, 4 February 2014 at 09:39:48 UTC, evilrat wrote: On Tuesday, 4 February 2014 at 09:30:22 UTC, ed wrote: Hi, given a struct like so: struct S(alias N, T) {...} is there a way to get the template parameters of S? Something

Get struct template types

2014-02-04 Thread ed
a way to do the above. Thanks, ed

Re: floating point comparison basics

2013-12-03 Thread ed
it gives the same results as approxEquals ... yay! ...only took me several hours to achieve about 10 LOC but I finally understand it Cheers, Ed

Re: floating point comparison basics

2013-12-03 Thread ed
approaches are very similar in terms of code though. Next year I have a whole semester on numerical computing, covering floating point numbers, machine imprecision and how to deal with etcI'm determined to ace that subject :D Cheers, Ed

Re: floating point comparison basics

2013-12-03 Thread ed
true;} else {return false;} Why does Phobos not check lhs < rhs? Does this imply that in some cases: approxEqual(X, Y) != approxEqual(Y, X) ?? Thanks, Ed

floating point comparison basics

2013-12-03 Thread ed
) < std::numeric_limits::min()) {} # if(fabs(x) < std::numeric_limits::epsilon()) {} # if(!(fabs(x) > 0.0)) {} # double eps = 1/(1/x); # if(!(fabs(eps) > 0.0)) {} So you can see we're all confused! Thanks, Ed PS: I have read this great article and the links it provides: http:/

Re: Sudoku Py / C++11 / D?

2012-08-15 Thread Ed McCardell
letter variable names, no whitespace, etc.) There are sudoku solvers in under 200 bytes in Perl and Python; a D version would just prove that we too can write code that looks like line noise. --Ed

Re: deimos libX11 undefined reference

2012-07-15 Thread Ed McCardell
fdef CRAY #define WORD64 #endif WORD64 should only be defined when building on a Cray. I've sent a pull request to the deimos/x11 repo. --Ed

Re: Template constraint and specializations

2012-03-23 Thread Ed McCardell
On 03/23/2012 04:14 AM, Andrej Mitrovic wrote: On 3/23/12, Ed McCardell wrote: Is there a way to write a template constraint that matches any specialization of a given type? Nope. But there are simple workarounds: class Foo(bool feature1, bool feature2) { enum _isFoo = true; } template

Template constraint and specializations

2012-03-23 Thread Ed McCardell
== Foo!(false, false)) || is(T == Foo!(false, true)) || is(T == Foo!(true, false)) || is(T == Foo!(true, true))) { // call methods of foo that don't change based on feature1/feature2 } Thanks, --Ed