Re: Lazy param with nothrow

2016-03-01 Thread ag0aep6g via Digitalmars-d-learn
On 01.03.2016 14:35, Andrea Fontana wrote: This very very simple function [1] won't compile. It says that param t is not nothrow. Why? What's wrong with this? http://dpaste.dzfl.pl/bfc382e62711 It's a bug. Lazy parameters generate delegates. nothrow is currently not inferred for those

Re: Lazy param with nothrow

2016-03-01 Thread Nemo via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 13:35:08 UTC, Andrea Fontana wrote: This very very simple function [1] won't compile. It says that param t is not nothrow. Why? What's wrong with this? http://dpaste.dzfl.pl/bfc382e62711 writeln isn't nothrow so you can't call it from test which is nothrow

Lazy param with nothrow

2016-03-01 Thread Andrea Fontana via Digitalmars-d-learn
This very very simple function [1] won't compile. It says that param t is not nothrow. Why? What's wrong with this? http://dpaste.dzfl.pl/bfc382e62711

Re: BitArray: count the number of bits set

2016-03-01 Thread yawniek via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 09:32:20 UTC, Andrea Fontana wrote: Maybe you should look for "hamming weight" :) maybe. and here is a snowman for you: ☃ the question was if it exists for BitArray in phobos. https://issues.dlang.org/show_bug.cgi?id=10239 so apparently its really missing in

Re: BitArray: count the number of bits set

2016-03-01 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 09:03:47 UTC, yawniek wrote: i figured i can count the number of bits set for a BitArray with std.algorithm : count: BitArray([0,0,1]).bitsSet.count() but this seems not very optimal, is there a faster way directly accessible trough phobos? ideally something

BitArray: count the number of bits set

2016-03-01 Thread yawniek via Digitalmars-d-learn
i figured i can count the number of bits set for a BitArray with std.algorithm : count: BitArray([0,0,1]).bitsSet.count() but this seems not very optimal, is there a faster way directly accessible trough phobos? ideally something that is optimized by the compiler.

Re: Member Access Based On A Runtime String

2016-03-01 Thread Adrian Matoga via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 08:53:20 UTC, Adrian Matoga wrote: static if (is(Q : T)) { Oops, should be T : Q

Re: Member Access Based On A Runtime String

2016-03-01 Thread Adrian Matoga via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 05:05:40 UTC, Jack Stouffer wrote: In Python, I can do this: my_obj = Obj() string_from_func = func() setattr(my_obj, string_from_func, 100) Say func() returns "member1" or "member2", the setattr would then set either one of those to 100. Is there any

Re: Member Access Based On A Runtime String

2016-03-01 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 05:05:40 UTC, Jack Stouffer wrote: In Python, I can do this: my_obj = Obj() string_from_func = func() setattr(my_obj, string_from_func, 100) Say func() returns "member1" or "member2", the setattr would then set either one of those to 100. Is there any

Re: D equivalent of run-time DLLs / Plugins

2016-03-01 Thread Carsten Blüggel via Digitalmars-d-learn
On Monday, 29 February 2016 at 22:40:41 UTC, Chris Katko wrote: On Monday, 29 February 2016 at 22:12:37 UTC, jmh530 wrote: On Monday, 29 February 2016 at 19:02:27 UTC, Chris Katko wrote: Hello. Dlang newbie here. ,,, I'm confused. Both posts appear to be for linking... D to C++ DLLs. I want