Re: how to declare an immutable class?

2016-08-11 Thread Mike Parker via Digitalmars-d-learn
On Friday, 12 August 2016 at 04:49:46 UTC, Charles Hixson wrote: It works, it's just not the syntax that I'd prefer. And it leaves me wondering exactly what immutable class Msg {...} was declaring. This should demonstrate: ``` immutable class iMsg { int getX() { return 10; } } class

Re: How to use std. packages in so files written in dlang

2016-08-11 Thread Mike Parker via Digitalmars-d-learn
On Friday, 12 August 2016 at 01:36:34 UTC, grampus wrote: On Friday, 12 August 2016 at 01:09:47 UTC, ketmar wrote: On Friday, 12 August 2016 at 00:57:42 UTC, grampus wrote: it's 'cause you didn't initialized druntime. you have to use dlsym to get "rt_init" function and call it right after

Re: How to use std. packages in so files written in dlang

2016-08-11 Thread Mike Parker via Digitalmars-d-learn
On Friday, 12 August 2016 at 00:57:42 UTC, grampus wrote: Hi,erveryone I am trying to use dLang to make so file for existing c/c++ project. I followed the examples on https://dlang.org/dll-linux.html, which works well. but when I replaced import core.stdc.stdio; with import std.stdio; to

Re: how to declare an immutable class?

2016-08-11 Thread Mike Parker via Digitalmars-d-learn
On Friday, 12 August 2016 at 00:44:31 UTC, Charles Hixson wrote: A way around this, which may be the same as the approach used by string was: alias immutable(Msg_)Msg; classMsg_ { ... This is exactly what Jonathan suggested in the post above. And yes, it's how string is handled:

Re: Using D in Games and bindings to c++ libraries

2016-08-06 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 6 August 2016 at 11:18:11 UTC, rikki cattermole wrote: For 32bit I use a hack of a workaround to make it work recursively. $ DFLAGS="-m32mscoff" ; dub build Sadly this is not full proof or much help. For clarity, what rikki is getting at here is that DUB does not yet support

Re: Instantiate C struct on heap

2016-08-04 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 4 August 2016 at 23:49:26 UTC, Mike Parker wrote: C structs can be created with new just like D structs as long For clarity, in a D binding to a C library, a C struct *is* a D struct. If they are declared as extern(C), that affects the name of the symbol and how it exists in

Re: Instantiate C struct on heap

2016-08-04 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 4 August 2016 at 21:02:59 UTC, TencoDK wrote: Hey, I'm using DerelictSFML2 + CSFML, I have stuck on instantiating window. derelict/window.d (binding from C): struct sfWindow; my_file.d: sfWindow* sfmlWindow = null; sfmlWindow = new sfWindow; // ??? This code snippet gives me:

Re: [Derelict-Lua] compiler error when lua_register is called

2016-08-02 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 14:23:55 UTC, Jack wrote: So basically I get the error "function button(lua_State* L) is not callable using argument types ()" whenever I try to lua_register a function. ``` lua_register(L,"button",button); ``` but whenever I use the function pointer I get the

Re: Struct dtor on ref variable

2016-08-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 1 August 2016 at 16:18:32 UTC, Patric wrote: But still. If it was the case of "+=" wasn´t wrong to call the dtor since is a ref var? No. It was working as expected. You never implemented opAssign, so default assignment was being used. There was no ref variable.

Re: Struct dtor on ref variable

2016-08-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 1 August 2016 at 16:17:02 UTC, Patric wrote: On Monday, 1 August 2016 at 16:05:51 UTC, Steven Schveighoffer wrote: On 8/1/16 12:01 PM, Patric wrote: I expected nothing to happen because "ref" its a simple pointer, right? Or I am missing something here? You want opAssign, not

Re: Struct dtor on ref variable

2016-08-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 1 August 2016 at 16:14:31 UTC, Patric wrote: On Monday, 1 August 2016 at 16:05:51 UTC, Steven Schveighoffer wrote: On 8/1/16 12:01 PM, Patric wrote: I expected nothing to happen because "ref" its a simple pointer, right? Or I am missing something here? You want opAssign, not

Re: C's void func() vs. void func(void).

2016-07-29 Thread Mike Parker via Digitalmars-d-learn
On Friday, 29 July 2016 at 18:24:52 UTC, ag0aep6g wrote: On 07/29/2016 02:15 PM, Mike Parker wrote: And if it is a cross-platform library that is stdcall on Windows and cdecl elsewhere: extern(C) void fun(); extern(System), no? Yeah, that's what I had intended.

Re: C's void func() vs. void func(void).

2016-07-29 Thread Mike Parker via Digitalmars-d-learn
On Friday, 29 July 2016 at 12:15:22 UTC, Mike Parker wrote: Yes, this is correct as long as the calling convention is not stdcall or something else: Though, I should add the caveat that you need to ensure the definition of the C function does not specify any parameters. AFAIK, this is

Re: C's void func() vs. void func(void).

2016-07-29 Thread Mike Parker via Digitalmars-d-learn
On Friday, 29 July 2016 at 10:57:37 UTC, ciechowoj wrote: In C, a function `void func()` doesn't declare a function without arguments, instead it declares a function that takes unspecified number of arguments. The correct way to declare a function that takes no arguments is to use the `void`

Re: Anybody use FreeImage on Linux with D?

2016-07-27 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 23:59:15 UTC, WhatMeWorry wrote: I've been stumped for several days trying to resolve this run time error. I'm pretty new with Linux. No problem on Windows. DerelictFI.load("/home/generic/MySharedLibraries/libfreeimage.so"); before DerelictFI.load

Re: Trouble checking for null-ness

2016-07-25 Thread Mike Parker via Digitalmars-d-learn
On Monday, 25 July 2016 at 12:37:18 UTC, Bahman Movaqar wrote: Suppose I have the following function: public auto max(alias comp, Range)(Range r) in { assert(r !is null && !r.empty); } body { // ... } When the function after a series of chained `map` operations,

Re: shuffle a character array

2016-07-20 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 20 July 2016 at 16:44:11 UTC, ketmar wrote: On Wednesday, 20 July 2016 at 13:33:34 UTC, Mike Parker wrote: There is no auto-decoding going on here, ... as char[] and wchar[] are rejected outright since they are not considered random access ranges. ...due to autodecoding. No,

Re: shuffle a character array

2016-07-20 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 20 July 2016 at 16:08:26 UTC, pineapple wrote: Pardon my being scatterbrained (and there not being an "edit post" function) - you're referring to phobos not considering char[] and wchar[] to have random access? The reason they are not considered to have random access is

Re: shuffle a character array

2016-07-20 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 20 July 2016 at 10:40:04 UTC, pineapple wrote: On Wednesday, 20 July 2016 at 08:02:07 UTC, Mike Parker wrote: You can then go to the documentation for std.range.primitives.isRandomAccessRange [2], where you'll find the following: "Although char[] and wchar[] (as well as their

Re: shuffle a character array

2016-07-20 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 20 July 2016 at 08:18:55 UTC, celavek wrote: As far as my current understanding goes the shuffle will be done in place. If I use the "representation" would that still hold, that is will I be able to use the same char[] but in the shuffled form? (of course I will test that)

Re: shuffle a character array

2016-07-20 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 20 July 2016 at 08:05:20 UTC, Mike Parker wrote: On Wednesday, 20 July 2016 at 08:02:07 UTC, Mike Parker wrote: On Wednesday, 20 July 2016 at 07:49:38 UTC, celavek wrote: If you are absolutely, 100% certain that you are dealing with ASCII, you can do this: And I forgot to

Re: shuffle a character array

2016-07-20 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 20 July 2016 at 08:02:07 UTC, Mike Parker wrote: On Wednesday, 20 July 2016 at 07:49:38 UTC, celavek wrote: If you are absolutely, 100% certain that you are dealing with ASCII, you can do this: And I forgot to add: Otherwise, you'll want to convert to dchar[] (probably via

Re: shuffle a character array

2016-07-20 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 20 July 2016 at 07:49:38 UTC, celavek wrote: I thought that I could use a dynamic array as a range ... You can. However, if you take a look at the documentation for std.random.randomShuffle [1], you'll find the following constraint: if (isRandomAccessRange!Range); You can

Re: How to get the "this" ptr of a lambda inside the lambda?

2016-07-19 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 19 July 2016 at 06:32:32 UTC, Rufus Smith wrote: Error: 'this' is only defined in non-static member functions, not __lambda2 Lambda's are delegates and delegates have a "this" type of pointer. I would like to get at it inside the lambda to check for some things. I'm doing some

Re: Are templates with variadic value parameters possible?

2016-07-15 Thread Mike Parker via Digitalmars-d-learn
On Friday, 15 July 2016 at 15:04:22 UTC, Devin Hill wrote: to the condition. It works pretty well! Granted, it doesn't allow for calling it in two ways like a variadic version would have: foo(1, 2, 3) // works with this setup foo([1, 2, 3]) // doesn't, but would only be occasionally

Re: C++ interface vs D and com

2016-07-13 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 21:27:29 UTC, Adam Sansier wrote: Yes! your right, If you were only around to tell me that in the first place! ;) Now we know. Again, as I said before, the problem is informational. Maybe because come works 99% of the time doesn't help us in the 1% if some

Re: mismatch and return value

2016-07-13 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 11:11:51 UTC, celavek wrote: Thank you for the example. I misunderstood the doc and I got a bit confused by the range - in C++ I would have incremented the iterators but here I did not know what to do exactly as I could not match the 2 different concepts in

Re: mismatch and return value

2016-07-13 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 11:10:11 UTC, ketmar wrote: On Wednesday, 13 July 2016 at 11:06:56 UTC, celavek wrote: On Wednesday, 13 July 2016 at 10:41:44 UTC, ketmar wrote: I understand your point but it should not be a matter of guessing. It should be explicitly stated by the

Re: mismatch and return value

2016-07-13 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 09:59:30 UTC, celavek wrote: Hi, I am trying to use the function "mismatch" from std.algorithm.comparison like so: int count = 0; auto m = mismatch(lhs, rhs); while (!m[0].empty) { ++count; m = mismatch(m[0], m[1]); } That goes into an infinite loop.

Re: mismatch and return value

2016-07-13 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 09:59:30 UTC, celavek wrote: As a side note the documentation of the standard library is not digestible to say the least - there is missing info(e.g. what does mismatch return if no mismatch found) and lacks user-friendliness and details. Whenever you find

Re: C++ interface vs D and com

2016-07-13 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 06:44:36 UTC, Adam Sansier wrote: Regardless of what you think, I can prove that the code won't work when it is marked extern(Windows) and works when it is marked extern (C++)... so what you should be asking yourself is why it is doing that rather than assuming

Re: C++ interface vs D and com

2016-07-12 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 02:49:54 UTC, Adam Sansier wrote: On Wednesday, 13 July 2016 at 02:34:14 UTC, Mike Parker wrote: What happens when you declare an interface that extends from IUnknown (and not extern(C++)), then cast the pointer returned from the COM API? It should just work

Re: C++ interface vs D and com

2016-07-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 23:55:55 UTC, Adam Sansier wrote: Ok, Another hack: iInterface x; void** y = cast(void**) *y = malloc(iInterface.sizeof); x.__vptr = cast(immutable(void*)*)(*ptr);

Re: Passing ranges around

2016-07-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 07:50:34 UTC, Bahman Movaqar wrote: On 07/12/2016 11:07 AM, Mike Parker wrote: auto foo(R)(R r) { ... } That did it. Thanks. Out of curiosity, does the same pattern apply to functions which take `tuple`s as input arguments? It's just a function template. It's

Re: Docs for `Group` type

2016-07-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 08:03:53 UTC, Bahman Movaqar wrote: On 07/12/2016 11:06 AM, Mike Parker wrote: The 'Group' type is an implementation detail -- a type used internally -- that you aren't supposed to care about. All you need to care about is that it's a range. The documentation for

Re: Passing ranges around

2016-07-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 03:57:09 UTC, Bahman Movaqar wrote: What should be signature of `foo` in the following piece of code? auto foo(range r) { // do something with the `r` } void main() { foo([1,2,3].map!(x => x*x)); } auto foo(R)(R r) { ... }

Re: Docs for `Group` type

2016-07-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 04:25:26 UTC, Bahman Movaqar wrote: When using `chunkBy` (unary pred) the result is a list of tuples. Each tuple holds a key and a `Group` which belong to that key. Where can I find the docs for this `Group` type (I have already tried searching library on

Re: protected + package attributes

2016-07-11 Thread Mike Parker via Digitalmars-d-learn
On Monday, 11 July 2016 at 12:42:57 UTC, ag0aep6g wrote: Other than that, you could add a `package` method with a different name that just calls the `protected` one. This is a pattern I have found useful, particularly when dealing with protected abstract methods, e.g. package void

Re: How to use `format` to repeat a character

2016-07-11 Thread Mike Parker via Digitalmars-d-learn
On Monday, 11 July 2016 at 10:23:24 UTC, Bahman Movaqar wrote: On 07/11/2016 02:44 PM, ketmar wrote: On Monday, 11 July 2016 at 09:31:49 UTC, Ali Çehreli wrote: What makes you expect that format should have that feature? :) I somehow recalled I could do that in C and then there was the

Re: shared not working!

2016-07-03 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 3 July 2016 at 23:20:35 UTC, Hiemlick Hiemlicker wrote: The only difference is that the thread is a windows CreateThread. I guess D doesn't know about such threads and hence shared doesn't extend across to them? The runtime doesn't know about external threads, no. You have to

Re: static __gshared struct

2016-07-01 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 2 July 2016 at 00:08:10 UTC, Hiemlick Hiemlicker wrote: I use a struct with static members so I do not have to instantiate it. It is essentially a singleton. I want all the variables to be __gshared. I guess I have to prefix all variables with it? Basically I have Foo.i; on

Re: What's the secret to static class members

2016-06-29 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 29 June 2016 at 19:10:18 UTC, chmike wrote: Claiming the problems you encountered are due to bad design of the language is unfair if you don't expose clearly the problem and verify the problem is not your side. There is a deeply thought rationale for every rule of the D

Re: What's the secret to static class members

2016-06-29 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 29 June 2016 at 15:33:58 UTC, Guido wrote: The problem is actually much more profound. The classes need to be declared outside the main() scope. WTF?!?!?! It's not going to work anywhere if you type 'Class' as opposed to 'class'. Types can be declared in any scope: ``` void

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: 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: 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: 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-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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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 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: 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 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: 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: 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 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: 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-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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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 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: 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 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: Is there a way to make a class variable visible but constant to outsiders, but changeable (mutable) to the class itself?

2016-05-22 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 22 May 2016 at 19:29:59 UTC, Meta wrote: Const *is* necessary to prevent _myVar being written to through code like: f.myVar = 4; Of course this isn't necessary for value types, but for reference types. I was referring specifically to marking the function const, not the

Re: Is there a way to make a class variable visible but constant to outsiders, but changeable (mutable) to the class itself?

2016-05-21 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 22 May 2016 at 03:06:44 UTC, Mike Parker wrote: As for 'const' and '@property', neither is strictly a requirement to implement this idiom. Adding const means that Oh, and the same holds true for final, of course. It's probably what you want most of the time, but it isn't strictly

Re: Is there a way to make a class variable visible but constant to outsiders, but changeable (mutable) to the class itself?

2016-05-21 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 21 May 2016 at 19:17:00 UTC, dan wrote: Thanks Vit, Meta, and Yuxuan for your speedy help! So 3 pieces to put together, function, const, and @property (and i guess final for protection against subclasses). Minimally, there are two pieces to this: a private member variable and a

Re: Basic question about stderr

2016-05-21 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 21 May 2016 at 22:11:30 UTC, chaseratx wrote: On Saturday, 21 May 2016 at 22:08:15 UTC, Era Scarecrow wrote: On Saturday, 21 May 2016 at 21:54:43 UTC, Era Scarecrow wrote: On Saturday, 21 May 2016 at 21:47:20 UTC, chaseratx wrote: Thanks Era, but I am not trying to fix the range

Re: Immutable objects and constructor ?

2016-05-20 Thread Mike Parker via Digitalmars-d-learn
On Friday, 20 May 2016 at 16:09:54 UTC, chmike wrote: This is confusing and frustrating. In C++ we can write MyInfos { . . . // one is a constant pointer to a constant object of type Obj Obj const * const one; . . . } And in main() Info const * x1 = MyInfos.one; x1 i a modifiable

Re: Immutable objects and constructor ?

2016-05-20 Thread Mike Parker via Digitalmars-d-learn
On Friday, 20 May 2016 at 16:09:54 UTC, chmike wrote: But I now met another error in my main(). I can't assign the immutable object to a mutable reference. Info x1 = MyInfos.one; Is it possible to define a mutable reference to an immutable instance ?  This is confusing and frustrating.

Re: Immutable objects and constructor ?

2016-05-20 Thread Mike Parker via Digitalmars-d-learn
On Friday, 20 May 2016 at 20:30:22 UTC, chmike wrote: I'm a bit surprized that the language doesn't support this. We have immutable strings that can be assigned to different variables. Why couldn't we do the same with objects ? Consider this: immutable(char)[] str; Here, the array

<    4   5   6   7   8   9   10   11   12   13   >