Re: Program exited with code -11

2015-06-24 Thread weaselcat via Digitalmars-d-learn
On Wednesday, 24 June 2015 at 07:52:10 UTC, Charles Hawkins wrote: On Wednesday, 24 June 2015 at 06:54:57 UTC, weaselcat wrote: On Tuesday, 23 June 2015 at 06:50:28 UTC, Charles Hawkins wrote: [...] you can instruct dub to use other compilers with the --compiler option valid options include

Re: Program exited with code -11

2015-06-23 Thread weaselcat via Digitalmars-d-learn
On Tuesday, 23 June 2015 at 06:50:28 UTC, Charles Hawkins wrote: On Tuesday, 23 June 2015 at 03:31:37 UTC, weaselcat wrote: On Tuesday, 23 June 2015 at 03:29:14 UTC, Charles Hawkins wrote: [...] Try to compile with either ldc or gdc and the -g flag, it should give you a backtrace. dmd seems

Re: Program exited with code -11

2015-06-22 Thread weaselcat via Digitalmars-d-learn
On Tuesday, 23 June 2015 at 03:29:14 UTC, Charles Hawkins wrote: Thanks, Adam. I'm coming from OCaml and haven't seen a seg fault in years. Didn't recognize it. :D Hopefully I can figure it out from here. Try to compile with either ldc or gdc and the -g flag, it should give you a backtrace

Re: Does anyone get line numbers in stack traces on Linux?

2015-06-17 Thread weaselcat via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 07:53:16 UTC, Atila Neves wrote: I thought it was because I was weird and I use gold as my linker, but ld.bfd produced the same results. The most I could find in bug reports was someone complaining it used to work but the consensus was that it never did? Atila

Re: Does anyone get line numbers in stack traces on Linux?

2015-06-17 Thread weaselcat via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 11:07:29 UTC, weaselcat wrote: On Wednesday, 17 June 2015 at 07:53:16 UTC, Atila Neves wrote: I thought it was because I was weird and I use gold as my linker, but ld.bfd produced the same results. The most I could find in bug reports was someone complaining it use

Re: AMD & Windows 7

2015-06-12 Thread weaselcat via Digitalmars-d-learn
On Friday, 12 June 2015 at 10:54:46 UTC, Chris wrote: Has anyone run into problems with D on AMD processors? I'm talking about Windows 7 on a HP625 laptop in particular. Can you be any more specific? What kind of problems?

Re: Shortest way to allocate an array and initialize it with a specific value.

2015-06-11 Thread weaselcat via Digitalmars-d-learn
On Thursday, 11 June 2015 at 07:57:47 UTC, Per Nordlöw wrote: On Wednesday, 10 June 2015 at 22:03:52 UTC, Ali Çehreli wrote: Another option: void main() { auto a2 = new ubyte[5]; But this causes an extra zero-initialization of a2. just an fyi, gdc optimizes this away(looks like it overwr

Re: Utf8 to Utf32 cast cost

2015-06-08 Thread weaselcat via Digitalmars-d-learn
On Monday, 8 June 2015 at 10:49:59 UTC, Ilya Yaroshenko wrote: On Monday, 8 June 2015 at 10:42:00 UTC, Kadir Erdem Demir wrote: I want to use my char array with awesome, cool std.algorithm functions. Since many of this algorithms requires like slicing etc.. I prefer to create my string with Utf

Re: Python's features, which requires D

2015-05-23 Thread weaselcat via Digitalmars-d-learn
On Friday, 22 May 2015 at 00:23:30 UTC, Dennis Ritchie wrote: Hi, I've collected some of Python's features. It seems to me that they are not in the D! Surely all this is in the D? :) http://rextester.com/CNQQR After another review, I think some of these conversions to D could be express

Re: Dual conditions in D and Python

2015-05-23 Thread weaselcat via Digitalmars-d-learn
On Saturday, 23 May 2015 at 17:17:17 UTC, Andrei Alexandrescu wrote: On 5/21/15 2:35 PM, Ali Çehreli wrote: On 05/21/2015 12:44 PM, Meta wrote: All we need is user-defined opIs and then we're really cooking with gas. if (5 is between(4, 6)) { //... } We're almost there. :) bool is_be

Re: How to append range to array?

2015-05-23 Thread weaselcat via Digitalmars-d-learn
On Saturday, 23 May 2015 at 07:03:35 UTC, Vladimir Panteleev wrote: int[] arr = [1, 2, 3]; auto r = iota(4, 10); // ??? assert(equal(arr, iota(1, 10))); import std.array : array; arr ~ r.array;

Re: How to append range to array?

2015-05-23 Thread weaselcat via Digitalmars-d-learn
On Saturday, 23 May 2015 at 08:35:45 UTC, weaselcat wrote: On Saturday, 23 May 2015 at 07:03:35 UTC, Vladimir Panteleev wrote: int[] arr = [1, 2, 3]; auto r = iota(4, 10); // ??? assert(equal(arr, iota(1, 10))); import std.array : array; arr ~ r.array; woops, meant ~= but this is probably f

Re: opIndex vs. opSlice for empty slices

2015-05-21 Thread weaselcat via Digitalmars-d-learn
On Friday, 22 May 2015 at 05:47:28 UTC, Mike Parker wrote: I've always used opSlice to produce empty slices, but having recently read the documentation at [1], I see this: "To overload a[], simply define opIndex with no parameters:" And no mention that opSlice can fill the same role. Am I righ

Re: Python's features, which requires D

2015-05-21 Thread weaselcat via Digitalmars-d-learn
On Friday, 22 May 2015 at 01:52:30 UTC, Dennis Ritchie wrote: On Friday, 22 May 2015 at 01:17:17 UTC, weaselcat wrote: D doesn't have list comprehensions, so it's difficult to directly port these. I can not imagine how difficult it is to implement it in D, but I'm pretty sure that nested for

Re: Python's features, which requires D

2015-05-21 Thread weaselcat via Digitalmars-d-learn
On Friday, 22 May 2015 at 00:23:30 UTC, Dennis Ritchie wrote: Hi, I've collected some of Python's features. It seems to me that they are not in the D! Surely all this is in the D? :) http://rextester.com/CNQQR D doesn't have list comprehensions, so it's difficult to directly port these.

Re: fwiw - quora on stroustrup/static if/D

2015-05-21 Thread weaselcat via Digitalmars-d-learn
On Thursday, 21 May 2015 at 17:36:00 UTC, Laeeth Isharc wrote: https://www.quora.com/What-does-Bjarne-Stroustrup-think-about-different-programming-languages The C++ standard committee already reviewed static_if IIRC Andrei and Walter said they were being incredibly unfair. http://forum.dlang.

Re: Dual conditions in D and Python

2015-05-21 Thread weaselcat via Digitalmars-d-learn
On Thursday, 21 May 2015 at 23:14:47 UTC, Dennis Ritchie wrote: On Thursday, 21 May 2015 at 21:35:22 UTC, Ali Çehreli wrote: We're almost there. :) bool is_between(T0, T1, T2)(T0 what, T1 min, T2 max) { return (what >= min) && (what <= max); } void main() { if (5.is_between(4, 6)) {

Re: functors with template lambdas

2015-05-15 Thread weaselcat via Digitalmars-d-learn
On Saturday, 16 May 2015 at 02:04:39 UTC, Vlad Levenfeld wrote: I think this code should be allowed, but it isn't: struct Functor (T) { T a; auto ref fmap (alias f)() { return Functor (f(a));

Re: functors with template lambdas

2015-05-15 Thread weaselcat via Digitalmars-d-learn
On Saturday, 16 May 2015 at 02:06:45 UTC, weaselcat wrote: very long standing compiler bug https://issues.dlang.org/show_bug.cgi?id=3051 see also https://issues.dlang.org/show_bug.cgi?id=5710 unsure if they're duplicate bugs, never really looked into it.

Re: problem with parallel foreach

2015-05-13 Thread weaselcat via Digitalmars-d-learn
On Wednesday, 13 May 2015 at 09:01:05 UTC, Gerald Jansen wrote: On Wednesday, 13 May 2015 at 03:19:17 UTC, thedeemon wrote: In case of Python's parallel.Pool() separate processes do the work without any synchronization issues. In case of D's std.parallelism it's just threads inside one process

Re: Cannot find -lphobos

2015-05-10 Thread weaselcat via Digitalmars-d-learn
On Sunday, 10 May 2015 at 14:41:17 UTC, Ali Çehreli wrote: On 05/10/2015 12:45 AM, Marko Grdinic wrote: I works just fine on Windows, but I am having difficulty figuring out what the trouble is on my Bodhi 1.4 Virtual Box. I've followed the instruction on the Codeblocks Wiki and set the paramet

Re: Memory usage tracking

2015-05-10 Thread weaselcat via Digitalmars-d-learn
On Sunday, 10 May 2015 at 10:43:37 UTC, tcak wrote: On Sunday, 10 May 2015 at 09:44:42 UTC, tcak wrote: I am testing my web server right now. I started 5 separate consoles and continuously sending request by using "curl" to it. It uses shared memory as well, thought from `ipcs -a`, I don't s

Re: Signs by which to recognize D1

2015-05-06 Thread weaselcat via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 07:56:53 UTC, Daren Scot Wilson wrote: Someone looks at a chunk of D code of murky origin. Possibly, it is old, maybe D1 not D2. Inadequately commented, believe it or not, and not other information. What are some easy to spot details in the syntax by which the on

Re: Destruction in D

2015-04-30 Thread weaselcat via Digitalmars-d-learn
On Thursday, 30 April 2015 at 20:07:11 UTC, bitwise wrote: After reading GC page in the reference, it seems that class destructors are called on a separate thread, in parallel to the main thread. Is this correct? There's no guarantee what thread will be used in the standard GC implementation

Re: Create a case-insensitive startsWith

2015-04-28 Thread weaselcat via Digitalmars-d-learn
On Tuesday, 28 April 2015 at 21:45:10 UTC, PhilipDaniels wrote: Beginner question. Given if (startsWith(input, "0x", "0X")) How do I turn that into a case-insensitive startsWith? startsWith says it takes a predicate but I can't figure out how to pass it one. The examples all use "a == b" !?

Re: std.json questions

2015-04-26 Thread weaselcat via Digitalmars-d-learn
On Sunday, 26 April 2015 at 17:14:22 UTC, extrawurst wrote: On Saturday, 25 April 2015 at 18:30:33 UTC, Baz wrote: On Saturday, 25 April 2015 at 09:56:25 UTC, tired_eyes wrote: I think this is ugly and clunky approach, what is the beautiful one? What you clearly need is a serializer: look at

Re: Structural exhaustive matching

2015-04-21 Thread weaselcat via Digitalmars-d-learn
On Wednesday, 22 April 2015 at 04:54:39 UTC, Martin Nowak wrote: On Tuesday, 21 April 2015 at 15:36:28 UTC, Jadbox wrote: What's the best equivalent to Rust's structural enum/pattern (match)ing? Is it also possible to enforce exhaustive matches? Basically, I'm curious on what the best way to do

Re: Structural exhaustive matching

2015-04-21 Thread weaselcat via Digitalmars-d-learn
On Tuesday, 21 April 2015 at 15:36:28 UTC, Jadbox wrote: What's the best equivalent to Rust's structural enum/pattern (match)ing? Is it also possible to enforce exhaustive matches? Basically, I'm curious on what the best way to do ADTs in D. D's ADTs are in std.variant, the equivalent of match

Re: Reading whitespace separated strings from stdin?

2015-04-20 Thread weaselcat via Digitalmars-d-learn
On Tuesday, 21 April 2015 at 01:31:58 UTC, TheGag96 wrote: Hi guys! I had this homework assignment for data structures that has a pretty easy solution in C++. Reading input like this... 1 2 3 # $ 4 3 * ! # 20 3 / # $ # 62 # $ 2 3 8 * + # 4 48 4 2 + / # SUM # $ 1 2 3 4 5 # R # @ ...where "@" d

Re: Maxime's micro allocation benchmark much faster ?

2015-03-31 Thread weaselcat via Digitalmars-d-learn
On Tuesday, 31 March 2015 at 20:56:09 UTC, Laeeth Isharc wrote: Trying on a different beefier machine with 2.066 and 2.067 release versions installed: 1mm allocations: 2.066: 0.844s 2.067: 0.19s 10mm allocations 2.066: 1m 17.2 s 2.067: 0m 1.15s So numbers were ballpark right before, and all

Re: using exceptions in @nogc

2015-03-30 Thread weaselcat via Digitalmars-d-learn
On Tuesday, 31 March 2015 at 03:12:42 UTC, ketmar wrote: On Tue, 31 Mar 2015 01:40:52 +, weaselcat wrote: was this ever solved? nope. there were some suggestions, but no decision was made. sigh do you know if there's an open enhancement request for this?

using exceptions in @nogc

2015-03-30 Thread weaselcat via Digitalmars-d-learn
was this ever solved? I did some research and saw static immutable ones suggested a few times, but they can't be chained AFAIK.

Re: Passing myself, a struct, as a C callback context

2015-03-29 Thread weaselcat via Digitalmars-d-learn
On Monday, 30 March 2015 at 03:02:07 UTC, Paul O'Neil wrote: On 03/29/2015 10:57 PM, weaselcat wrote: On Monday, 30 March 2015 at 02:53:36 UTC, Paul O'Neil wrote: As of dmd 2.067, doing "&this" is deprecated. where is this documented? I don't see it in the release notes. I don't see it in

Re: Passing myself, a struct, as a C callback context

2015-03-29 Thread weaselcat via Digitalmars-d-learn
On Monday, 30 March 2015 at 02:53:36 UTC, Paul O'Neil wrote: As of dmd 2.067, doing "&this" is deprecated. where is this documented? I don't see it in the release notes.

Re: D's type classes pattern ?

2015-03-24 Thread weaselcat via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 15:51:00 UTC, matovitch wrote: Hi, It's been a long time since I coded some d code... sorry I take the lazy way asking for advices. :D Lets say I want to implement some generic algorithm. I would like to checks the types passed to my algorithm implements a specifi

Re: Template reference parameter

2015-03-23 Thread weaselcat via Digitalmars-d-learn
On Monday, 23 March 2015 at 22:39:28 UTC, rumbu wrote: I have only one template and I think it's impossible to define specializations since it's supposed that a random member of A... will be passed sometime by reference: auto ref? http://dlang.org/template.html#auto-ref-parameters

Re: final methods by default

2015-03-20 Thread weaselcat via Digitalmars-d-learn
On Friday, 20 March 2015 at 14:25:22 UTC, ref2401 wrote: Why aren't methods of class final by default? history use final class, it should devirtualize all methods. see: https://github.com/D-Programming-Language/dmd/pull/4427

Re: get from tuple by type

2015-03-15 Thread weaselcat via Digitalmars-d-learn
On Sunday, 15 March 2015 at 22:21:04 UTC, ketmar wrote: On Sun, 15 Mar 2015 21:59:16 +, Charles Cooper wrote: C++14 has: template constexpr T& get(tuple& t); Which allows you to get a member of the tuple struct by type. Is there an idiomatic / library way to do this in D? Preferably by i

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread weaselcat via Digitalmars-d-learn
On Saturday, 14 March 2015 at 23:46:28 UTC, Ellery Newcomer wrote: And C# has LINQ, which when combined with the last point is fricken awesome. what does LINQ offer that UFCS-style functional programming does not?

Re: Memoization in compile-time

2015-03-13 Thread weaselcat via Digitalmars-d-learn
On Friday, 13 March 2015 at 12:49:48 UTC, Dennis Ritchie wrote: On Friday, 13 March 2015 at 02:38:18 UTC, Rikki Cattermole wrote: You could assign it to e.g. an enum. Or force it over using meta-programming. And this code can be rewritten to D? template struct Factorial { enum { value =

Re: Memoization in compile-time

2015-03-13 Thread weaselcat via Digitalmars-d-learn
On Friday, 13 March 2015 at 13:16:27 UTC, weaselcat wrote: On Friday, 13 March 2015 at 12:49:48 UTC, Dennis Ritchie wrote: On Friday, 13 March 2015 at 02:38:18 UTC, Rikki Cattermole wrote: You could assign it to e.g. an enum. Or force it over using meta-programming. And this code can be rewri

Re: moving from c++ to D is easy?

2015-03-12 Thread weaselcat via Digitalmars-d-learn
On Thursday, 12 March 2015 at 13:01:31 UTC, ayush wrote: Is D a lot like c++ ? I am currently midway through learning c++ and I also want to learn D . So should i focus on one or learn both together? Will I find learning D easy if I already know c++ ? D is very much like C++, but the biggest

Re: auto function attributes based on type

2015-03-11 Thread weaselcat via Digitalmars-d-learn
On Thursday, 12 March 2015 at 05:01:50 UTC, amber wrote: On Thursday, 12 March 2015 at 04:51:42 UTC, amber wrote: On Thursday, 12 March 2015 at 04:04:28 UTC, weaselcat wrote: On Thursday, 12 March 2015 at 03:12:15 UTC, amber wrote: ... http://dlang.org/function.html#function-attribute-inferenc

Re: auto function attributes based on type

2015-03-11 Thread weaselcat via Digitalmars-d-learn
On Thursday, 12 March 2015 at 03:12:15 UTC, amber wrote: ... http://dlang.org/function.html#function-attribute-inference might be a good read if you haven't read it already.

Re: is struct delete deterministic? (cf used in Unique)

2015-03-08 Thread weaselcat via Digitalmars-d-learn
On Sat, Mar 7, 2015 at 4:02 PM, weaselcat via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: On Saturday, 7 March 2015 at 23:48:39 UTC, Timothee Cour wrote: I'm a little confused about the following: clear,delete,destroy. My understanding is that clear is deprecate

Re: is struct delete deterministic? (cf used in Unique)

2015-03-07 Thread weaselcat via Digitalmars-d-learn
On Saturday, 7 March 2015 at 23:48:39 UTC, Timothee Cour wrote: I'm a little confused about the following: clear,delete,destroy. My understanding is that clear is deprecated and delete is planned to be deprecated, so we should only ever use destroy (which deterministic calls the destructor but

Is std.signals deprecated?

2015-03-05 Thread weaselcat via Digitalmars-d-learn
Seems barely maintained and there was a proposed replacement claiming it was broken(http://wiki.dlang.org/Review/std.signal) that never got approved. Is std.signals worth using over a dub package?

Re: Will D have a serious dedicated well supported IDE like Visual Studio or Eclipse?

2015-02-26 Thread weaselcat via Digitalmars-d-learn
On Friday, 27 February 2015 at 04:12:50 UTC, AJ wrote: On Thursday, 26 February 2015 at 20:23:10 UTC, Rinzler wrote: I a beginner with D, actually I have almost done nothing. I am using a Mac, and Xamarin Studio seem to be the best choice, but I am not even able to make it auto-complete the sta

Re: What is the Correct way to Malloc in @nogc section?

2015-02-14 Thread weaselcat via Digitalmars-d-learn
On Saturday, 14 February 2015 at 06:38:19 UTC, ketmar wrote: On Sat, 14 Feb 2015 00:57:33 +, weaselcat wrote: On Friday, 13 February 2015 at 22:55:27 UTC, anonymous wrote: On Thursday, 12 February 2015 at 23:52:41 UTC, Foo wrote: This is something I've done recently. Would be glad if my c

Re: What is the Correct way to Malloc in @nogc section?

2015-02-13 Thread weaselcat via Digitalmars-d-learn
On Friday, 13 February 2015 at 22:55:27 UTC, anonymous wrote: On Thursday, 12 February 2015 at 23:52:41 UTC, Foo wrote: This is something I've done recently. Would be glad if my code will help you: https://github.com/Dgame/m3 Especially the m3.d module could be useful for you. /* Class and Str

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread weaselcat via Digitalmars-d-learn
On Thursday, 12 February 2015 at 08:33:35 UTC, Kagamin wrote: Truth be told, D has no guideline for deterministic destruction of managed resources. +1 don't complain about people wondering why class destructors don't work when there's no _real_ way to do it in D beyond 'drop down to C level

Question about scope of @nogc

2015-02-11 Thread weaselcat via Digitalmars-d-learn
(Scope might have been a bad word choice...) Is @nogc intended to only stop from calling functions that allocate with the GC, or from interacting with the GC altogether? Is there a technical reason that functions such as addrange, etc cannot be @nogc if the former since AFAIK such functions do

Re: Intended to be able to RefCount an interface?

2015-02-09 Thread weaselcat via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 05:09:00 UTC, Jakob Ovrum wrote: On Tuesday, 10 February 2015 at 04:44:55 UTC, weaselcat wrote: Thread title. interface Itest{ } class testclass : Itest{ } void main() { import std.typecons; auto test = RefCounted!Itest(new testclass()); } If you chang

Intended to be able to RefCount an interface?

2015-02-09 Thread weaselcat via Digitalmars-d-learn
Thread title. interface Itest{ } class testclass : Itest{ } void main() { import std.typecons; auto test = RefCounted!Itest(new testclass()); } If you change the refcounted to type testclass it doesn't compile because refcounted doesn't support classes. Is this a bug, or intended?

Re: How to write asia characters on console?

2015-02-07 Thread weaselcat via Digitalmars-d-learn
On Sunday, 8 February 2015 at 05:57:31 UTC, Lave Zhang wrote: Hi, My first D program is like this: --- import std.stdio; void main(string[] args) { dstring s1 = "hello你好"d; writeln(s1); } --- But the output is not corre

Re: Better native D 2D graphics library?

2015-02-07 Thread weaselcat via Digitalmars-d-learn
On Saturday, 7 February 2015 at 22:09:03 UTC, Gan wrote: Is there a better D graphics library in the works? I'm using SFML(which is very easy and has lots of features) but it seems to use a lot of ram(if you leave it running for a while on a graphic intensive scene) and trying to make it incl

Re: ubyte array to uint?

2015-02-05 Thread weaselcat via Digitalmars-d-learn
On Friday, 6 February 2015 at 05:18:45 UTC, Gan wrote: Is there a simple way of conversion? Something like: uint length = to!uint(buffer[0 .. 4]); Right now I have: uint length = *cast(uint*)buffer[0 .. 4].ptr; Which I'm not entirely sure is the correct way to do that. Hi, check out std.bitm

Re: When to use typecons.proxy vs alias this?

2015-01-24 Thread weaselcat via Digitalmars-d-learn
On Sunday, 25 January 2015 at 03:55:18 UTC, Adam D. Ruppe wrote: Use alias this if you want implicit conversions too. Proxy keeps the types separate void foo(Base b) { } struct Modified { Base b; alias b this; } foo(Modified()); //works That wouldn't work if it was proxied though, whi

When to use typecons.proxy vs alias this?

2015-01-24 Thread weaselcat via Digitalmars-d-learn
I can't find much documentation/usage of typecons.proxy, but it seems extremely similar to alias this. The documentation page( http://dlang.org/library/std/typecons/proxy.html ) doesn't really seem to elaborate on this at all.

Re: On Variable References

2015-01-21 Thread weaselcat via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 17:14:29 UTC, Meta wrote: On Wednesday, 21 January 2015 at 08:23:44 UTC, Per Nordlöw wrote: On Wednesday, 21 January 2015 at 08:22:44 UTC, Per Nordlöw wrote: int x; auto ref xr; Correction: I, of course mean, int x = 42; auto ref xr = x; Walter is

Re: simple assignment statement compiles but becomes a run time error

2015-01-18 Thread weaselcat via Digitalmars-d-learn
On Sunday, 18 January 2015 at 19:51:02 UTC, WhatMeWorry wrote: On Sunday, 18 January 2015 at 19:42:33 UTC, WhatMeWorry wrote: I've got a OpenGL function returning a pointer // const GLubyte *version = glGetString(GL_VERSION); // C++ and openLG code // the following compiles with no errors