Re: Unexpected behavior when casting away immutable

2015-09-23 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 11:38:38 UTC, Mafi wrote: On Wednesday, 23 September 2015 at 05:24:05 UTC, John Colvin wrote: On Wednesday, 23 September 2015 at 03:39:02 UTC, Mike Parker wrote: ... ``` immutable int x = 10; int* px = cast(int*) *px = 9; writeln(x); ``` It prints 10,

Re: Unexpected behavior when casting away immutable

2015-09-22 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 03:50:44 UTC, Vladimir Panteleev wrote: On Wednesday, 23 September 2015 at 03:39:02 UTC, Mike Parker wrote: ``` immutable int x = 10; int* px = cast(int*) *px = 9; writeln(x); ``` It prints 10, where I expected 9. This is on Windows. I'm curious if anyone

Unexpected behavior when casting away immutable

2015-09-22 Thread Mike Parker via Digitalmars-d-learn
I have a situation where I would like to demonstrate violating the contract of immutable (as an example of what not to do), but do so without using structs or classes, just basic types and pointers. The following snippet works as I would expect: ``` immutable int i = 10; immutable(int*) pi =

Re: I can't get passing an array by reference to work anymore...

2015-09-24 Thread Mike Parker via Digitalmars-d-learn
On Friday, 25 September 2015 at 02:37:22 UTC, TheGag96 wrote: What's the problem here? I SWEAR I've passed arrays by reference before just like this. Thanks guys. I'm seeing the same error, but I haven't yet determined why. At any rate, this works: ``` import std.stdio; void append(ref

Re: final class & final methods

2015-09-25 Thread Mike Parker via Digitalmars-d-learn
On Friday, 25 September 2015 at 10:28:56 UTC, ref2401 wrote: If I declare a class as `final` do I have to mark all methods of the class as `final` too? A final class can't be subclassed, so none of its methods can be overridden anyway.

Re: Derelict3 object.Error@(0): Access Violation?

2015-11-27 Thread Mike Parker via Digitalmars-d-learn
On Friday, 27 November 2015 at 09:24:47 UTC, Alexander wrote: On Friday, 27 November 2015 at 07:53:09 UTC, Rikki Cattermole Ah ok! so here's my updated code. I still get the object error. I am trying to get a blank window to appear. I call the reload after I set the glfwcontext. I'm not

Re: Derelict3 object.Error@(0): Access Violation?

2015-11-27 Thread Mike Parker via Digitalmars-d-learn
On Friday, 27 November 2015 at 16:20:47 UTC, Mike Parker wrote: On Friday, 27 November 2015 at 07:53:09 UTC, Rikki Cattermole wrote: When you activate an OpenGL context you reload it. You do not do this when one is not activated. Doing so shouldn't cause an access violation, though. It

Re: Derelict3 object.Error@(0): Access Violation?

2015-11-27 Thread Mike Parker via Digitalmars-d-learn
On Friday, 27 November 2015 at 07:53:09 UTC, Rikki Cattermole wrote: When you activate an OpenGL context you reload it. You do not do this when one is not activated. Doing so shouldn't cause an access violation, though. It would be throwing a DerelictException saying that no context has

Re: Comparison operator overloading

2015-12-07 Thread Mike Parker via Digitalmars-d-learn
On Monday, 7 December 2015 at 11:49:51 UTC, Dominikus Dittes Scherkl wrote: On Sunday, 6 December 2015 at 15:01:08 UTC, cym13 wrote: Don't use opCmp, all binary operators should be overriden using opBinary. For more information I recommend this page

Re: Struct initializers as expressions

2015-12-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 December 2015 at 05:26:17 UTC, Chris Wright wrote: I can initialize a struct with named values: --- struct Foo { int i, j, k, l, m, n; } Foo f = {k: 12}; // other fields get default initialization --- I can initialize it with call syntax: --- auto f = Foo(0, 0, 12, 0, 0, 0);

Re: Struct initializers as expressions

2015-12-04 Thread Mike Parker via Digitalmars-d-learn
On Friday, 4 December 2015 at 10:42:46 UTC, Marc Schütz wrote: ; Then we can add some syntax sugar to leave out the braces, too: void bar(int a, T t) bar(42, a: "bla", b: "xyz"); This effectively gives us strongly typed named arguments, without making the names part of the function

Re: Are selective imports supposed to always be public?

2015-12-06 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 6 December 2015 at 10:31:58 UTC, tsbockman wrote: Why does this code compile? Shouldn't the `isIntegral` import be private to module `testB` unless I explicitly ask for it to be public? // testB.d module testB; import std.traits : isIntegral; // testA.d module testA; void

Re: Very very noobie question about how imports work.

2015-12-11 Thread Mike Parker via Digitalmars-d-learn
On Friday, 11 December 2015 at 03:51:35 UTC, tcak wrote: In D, directory structure doesn't matter. What matters is module names. Actually, it does matter sometimes. // src/foo/bar.d module foo.oops; // main.d import foo.oops; void main() {} Compile: dmd -Isrc main.d Result: main.d(1):

Re: AliasSeq can contain template identifier too?

2015-12-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 December 2015 at 14:15:37 UTC, Shriramana Sharma wrote: https://github.com/D-Programming-Language/phobos/blob/master/std/meta.d#L790 Looks like an AliasSeq can contain a template identifier too. So should I understand that AliasSeq in general can refer to any identifier and

Re: How to return user name from vibed session?

2015-12-10 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 10 December 2015 at 13:23:29 UTC, Suliman wrote: But question about why I need to get session info like: writeln("USER Session: ", req.session.get!string("username")); is still actual. When you have a template that looks like this: V get(V, K)(K key) {...} The compiler is

Re: How to return user name from vibed session?

2015-12-10 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 10 December 2015 at 13:46:19 UTC, Suliman wrote: because set return void, and get return T? No, it has nothing to do with the return type declarations. It's about whether or not the compiler has enough information to deduce the types. V get(V, K)(K key, V defaultVal); auto

Re: issue porting C++/glm/openGL to D/gl3n/openGL

2016-01-09 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 10 January 2016 at 02:51:57 UTC, WhatMeWorry wrote: Is gl3n not a direct replacement for glm? From the very top of the gl3n github page: "OpenGL Maths for D (not glm for D)." So, no, it is not. You might want to start with the glm documentaion [1]. [1]

Re: How to use GDC to get .a file on Linux?

2015-12-27 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 27 December 2015 at 15:19:21 UTC, FrankLike wrote: Hi, Now I need get the .a file on Linux,target system is ARM. If you use gcc ,you will use the 'ar' to get .a file, but how to do by GDC ? And how to get the execute file by .a file and .d file? Thank you. Just use ar on the

Re: Derelict GLFW3 glfw3.dll error

2015-11-27 Thread Mike Parker via Digitalmars-d-learn
On Friday, 27 November 2015 at 22:58:20 UTC, Alexander wrote: ERROR: "derelict.util.exception.SharedLibLoadException@..\..\AppData\Roaming\dub\packages\derelict-util-2.0.4\source\derelict\util\exception.d(35): Failed to load one or more shared libraries: glfw3.dll - The specified

Re: Derelict GLFW3 glfw3.dll error

2015-11-27 Thread Mike Parker via Digitalmars-d-learn
On Friday, 27 November 2015 at 22:58:20 UTC, Alexander wrote: import std.stdio; import derelict.opengl3.gl3; import derelict.glfw3.glfw3; pragma(lib, "C:\\Users\\Alexander\\AppData\\Roaming\\dub\\packages\\derelict-gl3-1.0.17\\lib\\DerelictGL3"); pragma(lib,

Re: Classes as enums in D?

2015-11-30 Thread Mike Parker via Digitalmars-d-learn
On Monday, 30 November 2015 at 07:58:43 UTC, Andrew LaChance wrote: Oh interesting. So you are saying I could have a struct WhiteKey {...} and then an enum that extends WhiteKey? enums can't *extend* anything. You can do this: struct WhiteKeyS { immutable int halfStepsToPrevious;

Re: D equivalent of Python's try..else

2015-11-21 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 21 November 2015 at 13:57:01 UTC, Shriramana Sharma wrote: Hmm – I forgot Python has `else` for `for` and `while` too. But it's a tad difficult to wrap one's mind around the meaning of the word `else` in this particular context whereas it actually means `nobreak`. Perhaps if

Re: issue porting C++/glm/openGL to D/gl3n/openGL

2016-01-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 10 January 2016 at 05:47:01 UTC, WhatMeWorry wrote: Thanks. Bummer. I really like gl3n, but glm/opengl is used almost exclusively in all the modern opengl code (tutorials) I've seen, so this might be a deal breaker. As the author of Derelict do you have any ideas of how much work

Re: LINK : fatal error LNK1104: cannot open file '_CMDLINE' --- errorlevel 1104

2016-01-11 Thread Mike Parker via Digitalmars-d-learn
On Monday, 11 January 2016 at 20:19:50 UTC, Jason Jeffory wrote: On Monday, 11 January 2016 at 20:17:23 UTC, Jason Jeffory wrote: Any ideas? Happens when I do a very simple dub project and try to compile using the MS linker(x86 but set in sc.ini or 64). I'm linking in glfw(using correct arch

Re: LINK : fatal error LNK1104: cannot open file '_CMDLINE' --- errorlevel 1104

2016-01-11 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 January 2016 at 01:44:17 UTC, Jason Jeffory wrote: So, how do I set the json to compile for x64? You don't. You pass -ax86_64 (or --arch=x86_64) on the command line. If you find that inconvenient, just make a batch file to do it for you.

Re: Setting up dmd properly

2016-01-11 Thread Mike Parker via Digitalmars-d-learn
On Monday, 11 January 2016 at 16:27:54 UTC, Jason Jeffory wrote: Anyway, regarding the static libs. I used this on a Win64 project and it works: "lflags" : [ "D:\\develop\\cairo\\cairo\\src\\release\\cairo-static.lib", "D:\\develop\\cairo\\libpng\\libpng.lib",

Re: LINK : fatal error LNK1104: cannot open file '_CMDLINE' --- errorlevel 1104

2016-01-11 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 January 2016 at 03:52:33 UTC, Mike Parker wrote: Actually, you could add -m64 in a dflags field (see [1]), but then you're in a situation where DUB thinks you're compiling in 32-bit, so configuration fields that are architecture-dependent will be off. [1]

Re: LINK : fatal error LNK1104: cannot open file '_CMDLINE' --- errorlevel 1104

2016-01-11 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 January 2016 at 03:47:35 UTC, Mike Parker wrote: On Tuesday, 12 January 2016 at 01:44:17 UTC, Jason Jeffory wrote: So, how do I set the json to compile for x64? You don't. You pass -ax86_64 (or --arch=x86_64) on the command line. If you find that inconvenient, just make a

Re: Setting up dmd properly

2016-01-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 January 2016 at 12:32:11 UTC, Mike Parker wrote: On Tuesday, 12 January 2016 at 08:42:19 UTC, Robert M. Münch wrote: I have seen countless problems because apps are using dynamic linking and whole IT environements getting into DLL hell. IMO one of the worst ideas these days.

Re: Setting up dmd properly

2016-01-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 January 2016 at 08:42:19 UTC, Robert M. Münch wrote: I have seen countless problems because apps are using dynamic linking and whole IT environements getting into DLL hell. IMO one of the worst ideas these days. I'm not talking about dynamic linking, but dynamic loading. This

Re: Anyone using glad?

2016-01-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 January 2016 at 19:16:51 UTC, Jason Jeffory wrote: So, I finally got it to work by abandoning demios and static linking. Derelict + dynamic linking worked with only about a min of problems(copying the proper dll to the correct place). Every operating system has a well-defined

Re: Setting up dmd properly

2016-01-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 January 2016 at 21:08:30 UTC, Jason Jeffory wrote: (I should mention that I am exaggerating a bit, and some of the complaints about D are actually more directed to the programming community in general. D has the same fundamental issues though and it is just a matter of scale.

Re: dlang.org using apache?

2016-06-08 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 8 June 2016 at 14:45:58 UTC, Mike Parker wrote: What does that have to do with the website? The forum software is written in D and has a reputation for performance. This is simply a matter of it not popping up

Re: dlang.org using apache?

2016-06-08 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 14:41:55 UTC, Ola Fosheim Grøstad wrote: But DMD also doesn't use the GC because it doesn't perform well enough. Stuff like this adds up. So I agree with you in essence, sending the message that there are things to avoid is not good in the long run. It might

Re: Windows system casting

2016-06-06 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 04:06:01 UTC, Mike Parker wrote: Fourth, while casting the string directly to void* will work, it's considered best practice to use the pointer property for clarity. Oops! cast(void*)path.ptr In both cases. Like I said, without .ptr, it works, but this makes

Re: How to enable feedback for AssertError?

2016-06-06 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 02:05:00 UTC, Seb wrote: On Tuesday, 7 June 2016 at 01:40:01 UTC, your_name wrote: The way I traced the problem, ironically ;), was to catch Error and print it to screen. It involved dereferencing a null pointer in a thread and an 'assert null this' silently killed

Re: Windows system casting

2016-06-06 Thread Mike Parker via Digitalmars-d-learn
On Monday, 6 June 2016 at 19:52:36 UTC, Alexander Patapoff wrote: import std.stdio; import std.string; import core.sys.windows.windows; void main() { string filepath = "C:\\Users\\awpat\\Pictures\\patterns_00387591.jpg"; auto p = toStringz(filepath); int result;

Re: dlang.org using apache?

2016-06-08 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 13:13:07 UTC, Jonathan Marler wrote: I've decided to write a web application using vibe and was shocked to see that dlang.org was using apache. Should I be scared that even after this long, the official D website doesn't rely on its own web tools? No, you

Re: Implicit conversion of struct to bool for if (s) operation ?

2016-06-07 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 22:28:57 UTC, Steven Schveighoffer wrote: It's news to me that while opCast for all other types is for explicit casting, opCast for bool works for implicit casting. as ag0... mentioned in another thread, opCast is NOT implicitly being invoked here, but rather

Re: core.sys.windows so lean?

2016-06-06 Thread Mike Parker via Digitalmars-d-learn
On Monday, 6 June 2016 at 16:51:20 UTC, Jonathan Marler wrote: Hmmm...it seems to be missing quite alot though. Especially the winsock api. Over the weekend I was writing some code that uses a windows IOCompletionPort and had to add a fair amount of code that was missing: Pull requests

Re: Gotchas for returning values from blocks

2016-06-12 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 12 June 2016 at 18:24:58 UTC, jmh530 wrote: garbage collected variable and assign it to it. Everything seems to work fine. I'm just not sure if there are any gotchas to be aware of. class Foo { int baz = 2; } void main() { import std.stdio : writeln;

Re: Accessing COM Objects

2016-06-12 Thread Mike Parker via Digitalmars-d-learn
On Monday, 13 June 2016 at 01:22:33 UTC, Incognito wrote: I can do this stuff in C# by simply dragging and dropping a dll into the references and it works fine but is a bit slow. I was hoping I could speed things up using D but it seems like COM isn't really supported, despite what several

Re: interfacing with C: strings and byte vectors

2016-06-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 June 2016 at 09:32:54 UTC, yawniek wrote: so far i defined vec_t as: struct vec_t { char *base; size_t len; this(string s) { base = s.ptr; len = s.lenght; } nothrow @nogc inout(char)[] toString() inout @property { return base[0 .. len]; } nothrow @nogc

Re: Accessing COM Objects

2016-06-12 Thread Mike Parker via Digitalmars-d-learn
On Monday, 13 June 2016 at 02:08:22 UTC, Incognito wrote: What interface are you talking about? How can I cast to something I don't have? I do not have a photoshop COM interface. Are you saying that if CoCreateInstance worked that I can then use the iid or pUnk to access the COM? Do I get the

Re: Accessing COM Objects

2016-06-12 Thread Mike Parker via Digitalmars-d-learn
On Monday, 13 June 2016 at 04:52:49 UTC, Mike Parker wrote: On Monday, 13 June 2016 at 02:08:22 UTC, Incognito wrote: What interface are you talking about? How can I cast to something I don't have? I do not have a photoshop COM interface. Are you saying that if CoCreateInstance worked that I

Re: Cannot find module during separate compilation

2016-06-10 Thread Mike Parker via Digitalmars-d-learn
On Friday, 10 June 2016 at 15:20:21 UTC, Satoshi wrote: Hello, I have 2 files: source/test.d: module foo.test; and source/bar.d module foo.bar; import foo.test; When I am compiling this 2 files together there is no problem. But when I compile it with -c flag (LDC) compiler thrown an error

Re: What's up with GDC?

2016-06-10 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 June 2016 at 04:20:38 UTC, Joerg Joergonson wrote: On Saturday, 11 June 2016 at 01:43:21 UTC, Adam D. Ruppe wrote: What's the exact message and what did you do? The opengl32.lib I have on my github is for dmd 32 bit, ldc uses the Microsoft one I think so you shouldn't need

Re: What's up with GDC?

2016-06-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 June 2016 at 08:48:42 UTC, Mike Parker wrote: Alternatively, you might try one of the dynamic bindings[1] to a library you need, such as DerelictGL3. Then there is no link [1] https://github.com/DerelictOrg

Re: What's up with GDC?

2016-06-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 June 2016 at 06:22:27 UTC, Joerg Joergonson wrote: OpenGL32.lib and glu32.lib are part of the Windows SDK. Assuming you've got VS 2015 installed, they should be part of the installation and should be available out of the box. Adam's lib is solely for use with OPTLINK when

Re: What's up with GDC?

2016-06-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 June 2016 at 08:48:42 UTC, Mike Parker wrote: it looks win the dmd2/windows/lib directory. Since opengl32 and glu32 do not ship with DMD, it will not find them there. So you either need to put COFF format libs there or tell the compiler Obviously, I meant 'OMF format' here.

Re: stretto...@tutanota.com

2016-06-09 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 9 June 2016 at 22:19:33 UTC, Stretto wrote: I have some class like class bar { } class foo : bar { bar[] stuff; } and have another class class dong : bar { int x; } Now sometimes stuff will contain dong's, but I cannot access its members it without a cast.

Re: is my code to get CTFE instantiated object valid D ?

2016-05-28 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 28 May 2016 at 08:34:17 UTC, Mike Parker wrote: const(F) cf = f; immutable(f) if = f; And, of course, those should be const(Foo) and immutable(Foo).

Re: is my code to get CTFE instantiated object valid D ?

2016-05-28 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 28 May 2016 at 05:30:26 UTC, chmike wrote: What is the difference between a const and immutable object ? would a const object be allowed to modify itself by using a hash table or caching results inside ? The difference lies in the guarantees of const and immutable. Foo f = new

Re: What's up with GDC?

2016-06-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 June 2016 at 14:10:07 UTC, Johan Engelen wrote: On Saturday, 11 June 2016 at 08:48:42 UTC, Mike Parker wrote: [... a lot ...] This looks like a nice writeup Mike, could you get this on the Wiki or somewhere more permanent where people can find it? -Johan I've been meaning

Re: What's up with GDC?

2016-06-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 12 June 2016 at 01:51:05 UTC, Joerg Joergonson wrote: Well, it's definitely not as simple as you make it out to be. I have tried all kinds of combinations of libs and settings and nothing works. If it's not one error it's another and it becomes hard to know exactly what is going

Re: What's up with GDC?

2016-06-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 12 June 2016 at 03:11:14 UTC, Mike Parker wrote: I think that's reasonable. All three compilers share the same Sorry, I mean I *don't* think that's reasonable.

Re: No triangle with OpenGL (DerelictGLFW and DerelictGL3)

2016-06-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 12 June 2016 at 02:16:52 UTC, Peter Lewis wrote: Hi all. I am trying to create a basic OpenGL triangle in a GLFW instance. The window works, I can change the background colour and everything but for the life of me I can't get the triangle to show up. Instead of trying to put

Re: What's up with GDC?

2016-06-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 12 June 2016 at 02:09:24 UTC, Joerg Joergonson wrote: Ok, So I started an empty project and I found all the libs that are required from all of VS, SDK, LDC, DMD, etc and put them in 4 folders: Libs\COFF\x86 Libs\COFF\x64 Libs\OMF\x86 Libs\OMF\x64 There's no need for OMF\x64.

Re: What's up with GDC?

2016-06-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 12 June 2016 at 04:19:33 UTC, Joerg Joergonson wrote: 1. I had an older distro(I think) of ldc. The ldc2.exe is 18MB while the "new" one is 36MB. I copied the old ldc bin dir to the new one and didn't change anything and everything compiled EXCEPT That's just asking for

Re: Strange Issues regarding aliases

2016-06-15 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 14 June 2016 at 17:37:40 UTC, Joerg Joergonson wrote: On Tuesday, 14 June 2016 at 17:34:42 UTC, Joerg Joergonson wrote: This is how derelict does it, I simply moved them in to the class for simplicity. I mean glad: http://glad.dav1d.de/ It seems that a loader is required for

Re: Is it possible to use a template to choose between foreach and foreach_reverse?

2016-06-04 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 4 June 2016 at 21:52:31 UTC, AbstractGuy wrote: On Saturday, 4 June 2016 at 17:16:45 UTC, pineapple wrote: Won't this pattern fail if items is a type implementing opApply and/or opApplyReverse? opApply/ApplyReverse predates the detection of the input/bidir range primitives. It's

Re: dlang.org using apache?

2016-06-08 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 14:33:50 UTC, Jonathan Marler wrote: On Wednesday, 8 June 2016 at 13:32:00 UTC, Mike Parker wrote: Why would we change over when Apache is working quite happily to serve up static content? I didn't say that. Rikki did :) If the official D website doesn't feel

Re: Legal operator overloading

2016-05-30 Thread Mike Parker via Digitalmars-d-learn
On Monday, 30 May 2016 at 05:54:42 UTC, Nicholas Wilson wrote: Is it legal/possible to overload the unary * operator? Also is it legal/possible to individually overload the comparison operators and not return a bool? Yes to unary * (see [1]). No to the rest. Comparisons are always lowered to

Re: is my code to get CTFE instantiated object valid D ?

2016-05-28 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 28 May 2016 at 15:39:44 UTC, ag0aep6g wrote: On 05/28/2016 10:34 AM, Mike Parker wrote: On Saturday, 28 May 2016 at 05:30:26 UTC, chmike wrote: [...] Is a static const Category c variable a TLS variable ? Yes. All variables are TLS unless explicitly marked with __gshared or

Re: is my code to get CTFE instantiated object valid D ?

2016-05-28 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 29 May 2016 at 05:35:33 UTC, Mike Parker wrote: Well then, this completely breaks my understanding of variable scope. OK, I see now at [1] the following: " Immutable data doesn't have synchronization problems, so the compiler doesn't place it in TLS." I've read that page more

Re: Calling C++ code with pointer** argument

2016-06-01 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 07:09:16 UTC, abad wrote: D source: extern(C++) void thisWorks(const char* test); extern(C++) void doesNotLink(const char** test); void main() { char* baz1; char** baz2; thisWorks(baz1); doesNotLink(baz2); } CPP source: #include void

Re: Using .lib and .dll in D applications

2016-06-21 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 21 June 2016 at 23:59:54 UTC, moe wrote: I had some time to try it out and I finally got it to work. I have only tried in windows so far but there was a pitfall in windows. Your dll need a DllMain entry to compile. This was the only thing that was missing from your information.

Re: Using .lib and .dll in D applications

2016-06-21 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 03:06:29 UTC, moe wrote: I meant like this: - PluginContract // not a dub project, just some folder -- iplugin.d - TestApp // all files for the app (separate project) -- packages DerelictUtil-master // contains the project for derelict -- source app.d

Re: blog.dlang.org

2016-06-21 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 21 June 2016 at 21:47:46 UTC, Christian Köstlin wrote: I just wanted to have a look at the new blog post about ldc, and entered blog.dlang.org without thinking into the browser. This does not lead to the official blog anymore, but to the old digitalmars website. When we first

Re: Using .lib and .dll in D applications

2016-06-21 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 02:38:23 UTC, moe wrote: Yes, I did it intentionally. I wanted to ensure that the packages are self contained and check whether it would work fine like this. Basically I like to have a project that contains everything it needs with the versions originally used

Re: Using .lib and .dll in D applications

2016-06-19 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 19 June 2016 at 15:35:04 UTC, moe wrote: I am new to d and doing some small test apps at the moment to learn d. Currently I must be missing something basic here. I have installed dub as a project manager and I am trying to use a .lib file in an app. However, I can not use a module

Re: Issues getting DCD to work on Windows

2016-06-17 Thread Mike Parker via Digitalmars-d-learn
On Friday, 17 June 2016 at 16:58:42 UTC, OpenJelly wrote: Trying to set up an IDE on Windows 7 with code completion but my issues keep coming back to DCD. The tests failed the one time I could get the tests to go beyond it waiting for another instance of DCD to close. The path is added to my

Re: Using .lib and .dll in D applications

2016-06-19 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 19 June 2016 at 18:33:36 UTC, moe wrote: I see where I went wrong. I thought that it's possible to only use the .lib file without the source code of dbar. Having access to the source makes what I am trying somewhat pointless. Is it otherwise possible to provide some functionality

Re: Why do I get this error when casting to an immutable or shared byRef return type?

2016-06-19 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 19 June 2016 at 10:45:25 UTC, Gary Willoughby wrote: On Sunday, 19 June 2016 at 10:35:59 UTC, Gary Willoughby wrote: ... A more correct example: In the second example, the problem is this: alias Type = Unqual!(T); You are declaring the function to return T, which in your

Re: Using .lib and .dll in D applications

2016-06-19 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 19 June 2016 at 17:33:43 UTC, moe wrote: Unfortunatelly I still don't get it. I would like to have an independant project "dbar". The created lib is then used in another project "dfoo". Assuming that "dfoo" has no access to "dbar" other than the .lib file. You can't do it

Re: Static function as member delegate's initial value?

2016-06-20 Thread Mike Parker via Digitalmars-d-learn
On Monday, 20 June 2016 at 13:20:04 UTC, OpenJelly wrote: I've got a delegate as a member of a class and I want to give it a default value. I can assign it an initial value in each initializer of the class but I'd like to make my code more readable and assign it a function at the declaration.

Re: Using .lib and .dll in D applications

2016-06-20 Thread Mike Parker via Digitalmars-d-learn
interface Plugin { bool initialize(); void terminate(); Throwable getLastException(); SomeObject getSomeObject(); void returnSomeObject(SomeObject); } Sorry, I forgot a couple of commments. I did explain it in the text, though. It was supposed to read: interface Plugin {

Re: Static function as member delegate's initial value?

2016-06-20 Thread Mike Parker via Digitalmars-d-learn
On Monday, 20 June 2016 at 13:54:22 UTC, Mike Parker wrote: The best you can do is assign it in a constructor. Well, 'initialize' it in a constructor.

Re: Using .lib and .dll in D applications

2016-06-20 Thread Mike Parker via Digitalmars-d-learn
On Monday, 20 June 2016 at 11:25:04 UTC, moe wrote: Where I still have a problem is with a plugin system. I would like to write an app that is plugin based. So that I can write a plugin to extend the functionality of the app. I imagine that I could copy the plugin into a folder from the

Re: Meaning of const variables

2016-06-21 Thread Mike Parker via Digitalmars-d-learn
behavior is identical. And really, if you never need to take the address of the variable, then a manifest constant using enum would be more appropriate. Actually, I should say it *may* be more appropriate. Definitely only when the initializer is known at compile time. There are cases when

Re: Get calling this, if exists

2016-06-23 Thread Mike Parker via Digitalmars-d-learn
On Friday, 24 June 2016 at 02:57:28 UTC, "Smoke" Adams wrote: Is there a type of __THIS__ construct similar to __FILE__ and __LINE__? Something that returns the current this ptr if it exists, null otherwise. Log(string filename = __FILE__, Object obj = __THIS__)() { // inspect obj and do

Re: Get calling this, if exists

2016-06-23 Thread Mike Parker via Digitalmars-d-learn
On Friday, 24 June 2016 at 03:04:25 UTC, Mike Parker wrote: On Friday, 24 June 2016 at 02:57:28 UTC, "Smoke" Adams wrote: Is there a type of __THIS__ construct similar to __FILE__ and __LINE__? Something that returns the current this ptr if it exists, null otherwise. Log(string filename =

Re: DUB - link error on Windows 10 64-bit

2016-01-16 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 16 January 2016 at 20:28:02 UTC, Dibyendu Majumdar wrote: I have installed DMD by unzipping the DMD archive (The installer does not work correctly on Windows 10). DUB installed as normal. What problem did you have with the installer? Which version? I've installed DMD more

Re: DUB - link error on Windows 10 64-bit

2016-01-16 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 17 January 2016 at 02:48:47 UTC, Mike Parker wrote: On Saturday, 16 January 2016 at 20:28:02 UTC, Dibyendu Majumdar wrote: I have installed DMD by unzipping the DMD archive (The installer does not work correctly on Windows 10). DUB installed as normal. What problem did you

Re: DUB - link error on Windows 10 64-bit

2016-01-16 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 16 January 2016 at 21:51:15 UTC, Dibyendu Majumdar wrote: Well as far as I can tell they are correct (unchanged from whatever the installer set them to): ; environment for both 32/64 bit [Environment] DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src\druntime\import" ;

Re: DUB & Win-10 SDK / link lib not found

2016-01-14 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 14 January 2016 at 22:13:37 UTC, Robert M. Münch wrote: Seems that some paths in sc.ini were not setup correctly. For x64 a Win10-SDK directory which doesn't exists was referenced. Did you install DMD manually? In that case, you will usually need to edit sc.ini to point to

Re: Doubt - Static multidimension arrays

2016-01-18 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 07:21:39 UTC, albert00 wrote: On Tuesday, 19 January 2016 at 04:50:18 UTC, tsbockman wrote: On Tuesday, 19 January 2016 at 03:20:30 UTC, albert00 wrote: [...] ... what you're making is an array *of arrays*: Maybe I was misunderstood, because in fact that is

Re: Doubt - Static multidimension arrays

2016-01-18 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 07:32:22 UTC, tsbockman wrote: That's because you're stuck in the mindset that 2d arrays are somehow *special*. If I do this: It's not that he's seeing them as special, it's just that indexing them in D is different than doing so in C or C++. It trips a lot

Re: print function

2016-02-04 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 4 February 2016 at 10:18:35 UTC, ixid wrote: On Thursday, 4 February 2016 at 10:05:15 UTC, Jonathan M Davis wrote: I would normally expect someone to do that with writefln, which would be cleaner. e.g. writefln("%s %s %s %s", a, b, c, d); Personally, I've never felt the need for

Re: Cannot get Derelict to work

2016-02-07 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 7 February 2016 at 12:55:30 UTC, Whirlpool wrote: Is it the same kind of problem as before ? If my understanding is correct [1], I need to link with the OpenGL DLL, don't I ? I found that I have an opengl32.dll file in C:\Windows\System32, and tried adding the path to it in the

Re: Cannot get Derelict to work

2016-02-07 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 7 February 2016 at 14:04:49 UTC, Mike Parker wrote: Another point to make is that if you need deprecated functions, DerelictGL3 is not what you want. You should import derelict.opengl3.gl and use DerelictGL.load/reload instead. It includes all of the deprecated functions. Just

Re: How to allocate arrays of objects?

2016-02-10 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 11 February 2016 at 04:07:18 UTC, cy wrote: The following program segfaults for me, compiling it with dmdv2.070 as well as the latest git. I must be doing it wrong. There's a way to specify class construction, or emplace, or something. But I can't find it! How do I deal with

Re: How to allocate arrays of objects?

2016-02-10 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 11 February 2016 at 04:31:12 UTC, cy wrote: Oh, I get it. `as` is an array of 2 pointers to A objects, both pointers set to null. So I need to say like: as[0..$] = new A(); before accessing .stuff on as[0]. Pedantically, no. It's an array of two class references. I don't

Re: Overriding opEquals in classes, for comparison with things that aren't Objects

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Friday, 29 January 2016 at 15:00:59 UTC, pineapple wrote: With this bit of code, the first method seems to work fine - things go as expected. But I get a compile error with the second method, and I'm not sure how else to write this. override bool opEquals(Object value) const{

Re: Why is it a memory ERRO.

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Friday, 29 January 2016 at 13:22:07 UTC, Mike Parker wrote: Your problem is probably that you are calling GC.free in the destructor. Don't do this. You don't need to call GC.free at all. The GC will collect both your object instance and the memory you allocated with new. Never, ever,

Re: Why is it a memory ERRO.

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Friday, 29 January 2016 at 12:43:53 UTC, Dsby wrote: the Code: ~this(){ GC.free(by.ptr); by = null; writeln("free"); } Your problem is probably that you are calling GC.free in the destructor. Don't do this. You don't need

Re: how to allocate class without gc?

2016-01-25 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 01:09:50 UTC, Igor wrote: Is there any examples that shows how to properly allocate an object of a class type with the new allocators and then release it when desired? Allocate a block of memory big enough to hold an instance of your class using whichever

Re: New Win32 Core api broke?

2016-01-25 Thread Mike Parker via Digitalmars-d-learn
On Monday, 25 January 2016 at 22:57:22 UTC, Igor wrote: error LNK2019: unresolved external symbol GetStockObject referenced in function _D2Application10createWindowMFPFZvZi (int Application.createWindow(void function()*)) and the line of code is wc.hbrBackground =

Re: New Win32 Core api broke?

2016-01-25 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 05:05:43 UTC, Mike Parker wrote: the linker looked for its copied form *compiled* form

Re: Binding to C - Arrays and Access Violation

2016-02-02 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 2 February 2016 at 22:56:28 UTC, jmh530 wrote: My D code calls a C function. One of the parameters to the C function is a function pointer to a D function. This D function (below) is one that I copied from the C library's tutorial. I only slightly changed the signature. This

<    1   2   3   4   5   6   7   8   9   10   >