Re: Idempotent partition around median of 5?

2016-02-05 Thread Xinok via Digitalmars-d
On Friday, 5 February 2016 at 17:33:55 UTC, Era Scarecrow wrote: On Friday, 5 February 2016 at 15:41:11 UTC, Fool wrote: One swap usually decomposes into three moves. Recently from reading some interesting hacks and super code, a good swap can also be done via 3 xor operations (and avoiding

Re: print function

2016-02-05 Thread cy via Digitalmars-d-learn
On Friday, 5 February 2016 at 12:35:14 UTC, Artur Skawina wrote: D's std lib implementations are sometimes really awful, but in this case it's not actually that bad: print("hi","there"); -> fwrite("hi", 1, 2, 0x7ff68d0cb640) = 2 fwrite(" ", 1, 1,

What's going to replace std.stream?

2016-02-05 Thread cy via Digitalmars-d-learn
Let's say I have a socket, and a file, and I want to send the contents of that file to the socket. What's the best way to do that? Yes I'm aware that in Linux, you can use a combination of a pipe and splice(2) to keep all buffers kernel side for that, but I was thinking more generally. The

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-05 Thread Marco Leise via Digitalmars-d-learn
Am Sat, 06 Feb 2016 04:28:17 + schrieb tsbockman : > On Friday, 5 February 2016 at 19:16:11 UTC, Marco Leise wrote: > >> > 1. Removing 'ref' from the return type > > > > Must happen. 'ref' only worked because of the reinterpreting > > cast which doesn't work in

Re: Template to create a type and instantiate it

2016-02-05 Thread Marco Leise via Digitalmars-d-learn
Mixin templates is the way to go if you want something new on every use of the template. Otherwise using the template multiple times with the same arguments will always give you the first instance. -- Marco

Re: Template to create a type and instantiate it

2016-02-05 Thread cy via Digitalmars-d-learn
On Saturday, 6 February 2016 at 06:39:27 UTC, Marco Leise wrote: using the template multiple times with the same arguments will always give you the first instance. Hmm, consider that the argument was a particular line of code though, and that's not likely to repeat. I didn't test what would

D

2016-02-05 Thread martin warnes via Digitalmars-d
A A A-B

Re: Idempotent partition around median of 5?

2016-02-05 Thread Ivan Kazmenko via Digitalmars-d
On Saturday, 6 February 2016 at 00:59:17 UTC, Andrei Alexandrescu wrote: On 02/05/2016 06:36 AM, Ivan Kazmenko wrote: Another interesting task would be to make the function stable, but I don't see how it is possible with such flat structure. Under what circumstances isn't your function

Re: Idempotent partition around median of 5?

2016-02-05 Thread Ivan Kazmenko via Digitalmars-d
On Saturday, 6 February 2016 at 07:06:27 UTC, Ivan Kazmenko wrote: On Saturday, 6 February 2016 at 00:59:17 UTC, Andrei Alexandrescu wrote: On 02/05/2016 06:36 AM, Ivan Kazmenko wrote: Another interesting task would be to make the function stable, but I don't see how it is possible with such

Re: Overloading free functions & run-time dispatch based on parameter types

2016-02-05 Thread Marc Schütz via Digitalmars-d-learn
Does the following help? import std.algorithm.comparison : castSwitch; import std.stdio; class A { } class B : A { } class C : A { } auto foo_impl(B b) { writeln("called foo(B)"); } auto foo_impl(C c) { writeln("called foo(C)"); } auto foo(A a) { return a.castSwitch!( (B

Re: Idempotent partition around median of 5?

2016-02-05 Thread tn via Digitalmars-d
On Thursday, 4 February 2016 at 20:30:57 UTC, Timon Gehr wrote: At most 6 comparisons, <=3 swaps, idempotent (optimal number of swaps): ... Inspired by this, I made four other versions of the function that are shorter but make more swaps (at most 4, 6, 7 and 8 swaps respectively). Each

Re: Idempotent partition around median of 5?

2016-02-05 Thread Ola Fosheim Grøstad via Digitalmars-d
On Friday, 5 February 2016 at 15:41:11 UTC, Fool wrote: So we can do with seven moves instead of three swaps (nine moves). ;-) Yes, well, this all breaks down when you realize that this is all completely dominated by cache misses and that you can do median more effectively using SIMD

Re: What reasons are known a thread stops suddenly?

2016-02-05 Thread Kagamin via Digitalmars-d-learn
https://dlang.org/phobos/core_thread.html#.Thread.join

Re: Idempotent partition around median of 5?

2016-02-05 Thread Era Scarecrow via Digitalmars-d
On Friday, 5 February 2016 at 15:41:11 UTC, Fool wrote: One swap usually decomposes into three moves. Recently from reading some interesting hacks and super code, a good swap can also be done via 3 xor operations (and avoiding an intermediate storage unit).

Re: Type safety could prevent nuclear war

2016-02-05 Thread H. S. Teoh via Digitalmars-d
On Fri, Feb 05, 2016 at 07:31:34AM +, tsbockman via Digitalmars-d wrote: > On Friday, 5 February 2016 at 07:05:06 UTC, H. S. Teoh wrote: > >On Fri, Feb 05, 2016 at 04:02:41AM +, tsbockman via Digitalmars-d > >wrote: > >>On Friday, 5 February 2016 at 03:46:37 UTC, Chris Wright wrote: >

Re: What reasons are known a thread stops suddenly?

2016-02-05 Thread Kagamin via Digitalmars-d-learn
Yep, munching an Error by default is pretty nasty.

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-05 Thread Marco Leise via Digitalmars-d-learn
Am Fri, 05 Feb 2016 05:31:15 + schrieb Saurabh Das : > On Friday, 5 February 2016 at 05:18:01 UTC, Saurabh Das wrote: > [...] > > Apologies for spamming. This is an improved implementation: > > @property > Tuple!(sliceSpecs!(from, to)) slice(size_t

Need some help about error that I don't understand

2016-02-05 Thread Uranuz via Digitalmars-d-learn
In my custom multithreaded web-server (non vibe-based) I got error that is strange for me. I've was looking for a reason running app under GDB, but I don't understand how to interpret what I've got. It's interesting that it fails (without any error or segfault message) in the case when null

Re: What reasons are known a thread stops suddenly?

2016-02-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/5/16 12:06 PM, Kagamin wrote: https://dlang.org/phobos/core_thread.html#.Thread.join Yeah, but in the meantime, the thread state is not cleaned up, and it's in the same memory space as everywhere else. I don't see why if you have an out-of-bounds error in the main thread, it should

Re: Need some help about error that I don't understand

2016-02-05 Thread Uranuz via Digitalmars-d-learn
On Friday, 5 February 2016 at 17:39:55 UTC, Uranuz wrote: In my custom multithreaded web-server (non vibe-based) I got error that is strange for me. I've was looking for a reason running app under GDB, but I don't understand how to interpret what I've got. It's interesting that it fails

Re: What reasons are known a thread stops suddenly?

2016-02-05 Thread Ali Çehreli via Digitalmars-d-learn
On 02/04/2016 10:41 PM, tcak wrote: > On Friday, 5 February 2016 at 06:23:09 UTC, Daniel Kozak wrote: >> V Fri, 05 Feb 2016 03:47:40 + >> tcak via Digitalmars-d-learn >> napsáno: >> >>> [...] >> >> Did you try catch Throwable instead of Exception? I was

Re: Proper Use of Assert and Enforce

2016-02-05 Thread Suliman via Digitalmars-d-learn
It is purely a way to make throwing an exception use a syntax similar to assert and save a line of code. if(!condition) throw new Exception(msg); becomes enforce(condition, msg); So enforce is just macros on top of: if(!condition) throw new Exception(msg); ?

Re: Detecting exception unwinding

2016-02-05 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Friday, 5 February 2016 at 07:31:24 UTC, cy wrote: I think you might be talking about two very different concepts here. Unwinding only happens within the context of a certain scope. The object itself is the scope (RAII). If you can test for "uncaught_exceptions" you can implement the

Re: Proper Use of Assert and Enforce

2016-02-05 Thread Ali Çehreli via Digitalmars-d-learn
On 02/05/2016 12:01 AM, Suliman wrote: It is purely a way to make throwing an exception use a syntax similar to assert and save a line of code. if(!condition) throw new Exception(msg); becomes enforce(condition, msg); So enforce is just macros on top of: if(!condition) throw new

Re: Type safety could prevent nuclear war

2016-02-05 Thread Ola Fosheim Grøstad via Digitalmars-d
On Friday, 5 February 2016 at 01:10:53 UTC, tsbockman wrote: All along I have been saying this is something that *compilers* should warn about. As far as I can recall, I never suggested using linters, sanitizers, changing the C standard - or even compiler plugins. Well, compilers "should"

Re: Type safety could prevent nuclear war

2016-02-05 Thread Ola Fosheim Grøstad via Digitalmars-d
Let me add to this that the superior approach is to compile to an intermediated high level format that retains type information. I guess this is where Rust is heading. It just isn't possible with C semantics to make a reasonable version of that, since the language itself is 90% unsafe and

Re: Type safety could prevent nuclear war

2016-02-05 Thread tsbockman via Digitalmars-d
On Friday, 5 February 2016 at 07:05:06 UTC, H. S. Teoh wrote: On Fri, Feb 05, 2016 at 04:02:41AM +, tsbockman via Digitalmars-d wrote: 1) Insert that information (together with what file and line number it came from) into a big list in a temporary file. 2) After all modules have been

Re: Found on Reddit: sgio.d - D lang project to send scsi ioctls and bypass drivers (Windows/Linux)

2016-02-05 Thread Ali Çehreli via Digitalmars-d-announce
On 09/30/2015 03:22 PM, Ali Çehreli wrote: https://www.reddit.com/r/programming/comments/3mze6p/sgiod_d_lang_project_to_send_scsi_ioctls_and/ Found on Reddit again. :) This time, its about a cool application of sgio.d:

Re: Idempotent partition around median of 5?

2016-02-05 Thread Fool via Digitalmars-d
On Thursday, 4 February 2016 at 20:30:57 UTC, Timon Gehr wrote: At most 6 comparisons, <=3 swaps, idempotent (optimal number of swaps)[...] One swap usually decomposes into three moves. A cycle of length n can be sorted with n + 1 moves. Corresponding to the seven integer partitions of 5 we

Re: Scientific computing in D

2016-02-05 Thread bachmeier via Digitalmars-d
On Friday, 5 February 2016 at 20:13:42 UTC, Laeeth Isharc wrote: On Monday, 9 November 2015 at 21:05:35 UTC, bachmeier wrote: On Monday, 9 November 2015 at 20:30:49 UTC, Gerald Jansen wrote: On Monday, 9 November 2015 at 19:31:14 UTC, Márcio Martins wrote: I have been running some MCMC

Re: Idempotent partition around median of 5?

2016-02-05 Thread Timon Gehr via Digitalmars-d
On 02/05/2016 04:41 PM, Fool wrote: On Thursday, 4 February 2016 at 20:30:57 UTC, Timon Gehr wrote: At most 6 comparisons, <=3 swaps, idempotent (optimal number of swaps)[...] One swap usually decomposes into three moves. A cycle of length n can be sorted with n + 1 moves. Corresponding to

Custom hash table key is const, how to call dtors?

2016-02-05 Thread Marco Leise via Digitalmars-d-learn
Usually I want the keys to be declared "immutable" to signal that their content must not change in order to provide stable hashes. But when you remove items from the table you need to call a const/immutable dtor that needs to be written for everything that can be a hash table key. What do you put

Re: Idempotent partition around median of 5?

2016-02-05 Thread Xinok via Digitalmars-d
On Friday, 5 February 2016 at 15:13:56 UTC, tn wrote: On Thursday, 4 February 2016 at 20:30:57 UTC, Timon Gehr wrote: At most 6 comparisons, <=3 swaps, idempotent (optimal number of swaps): ... Inspired by this, I made four other versions of the function that are shorter but make more

Re: Idempotent partition around median of 5?

2016-02-05 Thread Fool via Digitalmars-d
On Friday, 5 February 2016 at 21:48:58 UTC, Timon Gehr wrote: The goal is to partition though, not to sort. Six moves are sufficient. (And necessary. E.g. for 42310.) Indeed. I was wondering about that. Great job!

Re: Idempotent partition around median of 5?

2016-02-05 Thread Timon Gehr via Digitalmars-d
On 02/05/2016 10:42 PM, Xinok wrote: On Friday, 5 February 2016 at 15:13:56 UTC, tn wrote: On Thursday, 4 February 2016 at 20:30:57 UTC, Timon Gehr wrote: At most 6 comparisons, <=3 swaps, idempotent (optimal number of swaps): ... Inspired by this, I made four other versions of the

I was thinking of cool names for a new D gui library when...

2016-02-05 Thread Enjoys Math via Digitalmars-d
Function: gui & 2D graphics Package name: bud Pronunc.: B.U.D. bee-U-dee Files: bud +-- trees.d : AABB tree impl | +-- apple.d : application | +-- seeds.d : basic app utilities included throughout bud | +-- bong.d : box data structure | +-- const.d :

Re: Type safety could prevent nuclear war

2016-02-05 Thread tsbockman via Digitalmars-d
On Friday, 5 February 2016 at 20:35:16 UTC, Chris Wright wrote: On Fri, 05 Feb 2016 10:04:01 -0800, H. S. Teoh via Digitalmars-d wrote: On Fri, Feb 05, 2016 at 07:31:34AM +, tsbockman via Digitalmars-d wrote: On Friday, 5 February 2016 at 07:05:06 UTC, H. S. Teoh wrote: OK, probably I'm

Re: Overloading free functions & run-time dispatch based on parameter types

2016-02-05 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-02-05 15:23:53 +, Marc Schütz said: Does the following help? ... I thought about it too, but I need it to work with more then one parameter, so I tried this which doesn't work: Value nativePlus(Value a, Value b){ // @@ not working, runtime exception castSwitch!( (IntV a)

Re: Scientific computing in D

2016-02-05 Thread Laeeth Isharc via Digitalmars-d
On Monday, 9 November 2015 at 21:05:35 UTC, bachmeier wrote: On Monday, 9 November 2015 at 20:30:49 UTC, Gerald Jansen wrote: On Monday, 9 November 2015 at 19:31:14 UTC, Márcio Martins wrote: I have been running some MCMC simulations in Python ... Is anyone doing similar stuff with D?

First-class polymorphic lamdas?

2016-02-05 Thread ZombineDev via Digitalmars-d
Background: I'm working on a transducers proposal for Phobos, which generalizes ranges to support push data-flow model (in addition to the current pull-only) enabling composable algorithmic transformations that can be applied to other sources of data such as RX observables[0], signal & slots,

Re: Type safety could prevent nuclear war

2016-02-05 Thread Chris Wright via Digitalmars-d
On Fri, 05 Feb 2016 10:04:01 -0800, H. S. Teoh via Digitalmars-d wrote: > On Fri, Feb 05, 2016 at 07:31:34AM +, tsbockman via Digitalmars-d > wrote: >> On Friday, 5 February 2016 at 07:05:06 UTC, H. S. Teoh wrote: >> >On Fri, Feb 05, 2016 at 04:02:41AM +, tsbockman via Digitalmars-d >>

Re: Proper Use of Assert and Enforce

2016-02-05 Thread Minas Mina via Digitalmars-d-learn
On Wednesday, 14 March 2012 at 05:44:24 UTC, Chris Pons wrote: I'm new, and trying to incorporate assert and enforce into my program properly. My question revolves around, the fact that assert is only evaluated when using the debug switch. I read that assert throws a more serious exception

Re: Why this code can't take advantage from CTFE?

2016-02-05 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 22:45:47 UTC, Timon Gehr wrote: I would use enum forceCTFE(alias expr)=expr; though. With alias it won't force compile-time evaluation of expressions that can be interpreted as symbols. I've a code that build a JSON object using a wrapper over std.json.

[Issue 15626] extern(C++) calling crash

2016-02-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15626 Walter Bright changed: What|Removed |Added Keywords||C++ --

Re: Why this code can't take advantage from CTFE?

2016-02-05 Thread Luis via Digitalmars-d-learn
On Friday, 5 February 2016 at 09:36:37 UTC, Andrea Fontana wrote: On Wednesday, 3 February 2016 at 22:45:47 UTC, Timon Gehr wrote: I would use enum forceCTFE(alias expr)=expr; though. With alias it won't force compile-time evaluation of expressions that can be interpreted as symbols. I've a

Re: Proper Use of Assert and Enforce

2016-02-05 Thread Suliman via Digitalmars-d-learn
On Friday, 5 February 2016 at 08:45:00 UTC, Minas Mina wrote: On Wednesday, 14 March 2012 at 05:44:24 UTC, Chris Pons wrote: I'm new, and trying to incorporate assert and enforce into my program properly. My question revolves around, the fact that assert is only evaluated when using the

[Issue 15645] Tuple.slice() causes memory corruption.

2016-02-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15645 thomas.bock...@gmail.com changed: What|Removed |Added CC||thomas.bock...@gmail.com ---

Re: print function

2016-02-05 Thread Marc Schütz via Digitalmars-d-learn
On Friday, 5 February 2016 at 07:04:27 UTC, cy wrote: Mind if I elaborate on this a bit? If that is unrolled, I understand it will unroll into several calls to write, as in print("1","2","3") => write("1"," ");write("2"," ");write("3","\n"); Up to here, yes. And presumably, write()

Re: Type safety could prevent nuclear war

2016-02-05 Thread Daniel Murphy via Digitalmars-d
On 5/02/2016 11:03 AM, tsbockman wrote: The compiler cannot (in the general case) verify that `extern(C)` declarations are *correct*. What it could do, though, is verify that they are *consistent*. If the same `extern(C)` symbol is declared multiple places in the D source code for a program,

Re: Why this code can't take advantage from CTFE?

2016-02-05 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 5 February 2016 at 09:49:38 UTC, Luis wrote: Reading/parsing a JSON or a XML using std.json / std.xml could be done on CTFE ? parseJSON() from std.json doesn't work with CTFE. But I can build objects with with my code that works over std.json. So if you convert (with mixins) {

Re: Proper Use of Assert and Enforce

2016-02-05 Thread Marc Schütz via Digitalmars-d-learn
On Friday, 5 February 2016 at 08:45:00 UTC, Minas Mina wrote: Use assertions when a variable's value should not depend on external factors. For example, let's say you want to write a square root function. The input must be >= 0, and because this depends on external factors (e.g. user input),

[Issue 15647] Casting from one C++ interface in a hierarchy to another is a noop

2016-02-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15647 Walter Bright changed: What|Removed |Added Keywords||C++ --

[Issue 15647] New: Casting from one C++ interface in a hierarchy to another is a noop

2016-02-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15647 Issue ID: 15647 Summary: Casting from one C++ interface in a hierarchy to another is a noop Product: D Version: D2 Hardware: All OS: All Status: NEW

Overloading free functions & run-time dispatch based on parameter types

2016-02-05 Thread Robert M. Münch via Digitalmars-d-learn
From the docs: class A { } class B : A { } class C : B { } void foo(A); void foo(B); void test() { C c; foo(c); // calls foo(B) } I need the other way around. So, at runtime I get an A and depending on it's dynamic type, I would like to get the correct foo() called. class A { }

Re: Type safety could prevent nuclear war

2016-02-05 Thread tsbockman via Digitalmars-d
On Friday, 5 February 2016 at 10:49:50 UTC, Daniel Murphy wrote: Currently D allows overloading extern(C) declarations, see https://issues.dlang.org/show_bug.cgi?id=15217 Checking for invalid overloads with non-D linkage is covered here: https://issues.dlang.org/show_bug.cgi?id=2789 But

Re: Proper Use of Assert and Enforce

2016-02-05 Thread bachmeier via Digitalmars-d-learn
On Friday, 5 February 2016 at 09:50:43 UTC, Suliman wrote: Will asserts stay after compilation in release mode? No. The only assert that remains in release mode is assert(false) or assert(0) as a way to identify that you've reached a piece of code that shouldn't be executed.

Re: Deprecation policy

2016-02-05 Thread Daniel Murphy via Digitalmars-d
On 4/02/2016 6:25 AM, Jonathan M Davis wrote: With regards to language features, we really don't have a policy. Some stuff has been in the state of "we're definitely going to deprecate it" for ages (e.g. delete and using scope on local variables) but never actually gets deprecated, and other

Re: print function

2016-02-05 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 22:13:36 UTC, Ola Fosheim Grøstad wrote: Well, it is probably not the best point in time to have absolute beginners use D anyway. That is a ridiculous thing to say and a great way of ensuring a language dies. Good starting resources help everyone.

Re: Overloading free functions & run-time dispatch based on parameter types

2016-02-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 5 February 2016 at 10:54:27 UTC, Robert M. Münch wrote: From the docs: class A { } class B : A { } class C : B { } void foo(A); void foo(B); [...] sounds like foo should just be a method in the class rather than a free function

Re: Idempotent partition around median of 5?

2016-02-05 Thread Ivan Kazmenko via Digitalmars-d
On Thursday, 4 February 2016 at 01:24:15 UTC, Andrei Alexandrescu wrote: So there's got to be a better solution. Your challenge - should you choose to accept it :o) - is an algorithm that does the partitioning in 6 comparisons and <= 9 swaps, which is idempotent: when applied twice, it always

[Issue 15645] Tuple.slice() causes memory corruption.

2016-02-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15645 --- Comment #2 from Saurabh Das --- Alternative fix: https://github.com/D-Programming-Language/phobos/pull/3975 This fixes the issue without changing the layout of the tuple. Please review and consider whether the changed

Re: Type safety could prevent nuclear war

2016-02-05 Thread Daniel Murphy via Digitalmars-d
On 5/02/2016 10:07 PM, tsbockman wrote: I think it makes sense (when actually linking to C) to allow stuff like druntime's creative use of overloads. The signatures of the two bsd_signal() overloads are compatible (from C's perspective), so why not? However, multiple `extern(C)` overloads that

Re: print function

2016-02-05 Thread Artur Skawina via Digitalmars-d-learn
On 02/05/16 08:04, cy via Digitalmars-d-learn wrote: > On Thursday, 4 February 2016 at 15:32:48 UTC, Artur Skawina wrote: >>void print(A...)(A a) { >> foreach (N, ref e; a) >> write(e, N==A.length-1?"\n":" "); >>} > >>> will be unrolled at compile time > > Mind if I

Re: print function

2016-02-05 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Friday, 5 February 2016 at 12:35:14 UTC, Artur Skawina wrote: call used to print diagnostics. What I saw made me never use or look at D's std lib again. Except for meta programing and toy/example programs where it doesn't matter. What do you use instead? A buffer and Posix write() and

Re: Overloading free functions & run-time dispatch based on parameter types

2016-02-05 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-02-05 11:10:36 +, Nicholas Wilson said: sounds like foo should just be a method in the class rather than a free function In my particular case I want to keep some stuff outside of claases. -- Robert M. Münch http://www.saphirion.com smarter | better | faster

Re: print function

2016-02-05 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Friday, 5 February 2016 at 07:04:27 UTC, cy wrote: tl;dr speed demons use std.stream.InputStream.read() whenever you can, and std.stream.OutputStream.write() its result. Isn't std.stream deprecated?

[Issue 15626] extern(C++) calling crash

2016-02-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15626 --- Comment #4 from Walter Bright --- https://github.com/D-Programming-Language/dmd/pull/5403 There's no easy way to hack this in. The trouble is you have a C++ base class with no virtual functions, so it has no vtbl[].

Re: print function

2016-02-05 Thread Artur Skawina via Digitalmars-d-learn
On 02/05/16 14:38, Ola Fosheim Grøstad via Digitalmars-d-learn wrote: > On Friday, 5 February 2016 at 12:35:14 UTC, Artur Skawina wrote: >> call used to print diagnostics. What I saw made me never use or look at D's >> std lib again. Except for meta programing and toy/example programs where it

Re: What reasons are known a thread stops suddenly?

2016-02-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/5/16 2:59 AM, Ali Çehreli wrote: On 02/04/2016 10:41 PM, tcak wrote: > On Friday, 5 February 2016 at 06:23:09 UTC, Daniel Kozak wrote: >> V Fri, 05 Feb 2016 03:47:40 + >> tcak via Digitalmars-d-learn >> napsáno: >> >>> [...] >> >> Did you try

Re: Idempotent partition around median of 5?

2016-02-05 Thread Andrei Alexandrescu via Digitalmars-d
On 02/05/2016 04:42 PM, Xinok wrote: Very nice! I'm curious, to both you and Timon, how did you go about writing these and coming up with the solutions? I'm not sure if I could come up with these results myself and so quickly at that. I was thinking the same exact things. -- Andrei

Re: Idempotent partition around median of 5?

2016-02-05 Thread Andrei Alexandrescu via Digitalmars-d
On 02/05/2016 04:35 PM, Xinok wrote: It's a cool trick but I would be surprised if this were actually faster. That changes every few years. Last time I measured it was slower. -- Andrei

Re: Idempotent partition around median of 5?

2016-02-05 Thread Andrei Alexandrescu via Digitalmars-d
On 02/05/2016 07:59 PM, Andrei Alexandrescu wrote: On 02/05/2016 06:36 AM, Ivan Kazmenko wrote: Another interesting task would be to make the function stable, but I don't see how it is possible with such flat structure. Under what circumstances isn't your function unstable? -- Andrei I

Re: Idempotent partition around median of 5?

2016-02-05 Thread Timon Gehr via Digitalmars-d
On 02/06/2016 02:39 AM, Andrei Alexandrescu wrote: On 02/04/2016 03:30 PM, Timon Gehr wrote: At most 6 comparisons, <=3 swaps, idempotent (optimal number of swaps): What is the minimum number of comparisons? Thx! -- Andrei There is no partition algorithm that uses <= 5 comparisons in all

Re: Custom hash table key is const, how to call dtors?

2016-02-05 Thread cy via Digitalmars-d-learn
On Friday, 5 February 2016 at 22:18:50 UTC, Marco Leise wrote: But when you remove items from the table you need to call a const/immutable dtor that needs to be written for everything that can be a hash table key. You need to write destructors for hash keys? How would you use string literals

[Issue 15648] New: Destructor constness doesn't take member destructor attributes into account

2016-02-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15648 Issue ID: 15648 Summary: Destructor constness doesn't take member destructor attributes into account Product: D Version: D2 Hardware: x86_64 OS: Linux

Re: How do you take the address of a struct in D?

2016-02-05 Thread Enjoys Math via Digitalmars-d-learn
On Friday, 5 February 2016 at 23:53:15 UTC, Enjoys Math wrote: SDL_RenderCopy(...) takes two pointers to SDL_Rect's, I have a property method in another class returning the SDL_Rect equivalent of a Box (my structure). Taking ampersand on the left of a call to the property does not give the

Re: Idempotent partition around median of 5?

2016-02-05 Thread Andrei Alexandrescu via Digitalmars-d
On 02/04/2016 03:30 PM, Timon Gehr wrote: At most 6 comparisons, <=3 swaps, idempotent (optimal number of swaps): What is the minimum number of comparisons? Thx! -- Andrei P.S. The sythesized searcher is genius.

Re: Idempotent partition around median of 5?

2016-02-05 Thread Andrei Alexandrescu via Digitalmars-d
On 02/04/2016 03:30 PM, Timon Gehr wrote: At most 6 comparisons, <=3 swaps, idempotent (optimal number of swaps): Oh, also: could you let that bad boy run and let it find anything that does idempotent partition in 6 compares and 0-7 swaps? Then slowly tighten the number of swaps until you

How do you take the address of a struct in D?

2016-02-05 Thread Enjoys Math via Digitalmars-d-learn
SDL_RenderCopy(...) takes two pointers to SDL_Rect's, I have a property method in another class returning the SDL_Rect equivalent of a Box (my structure). Taking ampersand on the left of a call to the property does not give the address (&).

Re: How do you take the address of a struct in D?

2016-02-05 Thread Ali Çehreli via Digitalmars-d-learn
On 02/05/2016 03:53 PM, Enjoys Math wrote: SDL_RenderCopy(...) takes two pointers to SDL_Rect's, I have a property method in another class returning the SDL_Rect equivalent of a Box (my structure). Returning by reference or by value? > Taking ampersand on the left of a call to the property

Re: Proposal: Database Engine for D

2016-02-05 Thread Mengu via Digitalmars-d
On Tuesday, 5 January 2016 at 22:12:05 UTC, Mengu wrote: On Tuesday, 5 January 2016 at 08:26:16 UTC, Jacob Carlborg wrote: [...] i love how things can become so complex in this community. i am a web developer so i am going to talk in terms of simplicity. as russel said, with SQLAlchemy

Re: I was thinking of cool names for a new D gui library when...

2016-02-05 Thread Wyatt via Digitalmars-d
On Friday, 5 February 2016 at 20:19:58 UTC, Enjoys Math wrote: Anyhow, had a question: what should const.d be named in this scheme? compost.d And also thought some would appreciate the humor :) Amusing, but I feel like it might be awful confusing to actually use. I've always wondered

Re: Idempotent partition around median of 5?

2016-02-05 Thread Andrei Alexandrescu via Digitalmars-d
On 02/04/2016 03:30 PM, Timon Gehr wrote: At most 6 comparisons, <=3 swaps, idempotent (optimal number of swaps): Timon, Ivan, this is amazing work. I don't know how your minds work folks - I sat for like two hours on it yesterday and couldn't crack it. Surprisingly in a test on millions of

Re: Idempotent partition around median of 5?

2016-02-05 Thread Andrei Alexandrescu via Digitalmars-d
On 02/05/2016 06:36 AM, Ivan Kazmenko wrote: Another interesting task would be to make the function stable, but I don't see how it is possible with such flat structure. Under what circumstances isn't your function unstable? -- Andrei

Re: Custom hash table key is const, how to call dtors?

2016-02-05 Thread Marco Leise via Digitalmars-d-learn
Am Sat, 06 Feb 2016 03:38:54 + schrieb cy : > On Friday, 5 February 2016 at 22:18:50 UTC, Marco Leise wrote: > > But when you remove items from the table you need to call a > > const/immutable dtor that needs to be written for everything > > that can be a hash table

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-05 Thread tsbockman via Digitalmars-d-learn
On Friday, 5 February 2016 at 19:16:11 UTC, Marco Leise wrote: > 1. Removing 'ref' from the return type Must happen. 'ref' only worked because of the reinterpreting cast which doesn't work in general. This will change the semantics. Now the caller of 'slice' will deal with a whole new copy

"Error: need 'this' for 'bbox' of type 'Bong!(double, 3u)'"

2016-02-05 Thread Enjoys Math via Digitalmars-d-learn
I'm getting that on the last line of this code: auto wh = Vec2([loadSurf.w, loadSurf.h]); wh /= 2; auto x = wh.plus1Dim(pos[Z]); this.bbox = Box3(pos - x, pos + x); Any ideas?

Re: Template to create a type and instantiate it

2016-02-05 Thread cy via Digitalmars-d-learn
On Friday, 5 February 2016 at 07:44:29 UTC, Rikki Cattermole wrote: That code is completely wrong anyway. Well, obviously it's wrong. If I don't know correct code that will do what I want, then I can't tell you what I want using correct code. But you could do: alias Derp = TFoo; Derp

Re: "Error: need 'this' for 'bbox' of type 'Bong!(double, 3u)'"

2016-02-05 Thread Enjoys Math via Digitalmars-d-learn
On Saturday, 6 February 2016 at 04:41:26 UTC, Enjoys Math wrote: I'm getting that on the last line of this code: auto wh = Vec2([loadSurf.w, loadSurf.h]); wh /= 2; auto x = wh.plus1Dim(pos[Z]); this.bbox = Box3(pos - x, pos + x);

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-05 Thread Saurabh Das via Digitalmars-d-learn
On Friday, 5 February 2016 at 19:16:11 UTC, Marco Leise wrote: Am Fri, 05 Feb 2016 05:31:15 + schrieb Saurabh Das : [...] That is enlightening. I have updated the PR at https://github.com/D-Programming-Language/phobos/pull/3975 to incorporate these changes.

Re: Detecting exception unwinding

2016-02-05 Thread cy via Digitalmars-d-learn
On Friday, 5 February 2016 at 08:16:05 UTC, Ola Fosheim Grøstad wrote: If you can test for "uncaught_exceptions" you can implement the equivalent of scope(failure/success) etc within destructors. Sorry, years of python programming have made me shy of destructors. It just looks a little less