Re: D man pages

2019-01-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 January 2019 at 14:25:26 UTC, H. S. Teoh wrote: A text-based links browser with a focused use case sounds like a far better idea. Though programs like elinks or pinfo may have already have you beat on this front. :-D elinks does an ok job on dpldocs (of course, I partially

Re: reimplementing an interface in a derived class

2019-01-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/4/19 7:16 PM, kdevel wrote: On Friday, 4 January 2019 at 20:21:56 UTC, Steven Schveighoffer wrote: missing in the source. But why is d a null reference in the first place? Because when you dynamically cast one object or interface to another object or interface, and that result is not

static foreach not working with this

2019-01-07 Thread Michelle Long via Digitalmars-d-learn
static foreach(k, p; AliasSeq!(this, s)) {{ p.foo(); // Fails even if this line is removed }} this not known at compile time. replace s with this and it works! s is an argument which is also not known at compile time(generally). Should work with this. Just "simplifying"

Re: D man pages

2019-01-07 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jan 06, 2019 at 03:11:48AM +, Adam D. Ruppe via Digitalmars-d-learn wrote: [...] > http://arsdnet.net/arsd/dman.png > > But that's the result of about 5 mins of work... though I really like > my hyperlinks and actually kinda prefer the browser for that reason > (tho making a custom

Re: static foreach not working with this

2019-01-07 Thread Alex via Digitalmars-d-learn
On Monday, 7 January 2019 at 16:16:57 UTC, Michelle Long wrote: On Monday, 7 January 2019 at 16:01:50 UTC, Michelle Long wrote: static foreach(k, p; AliasSeq!(this, s)) {{ p.foo(); // Fails even if this line is removed }} this not known at compile time. replace s with this

Re: static foreach not working with this

2019-01-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/7/19 11:16 AM, Michelle Long wrote: On Monday, 7 January 2019 at 16:01:50 UTC, Michelle Long wrote: static foreach(k, p; AliasSeq!(this, s)) {{     p.foo(); // Fails even if this line is removed }} this not known at compile time. replace s with this and it works! s is an argument which

Re: static foreach not working with this

2019-01-07 Thread Alex via Digitalmars-d-learn
On Monday, 7 January 2019 at 16:31:49 UTC, Steven Schveighoffer wrote: On 1/7/19 11:16 AM, Michelle Long wrote: On Monday, 7 January 2019 at 16:01:50 UTC, Michelle Long wrote: [...] static foreach(k, p; AliasSeq!(Alias!this, s)) {{     p.foo(); // Fails even if this line is removed }} To

Re: Bitwise rotate of integral

2019-01-07 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 7 January 2019 at 14:39:07 UTC, Per Nordlöw wrote: What's the preferred way of doing bitwise rotate of an integral value in D? Are there intrinsics for bitwise rotation available in LDC? I just found this ulong rotateLeft(ulong x, ubyte bits) { return (x << bits)

Re: Bitwise rotate of integral

2019-01-07 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 7 January 2019 at 14:53:26 UTC, Alex wrote: There are https://dlang.org/phobos/core_bitop.html#.rol and https://dlang.org/phobos/core_bitop.html#.ror But it seems the implementation is like yours. Ahh, missed that. Thanks.

Re: Bitwise rotate of integral

2019-01-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/7/19 10:10 AM, Per Nordlöw wrote: On Monday, 7 January 2019 at 14:53:26 UTC, Alex wrote: There are https://dlang.org/phobos/core_bitop.html#.rol and https://dlang.org/phobos/core_bitop.html#.ror But it seems the implementation is like yours. Ahh, missed that. Thanks. Use the

Re: static foreach not working with this

2019-01-07 Thread Michelle Long via Digitalmars-d-learn
On Monday, 7 January 2019 at 16:29:25 UTC, Alex wrote: On Monday, 7 January 2019 at 16:16:57 UTC, Michelle Long wrote: On Monday, 7 January 2019 at 16:01:50 UTC, Michelle Long wrote: static foreach(k, p; AliasSeq!(this, s)) {{ p.foo(); // Fails even if this line is removed

Bitwise rotate of integral

2019-01-07 Thread Per Nordlöw via Digitalmars-d-learn
What's the preferred way of doing bitwise rotate of an integral value in D? Are there intrinsics for bitwise rotation available in LDC?

Re: Bitwise rotate of integral

2019-01-07 Thread Alex via Digitalmars-d-learn
On Monday, 7 January 2019 at 14:43:29 UTC, Per Nordlöw wrote: On Monday, 7 January 2019 at 14:39:07 UTC, Per Nordlöw wrote: What's the preferred way of doing bitwise rotate of an integral value in D? Are there intrinsics for bitwise rotation available in LDC? I just found this ulong

Re: Converting an integer to a string with std.format.

2019-01-07 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 7 January 2019 at 09:57:45 UTC, Daniel Kozak wrote: I would go with std.conv.to or std.conv.text :) The reason for not using std.conv.to is to prevent the extra allocation needed in code such as sink.put(someIntegral.to!string) instead of something like

Re: Pass reference to void*

2019-01-07 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 7 January 2019 at 12:19:57 UTC, Andre Pany wrote: Hi, I call a C function from a dll (SO on linux). While the following code works fine for DMD on windows, there are strange errors for LDC on windows. Also the equivalent code does not work for DMD/LDC on linux. (When calling other

Re: Converting an integer to a string with std.format.

2019-01-07 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 6 January 2019 at 21:53:31 UTC, Per Nordlöw wrote: When converting a single integer to a string is `formatValue` preferred over `formattedWrite` in terms of compilation and run-time performance? I've written my own itos function because using std.conv was too expensive. see

Pass reference to void*

2019-01-07 Thread Andre Pany via Digitalmars-d-learn
Hi, I call a C function from a dll (SO on linux). While the following code works fine for DMD on windows, there are strange errors for LDC on windows. Also the equivalent code does not work for DMD/LDC on linux. (When calling other functions from the dll and passing the model reference, this

Re: Pass reference to void*

2019-01-07 Thread Andre Pany via Digitalmars-d-learn
On Monday, 7 January 2019 at 13:01:57 UTC, Stefan Koch wrote: On Monday, 7 January 2019 at 12:19:57 UTC, Andre Pany wrote: Hi, I call a C function from a dll (SO on linux). While the following code works fine for DMD on windows, there are strange errors for LDC on windows. Also the

Re: Converting an integer to a string with std.format.

2019-01-07 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 6 January 2019 at 21:53:31 UTC, Per Nordlöw wrote: When converting a single integer to a string is `formatValue` preferred over `formattedWrite` in terms of compilation and run-time performance? Also, if you do not need to write to a stream or a range and just need the value,

Re: Co-developing application and library

2019-01-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2019-01-05 16:17, Mike Parker wrote: What I do is use `dub add-local /path/to/lib 0.0.1` and use that explicit version for development. That way, whatever repository branch is currently active in that directory becomes version 0.0.1 and I can make use of any changes. The problem with

Unexpected results with doubles

2019-01-07 Thread Joseph Malle via Digitalmars-d-learn
I am learning D. I was working on Project Euler #199 (possible spoilers) and got some unexpected results. It's probably a stupid mistake but I can't see it. Here is an edited function from my program: auto radius(const double r1, const double r2, const double r3) { auto const k1 = 1/r1;

Re: signed nibble

2019-01-07 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 7 January 2019 at 18:56:17 UTC, H. S. Teoh wrote: On Mon, Jan 07, 2019 at 06:42:13PM +, Patrick Schluter via Digitalmars-d-learn wrote: On Monday, 7 January 2019 at 17:23:19 UTC, Michelle Long wrote: > Is there any direct way to convert a signed nibble in to a > signed byte with

Re: Unexpected results with doubles

2019-01-07 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 07, 2019 at 07:57:14PM +, Joseph Malle via Digitalmars-d-learn wrote: [...] > auto radius(const double r1, const double r2, const double r3) { > auto const k1 = 1/r1; > auto const k2 = 1/r2; > auto const k3 = 1/r3; > writeln(); > writeln("1 ", [k1, k2, k3]); >

Re: signed nibble

2019-01-07 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 07, 2019 at 06:42:13PM +, Patrick Schluter via Digitalmars-d-learn wrote: > On Monday, 7 January 2019 at 17:23:19 UTC, Michelle Long wrote: > > Is there any direct way to convert a signed nibble in to a signed > > byte with the same absolute value? Obviously I can do some bit > >

Re: signed nibble

2019-01-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 January 2019 at 18:42:13 UTC, Patrick Schluter wrote: byte b = nibble | ((nibble & 0x40)?0xF0:0); don't you mean & 0x80 ?

Re: signed nibble

2019-01-07 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 7 January 2019 at 20:28:21 UTC, H. S. Teoh wrote: On Mon, Jan 07, 2019 at 08:06:17PM +, Patrick Schluter via Digitalmars-d-learn wrote: On Monday, 7 January 2019 at 18:56:17 UTC, H. S. Teoh wrote: > On Mon, Jan 07, 2019 at 06:42:13PM +, Patrick Schluter > via

Re: signed nibble

2019-01-07 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 07, 2019 at 05:23:19PM +, Michelle Long via Digitalmars-d-learn wrote: > Is there any direct way to convert a signed nibble in to a signed byte > with the same absolute value? Obviously I can do some bit comparisons > but just curious if there is a very quick way. Assuming you

Re: signed nibble

2019-01-07 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 7 January 2019 at 18:47:04 UTC, Adam D. Ruppe wrote: On Monday, 7 January 2019 at 18:42:13 UTC, Patrick Schluter wrote: byte b = nibble | ((nibble & 0x40)?0xF0:0); don't you mean & 0x80 ? He asked for signed nybble. So mine is wrong and yours also :-) It's obviously 0x08 for the

Re: Forward declaration inside Function block, no error?

2019-01-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/7/19 12:20 AM, Jonathan M Davis wrote: On Sunday, January 6, 2019 11:38:44 AM MST Benjamin Thaut via Digitalmars-d- learn wrote: Today I found a bug in my D code. import std.stdio; // Type your code here, or load an example. void grow() { writeln("grow"); } void someFunc(bool

signed nibble

2019-01-07 Thread Michelle Long via Digitalmars-d-learn
Is there any direct way to convert a signed nibble in to a signed byte with the same absolute value? Obviously I can do some bit comparisons but just curious if there is a very quick way.

Re: signed nibble

2019-01-07 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 7 January 2019 at 17:23:19 UTC, Michelle Long wrote: Is there any direct way to convert a signed nibble in to a signed byte with the same absolute value? Obviously I can do some bit comparisons but just curious if there is a very quick way. byte b = nibble | ((nibble &

Re: signed nibble

2019-01-07 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 07, 2019 at 08:06:17PM +, Patrick Schluter via Digitalmars-d-learn wrote: > On Monday, 7 January 2019 at 18:56:17 UTC, H. S. Teoh wrote: > > On Mon, Jan 07, 2019 at 06:42:13PM +, Patrick Schluter via > > Digitalmars-d-learn wrote: [...] > > > byte b = nibble | ((nibble &

Will AtoX replace SWIFT?

2019-01-07 Thread tongzhengshijie via Digitalmars-d-learn
Will AtoX replace SWIFT? Society for Worldwide Interbank Financial Telecommunication (SWIFT) is a non-profitable international and cooperative organization between international bank that provides fast, accurate and excellent services to international financial services. It operates a

Re: signed nibble

2019-01-07 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 07, 2019 at 08:41:32PM +, Patrick Schluter via Digitalmars-d-learn wrote: > On Monday, 7 January 2019 at 20:28:21 UTC, H. S. Teoh wrote: > > On Mon, Jan 07, 2019 at 08:06:17PM +, Patrick Schluter via > > Digitalmars-d-learn wrote: [...] > > > Up to 32 bit processors, shifting

Re: Bitwise rotate of integral

2019-01-07 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 07, 2019 at 11:13:37PM +, Guillaume Piolat via Digitalmars-d-learn wrote: > On Monday, 7 January 2019 at 14:39:07 UTC, Per Nordlöw wrote: > > What's the preferred way of doing bitwise rotate of an integral > > value in D? > > > > Are there intrinsics for bitwise rotation

Re: Bitwise rotate of integral

2019-01-07 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 7 January 2019 at 14:39:07 UTC, Per Nordlöw wrote: What's the preferred way of doing bitwise rotate of an integral value in D? Are there intrinsics for bitwise rotation available in LDC? Turns out you don't need any: https://d.godbolt.org/z/C_Sk_- Generates ROL instruction.

Re: Unexpected results with doubles

2019-01-07 Thread Joseph Malle via Digitalmars-d-learn
On Monday, 7 January 2019 at 20:18:28 UTC, H. S. Teoh wrote: Either there's memory corruption somewhere, or there's a codegen bug in the compiler. I think that must be it. I ran it with ldc instead of dmd and it worked fine (solved the original problem! woohoo). Or the compiler somehow is

Re: Unexpected results with doubles

2019-01-07 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 07, 2019 at 09:42:42PM +, Joseph Malle via Digitalmars-d-learn wrote: > On Monday, 7 January 2019 at 20:18:28 UTC, H. S. Teoh wrote: > > Either there's memory corruption somewhere, or there's a codegen bug > > in the compiler. > > I think that must be it. I ran it with ldc