Re: Qualified class opEquals()

2018-12-24 Thread Paul Backus via Digitalmars-d-learn
On Monday, 24 December 2018 at 22:58:03 UTC, Per Nordlöw wrote: Is it in the following code possible to make the statement assert(car1 == car2); in the function testEqual() compile in a `@safe pure nothrow @nogc context`? No, because equality comparison between classes lowers to `object

Qualified class opEquals()

2018-12-24 Thread Per Nordlöw via Digitalmars-d-learn
Is it in the following code possible to make the statement assert(car1 == car2); in the function testEqual() compile in a `@safe pure nothrow @nogc context`? Code: import core.internal.hash : hashOf; /** Hash that distinguishes `Expr(X)` from `NounExpr(X)`. * * See_Also: https://for

Re: class template conflict

2018-12-24 Thread Daniel Kozak via Digitalmars-d-learn
ne 23. 12. 2018 13:10 odesílatel Michelle Long via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> napsal: > class X > { > > } > > class X(int N) : X > { > > } > > Is there any real reason we can't do this? Actually yes. It would break almost all of my code. In D you can do thing like

Re: DLang BetterC dynamic arrays

2018-12-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/24/18 5:07 PM, dtoadq wrote: Ah, of course I find the solution immediately after I post. At least it seems to work fine; ``` struct Array(T) {   T[] foo;   this ( size_t size ) {     T* data = cast(T*)malloc(size);     foo = data[0..size];   } } ``` Careful there, data[0 .. size]

Re: DLang BetterC dynamic arrays

2018-12-24 Thread dtoadq via Digitalmars-d-learn
Ah, of course I find the solution immediately after I post. At least it seems to work fine; ``` struct Array(T) { T[] foo; this ( size_t size ) { T* data = cast(T*)malloc(size); foo = data[0..size]; } } ``` :-)

DLang BetterC dynamic arrays

2018-12-24 Thread dtoadq via Digitalmars-d-learn
One of the major things holding me back from using BetterC is https://issues.dlang.org/show_bug.cgi?id=18949 . Until this is fixed (if it ever is), we are stuck with implementing our own arrays. The problem comes that the default constructor of a struct must be default or disabled, which means

Re: Mysteries of the Underscore

2018-12-24 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 24, 2018 at 04:53:57PM +, Neia Neutuladh via Digitalmars-d-learn wrote: > On Mon, 24 Dec 2018 08:16:01 -0800, H. S. Teoh wrote: > > Rather, it's *conventionally* taken to mean "unused". The language > > actually does not treat it in any special way apart from "normal" > > identifi

Re: Mysteries of the Underscore

2018-12-24 Thread Neia Neutuladh via Digitalmars-d-learn
On Mon, 24 Dec 2018 08:16:01 -0800, H. S. Teoh wrote: > Rather, it's *conventionally* taken to mean "unused". The language > actually does not treat it in any special way apart from "normal" > identifiers. It's perfectly valid (though probably not recommended!) to > declare functions or variables

Re: Mysteries of the Underscore

2018-12-24 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 24, 2018 at 02:45:24PM +, bauss via Digitalmars-d-learn wrote: [...] > The underscore does nothing and it's just an identifier. > > Really it just means "unused". It's frequently used in loops to. Rather, it's *conventionally* taken to mean "unused". The language actually does no

Re: Mysteries of the Underscore

2018-12-24 Thread bauss via Digitalmars-d-learn
On Monday, 24 December 2018 at 11:18:44 UTC, Ron Tarrant wrote: I found a mention that in the definition of a delegate, a function parameter and its type could be replaced by an underscore: myTestRig.addOnDestroy(delegate void(Widget w) { quitApp(); } ); became: myTestRig.addOnDestroy(delega

Re: Mysteries of the Underscore

2018-12-24 Thread Ron Tarrant via Digitalmars-d-learn
On Monday, 24 December 2018 at 11:30:31 UTC, Johan Engelen wrote: The underscore is just an identifier but nothing special, it could be any valid identifier like "ldkhfksdkdsg". -Johan Thanks, Johan. In a way, I was hoping it was some kind of underscore magic. Now my brain hurts.

Re: Mysteries of the Underscore

2018-12-24 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 24 December 2018 at 11:18:44 UTC, Ron Tarrant wrote: I found a mention that in the definition of a delegate, a function parameter and its type could be replaced by an underscore: myTestRig.addOnDestroy(delegate void(Widget w) { quitApp(); } ); became: myTestRig.addOnDestroy(delega

Re: DSFML linking fails

2018-12-24 Thread Dmitriy via Digitalmars-d-learn
On Monday, 24 December 2018 at 11:07:09 UTC, number wrote: On Monday, 24 December 2018 at 10:08:25 UTC, Dmitriy wrote: Hello. I'm using https://github.com/Jebbs/DSFML library ... The problem when I build my project using these libraries. The problem in linking: Did you look at http://dsf

Re: cas and interfaces

2018-12-24 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 23 December 2018 at 14:07:04 UTC, Johannes Loher wrote: I recently played around with atomic operations. While doing so, I noticed a problem with the interaction of interfaces and cas. Consider the following program: ``` import core.atomic; import std.stdio; interface TestInterface

Mysteries of the Underscore

2018-12-24 Thread Ron Tarrant via Digitalmars-d-learn
I found a mention that in the definition of a delegate, a function parameter and its type could be replaced by an underscore: myTestRig.addOnDestroy(delegate void(Widget w) { quitApp(); } ); became: myTestRig.addOnDestroy(delegate void(_) { quitApp(); } ); I was trying to find some further d

Re: DSFML linking fails

2018-12-24 Thread number via Digitalmars-d-learn
On Monday, 24 December 2018 at 10:08:25 UTC, Dmitriy wrote: Hello. I'm using https://github.com/Jebbs/DSFML library ... The problem when I build my project using these libraries. The problem in linking: Did you look at http://dsfml.com/docs/firstprogram.html ? I remember having to link a

Re: DSFML linking fails

2018-12-24 Thread Dmitriy via Digitalmars-d-learn
I opened dsfml-system.lib file, and found 1.txt file there, it contains the line: src\DSFMLC\System\CMakeFiles\dsfmlc-system.dir\Err.cpp.obj _sfErr_redirect but when linking it looking for the: lld-link: error: : undefined symbol: sfErr_redirect without a _ symbol on the beginning

DSFML linking fails

2018-12-24 Thread Dmitriy via Digitalmars-d-learn
Hello. I'm using https://github.com/Jebbs/DSFML library My env Windows 10 (x64), utils: mingw32-make, MinGW Makefiles, dub, dmd, ldc2, also tried with Visual Studio 2017 compilers (nmake, NMake Files) I compiled build.exe util from this repository, copied SFML (include content) to SFML fold