Re: Why Does Dscanner Warn About a Missing toHash if opEquals is Defined?

2016-08-02 Thread BLM768 via Digitalmars-d-learn
On Sunday, 31 July 2016 at 18:57:50 UTC, Jack Stouffer wrote: Next question: what's the fastest hashing implementation that will provide the least collisions? Is there a hash implementation that's perfered for AAs? I've heard that FNV-1a is a decent general-purpose option, and it's fairly

Re: Why Does Dscanner Warn About a Missing toHash if opEquals is Defined?

2016-07-31 Thread BLM768 via Digitalmars-d-learn
On Sunday, 31 July 2016 at 16:39:59 UTC, Jack Stouffer wrote: But D provides a default toHash for every type if it's not defined. I was wondering why not just rely on that version. If two objects are equal, their hashes must also be equal. Consider this example: struct Nullable(T) { bool

Re: Iterate all visible symbols, even from imported modules

2016-07-18 Thread BLM768 via Digitalmars-d-learn
On Monday, 18 July 2016 at 13:00:16 UTC, Lodovico Giaretta wrote: // how do I discover that "std" is a package? I've got a DMD pull request that adds __traits(isPackage, someSymbol), but it's stuck waiting for approval. If and when it gets merged, it could be useful for that.

Keeping a reference to a linked list element

2016-05-11 Thread BLM768 via Digitalmars-d-learn
I just started working on a project in which it would be convenient to hold a reference to a specific entry in a DList. The interface doesn't seem to provide a way to get a pointer to a raw node struct, so about the best solution I can find is to get a range out of the list, pop elements until

Re: C header file: tagged enumerations

2016-04-27 Thread BLM768 via Digitalmars-d-learn
On Tuesday, 26 April 2016 at 23:40:24 UTC, Adam D. Ruppe wrote: D doesn't handle this C pattern well... you basically have to rewrite the whole thing for each version. Or you can use the technique that's used in llvm-d: build the enumeration from a string mixin which is generated from a

Re: Functions that return type

2016-01-20 Thread BLM768 via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 10:04:03 UTC, burjui wrote: That's alright. Parsing and AST construction are trivial with S-expressions (Lisp-like syntax), so if you use them for the early stages of development, you can focus on the type system. When you're done with types, you can switch to

Re: Functions that return type

2016-01-19 Thread blm768 via Digitalmars-d-learn
On Sunday, 17 January 2016 at 02:08:06 UTC, Timon Gehr wrote: On 01/16/2016 11:50 PM, data pulverizer wrote: I guess the constraints are that of a static language. (This is not true.) I'm playing with the design of such a language myself. Basically, anything can create/use/return type

Re: How do you create an opengl window with DerelictOrg?

2015-12-07 Thread BLM768 via Digitalmars-d-learn
On Monday, 7 December 2015 at 21:33:57 UTC, Enjoys Math wrote: I've seen these: https://github.com/DerelictOrg?page=1 BUt not sure how to use them, examples? OpenGL itself can't create a window/context, so you'll need to use DerelictGLFW or DerelictSDL. GLFW is lighter-weight. Combine the

Re: Password Storage

2015-11-27 Thread BLM768 via Digitalmars-d-learn
On Friday, 27 November 2015 at 16:14:06 UTC, H. S. Teoh wrote: True, so you'd store hash(password01) in the database, and compute hash(X + hash(password)) during authentication. T Another option is SCRAM: https://en.wikipedia.org/wiki/Salted_Challenge_Response_Authentication_Mechanism

Re: Password Storage

2015-11-26 Thread BLM768 via Digitalmars-d-learn
On Friday, 27 November 2015 at 02:05:49 UTC, H. S. Teoh wrote: For authentication, the password shouldn't even be sent over the wire. Instead, the server (which knows the correct password) should send a challenge to the client (i.e., a large random number produced by a good RNG -- which is

Re: Something about Chinese Disorder Code

2015-11-24 Thread BLM768 via Digitalmars-d-learn
On Tuesday, 24 November 2015 at 09:48:45 UTC, magicdmer wrote: I display chinese string like: auto str = "你好,世界" writeln(str) and The display is garbled。 some windows api like MessageBoxA ,if string is chinese, it displays disorder code too i think i must use WideCharToMultiByte to convert

Finding packages recursively

2015-11-23 Thread BLM768 via Digitalmars-d-learn
I'm trying to recursively visit a package and all packages/modules within it using metaprogramming. I should be able to use __traits(allMembers, somePackage) recursively to get all symbols within the package, but is there an easy way to determine whether a symbol represents a package, a

DMD chokes on UDAs of mixin enum members

2013-04-26 Thread BLM768
I've got some code that reduces to the following test case: -- mixin template stuff() { enum someEnum = testing; static void test() { foreach(member; __traits(allMembers, typeof(this))) { pragma(msg, member);

Re: DMD chokes on UDAs of mixin enum members

2013-04-26 Thread BLM768
That's probably it. I guess I'll have to work around it for now. On Saturday, 27 April 2013 at 00:21:02 UTC, anonymous wrote: On Friday, 26 April 2013 at 21:50:51 UTC, BLM768 wrote: [...] Is there some subtle point I'm missing, or is this just a bug? Looks like http://d.puremagic.com/issues

Re: SQLite library on Windows

2012-12-27 Thread BLM768
Download their windows binaries and use Digital Mars implib tool with /system switch. Man, I wish I'd known about that tool a while ago... It seems to be working, but it looks like I'll need to recompile the DLL myself; DMD is looking for symbols mangled with a leading underscore, but the

Re: SQLite library on Windows

2012-12-27 Thread BLM768
Man, I wish I'd known about that tool a while ago... It seems to be working, but it looks like I'll need to recompile the DLL myself; DMD is looking for symbols mangled with a leading underscore, but the DLL has unmangled symbols, so optlink still complains. Oh; never mind. I forgot the

SQLite library on Windows

2012-12-26 Thread BLM768
I've been trying various methods to get SQLite working in Windows using the etc.c.sqlite3 bindings, but I can't figure out how to get everything in a form that DMD likes. GCC doesn't seem to output anything that OPTLINK can use, and I can't use the standard DLL build without creating a .LIB

Re: SQLite library on Windows

2012-12-26 Thread BLM768
On Thursday, 27 December 2012 at 03:03:34 UTC, jose isaias cabrera wrote: I have a huge project with D1 using the old DDBI project in dsource: http://dsource.org/projects/ddbi It would be nice if someone with time will port it to D2. IHTH. jic Actually, my current project is basically

Re: long compile time question

2012-10-27 Thread BLM768
In any case, though, separately initializing every member of an array is silly. That's what a loop is for. That, or a memcpy from an immutable copy of .init. I think that the reasoning behind DMD's implementation is that for small structs, writing out the instructions is more efficient

Re: long compile time question

2012-10-27 Thread BLM768
On Saturday, 27 October 2012 at 23:07:19 UTC, BLM768 wrote: In any case, though, separately initializing every member of an array is silly. That's what a loop is for. That, or a memcpy from an immutable copy of .init. I think that the reasoning behind DMD's implementation

Re: two-dimensional C array and its analog in D

2012-08-08 Thread BLM768
I mean that I call C function from D code. And C function takes void** pointer as its argument. In C this means array of array, but if I pass D two-dimensional array it doesn't work (but compiles). I'm pretty sure that the issue is D's internal implementation of 2-dimensional arrays. From

LDC -noruntime

2012-07-06 Thread BLM768
I've been trying to write an OS kernel in D, and I'm having issues with the runtime. I'm trying to use LDC's -noruntime option, which is _supposed_ to prevent any runtime calls from being generated, but the linker keeps complaining about unresolved references to _d_assert_msg and other runtime

Re: LDC -noruntime

2012-07-06 Thread BLM768
It's not like compiling without a runtime will make the compiler not emit calls; what else would it do for e.g. the 'new' expression? Anyway, given your situation, just grab the function prototypes from druntime and stub them out, then fill them in later. I knew that stuff like new

Re: LDC -noruntime

2012-07-06 Thread BLM768
On Friday, 6 July 2012 at 09:38:13 UTC, Jacob Carlborg wrote: On 2012-07-06 08:53, BLM768 wrote: I've been trying to write an OS kernel in D, and I'm having issues with the runtime. I'm trying to use LDC's -noruntime option, which is _supposed_ to prevent any runtime calls from being generated

Re: LDC -noruntime

2012-07-06 Thread BLM768
The output of the --help switch suggested that it would actually keep LDC from generating the calls, but I guess not. Looks like I've got a rumtime to stub out. At least I'll understand it better when I'm done. I meant runtime. Stupid touch-screen keyboard :).

Re: LDC -noruntime

2012-07-06 Thread BLM768
On Friday, 6 July 2012 at 15:35:17 UTC, K.Wilson wrote: Check out the Xomb OS as they had to stub things in the runtime out IIRC, and they use LDC still, I believe. May need to check out a very old copy to see what they originally did to get a minimal kernel running. I've looked a little

Re: LDC -noruntime

2012-07-06 Thread BLM768
On Friday, 6 July 2012 at 21:54:15 UTC, 1100110 wrote: I swear you guys read my mind sometimes... It's creepy. I just had this very issue, doing the exact same thing, about an hour ago. Have you tried with -nodefaultlib -noruntime ? Cause that's what works for me... I just got

Re: LDC -noruntime

2012-07-06 Thread BLM768
On Saturday, 7 July 2012 at 04:27:07 UTC, Jonathan M Davis wrote: On Saturday, July 07, 2012 05:45:53 BLM768 wrote: On Friday, 6 July 2012 at 21:54:15 UTC, 1100110 wrote: I swear you guys read my mind sometimes... It's creepy. I just had this very issue, doing the exact same thing, about

Re: implicit conversion to alias this

2012-06-28 Thread BLM768
I'm fine that the assignment to C is verboten. I'd disallow the  first assignments to and would like to know, why they are kept. OK, now I get it. I'm not sure why they're allowed, either; I guess that it's just because it's written with assignment syntax. On second thought, it might be

Re: implicit conversion to alias this

2012-06-28 Thread BLM768
I'm fine that the assignment to C is verboten. I'd disallow the  first assignments to and would like to know, why they are kept. OK, now I get it. I'm not sure why they're allowed, either; I guess that it's just because it's written with assignment syntax. On second thought, it might be

Re: implicit conversion to alias this

2012-06-27 Thread BLM768
On Monday, 25 June 2012 at 20:06:21 UTC, Tobias Pankrath wrote: - struct A { bool a; alias a this; } struct B { int b; alias b this; } A a = false; // works B b = 12; // works struct C { A aa; B ab; } C c = { false, 12 }; // does not work, because the implicit conversion does

Re: aa.remove in a destructor

2012-06-23 Thread BLM768
I've been having the same problem as well, but I never figured out the link to the remove() call in the destructor. The only solution I've found is to use GC.removeRoot() on the table, but it's an untested and potentially dangerous solution.

Package and virtual functions

2012-06-13 Thread BLM768
For some reason, whenever I declare a method with package visibility, it becomes non-virtual. Is this normal behavior, or is there a bug in DMD 2.059?

Re: Package and virtual functions

2012-06-13 Thread BLM768
On Wednesday, 13 June 2012 at 22:48:34 UTC, Jonathan M Davis wrote: On Thursday, June 14, 2012 00:32:45 BLM768 wrote: For some reason, whenever I declare a method with package visibility, it becomes non-virtual. Is this normal behavior, or is there a bug in DMD 2.059? Only public

Re: Package and virtual functions

2012-06-13 Thread BLM768
override will eventually be required when overriding a function. It is already if you compile with -w but not yet all of the time - though since protected isn't virtual and isn't really overriding anything, the compiler doesn't complain if you don't use override with it (though it will if

Re: Package and virtual functions

2012-06-13 Thread BLM768
True, but it will be explicit in the derived class code: No 'override', no function that is overridden. However, if a programmer expects it to override, there could be an issue. Imagine a novice D programmer who is not used to using override and looks at at the following code: class Base

Re: Package and virtual functions

2012-06-13 Thread BLM768
I guess that another solution to this whole mess is to just start requiring the use of override; then everyone would be educated and it would be obvious where the bug is in the code I posted. Since we don't want to break code, though, maybe there should be a message prominently displayed on

Calling main() from WinMain()

2012-06-05 Thread BLM768
I'm working on a cross-platform GUI library and I'd like to be able to call the user's main() function from WinMain() so users don't have to write both functions. However, I'm at a bit of a loss as to how to accomplish that. I know that D internally creates the extern(C) main(), which in turn

Re: Calling main() from WinMain()

2012-06-05 Thread BLM768
I've researched this some more, and it appears that WinMain() actually doesn't do any runtime initialization. That means I should be able to just call the C main from WinMain() and let it initialize the runtime and call _Dmain(). The main problem I have now is that as soon as I put main() in,