Re: Load D shared library on windows x64

2018-08-18 Thread Tofu Ninja via Digitalmars-d-learn
On Saturday, 18 August 2018 at 21:10:55 UTC, Tofu Ninja wrote: On Saturday, 18 August 2018 at 11:27:29 UTC, Mike Wey wrote: On 18-08-18 02:31, Tofu Ninja wrote: On Friday, 17 August 2018 at 20:27:05 UTC, Tofu Ninja wrote: Its this part that fails... always returns null HMODULE h =

Re: Load D shared library on windows x64

2018-08-18 Thread Tofu Ninja via Digitalmars-d-learn
On Saturday, 18 August 2018 at 11:27:29 UTC, Mike Wey wrote: On 18-08-18 02:31, Tofu Ninja wrote: On Friday, 17 August 2018 at 20:27:05 UTC, Tofu Ninja wrote: Its this part that fails... always returns null HMODULE h = cast(HMODULE) Runtime.loadLibrary(dllName); if (h is null) {

Re: Load D shared library on windows x64

2018-08-17 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 17 August 2018 at 20:27:05 UTC, Tofu Ninja wrote: Its this part that fails... always returns null HMODULE h = cast(HMODULE) Runtime.loadLibrary(dllName); if (h is null) { writeln("error loading"); return; } I there any way to see why Runtime.loadLibrary is failing?

Re: Load D shared library on windows x64

2018-08-17 Thread Tofu Ninja via Digitalmars-d-learn
Its this part that fails... always returns null HMODULE h = cast(HMODULE) Runtime.loadLibrary(dllName); if (h is null) { writeln("error loading"); return; }

Load D shared library on windows x64

2018-08-17 Thread Tofu Ninja via Digitalmars-d-learn
Do shared libraries work? I am trying to load a D library into a D program but Runtime.loadLibrary just returns null for me and I am not sure what I am doing wrong. import std.stdio; import std.file : exists, getcwd, rename; import core.thread; import std.conv : to; version(tofu_dynamic){

isFuture

2018-02-18 Thread Tofu Ninja via Digitalmars-d-learn
What is __traits(isFuture)? The language documents says it tests for @future which doesn't really help as @future is undocumented.

Re: TypeInfo_Class.interfaces has TypeInfo_Class and not TypeInfo_Interface?

2017-12-15 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 15 December 2017 at 05:19:04 UTC, Tofu Ninja wrote: TypeInfo_Class.interfaces has TypeInfo_Class and not TypeInfo_Interface? Is this correct? Or is it a bug? Doesn't make much sense to me. Also the following code prints false so there are some consequences to this. import

TypeInfo_Class.interfaces has TypeInfo_Class and not TypeInfo_Interface?

2017-12-14 Thread Tofu Ninja via Digitalmars-d-learn
TypeInfo_Class.interfaces has TypeInfo_Class and not TypeInfo_Interface? Is this correct? Or is it a bug? Doesn't make much sense to me.

Re: Open Scene Graph For D?

2017-12-11 Thread Tofu ninja via Digitalmars-d-learn
On Thursday, 7 December 2017 at 19:30:13 UTC, Tofu ninja wrote: Is there a binding for it? Just a question, trying to convince people at work to use D and that is something they asked about. Guess not

Open Scene Graph For D?

2017-12-07 Thread Tofu ninja via Digitalmars-d-learn
Is there a binding for it? Just a question, trying to convince people at work to use D and that is something they asked about.

Re: Debugging shared libs on windows

2017-12-07 Thread Tofu ninja via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 22:59:17 UTC, user1234 wrote: On Wednesday, 6 December 2017 at 21:17:55 UTC, Tofu ninja wrote: On Wednesday, 6 December 2017 at 21:12:20 UTC, Tofu ninja wrote: I am compiling with -m64 -shared -debug -g and a .pdb is generated but visual studio says the dll was

Re: Debugging shared libs on windows

2017-12-06 Thread Tofu ninja via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 21:12:20 UTC, Tofu ninja wrote: I am compiling with -m64 -shared -debug -g and a .pdb is generated but visual studio says the dll was not compiled with debug information, am I missing something or is this not supported? DMD32 D Compiler v2.076.0 Actually

Debugging shared libs on windows

2017-12-06 Thread Tofu ninja via Digitalmars-d-learn
I am compiling with -m64 -shared -debug -g and a .pdb is generated but visual studio says the dll was not compiled with debug information, am I missing something or is this not supported? DMD32 D Compiler v2.076.0

Re: Windows X64 Calling conventions

2017-04-20 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 20 April 2017 at 08:36:32 UTC, kinke wrote: On Thursday, 20 April 2017 at 01:16:11 UTC, Tofu Ninja wrote: My question is, why is it passed twice, both in xmm0 and rcx? The MSDN docs say floating point are passed in xmm registers, why is it also copied in into rcx? Is it necessary

Windows X64 Calling conventions

2017-04-19 Thread Tofu Ninja via Digitalmars-d-learn
I am trying to learn the calling conventions in DMD, I am sure I will have more than one question about them so as I come across them I will ask them in this thread. I am mainly reading the MSDN docs on the x64 calls and looking at disassemblies to confirm what I learn. While I was looking

Get method address from alias?

2017-04-11 Thread Tofu Ninja via Digitalmars-d-learn
I only have an alias to the method without a this pointer, is there any way to get the address? Something like struct T{ void foo(){} } alias A = Alias!(__traits(getMemeber, T, "foo")); void* A_addres = ? // Somehow get the address from A

Re: dub subpackage output to shared lib not working

2017-01-26 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 26 January 2017 at 19:01:41 UTC, Tofu Ninja wrote: Actually.. if I do dub describe on the root package it lists both the exe and the lib as targets but the build settings for the lib has "targetType": 6 which according to dub/source/dub/compilers/buildsettings.d is

Re: dub subpackage output to shared lib not working

2017-01-26 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 26 January 2017 at 18:26:27 UTC, Tofu Ninja wrote: On Thursday, 26 January 2017 at 18:10:12 UTC, Tofu Ninja wrote: On Thursday, 26 January 2017 at 18:00:57 UTC, Tofu Ninja wrote: Is this not doable? I guess an alternative question, is there any way to have multiple binaries(an

Re: dub subpackage output to shared lib not working

2017-01-26 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 26 January 2017 at 18:10:12 UTC, Tofu Ninja wrote: On Thursday, 26 January 2017 at 18:00:57 UTC, Tofu Ninja wrote: Is this not doable? I guess an alternative question, is there any way to have multiple binaries(an executable and a bunch of shared libs) built from a single dub

Re: dub subpackage output to shared lib not working

2017-01-26 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 26 January 2017 at 18:00:57 UTC, Tofu Ninja wrote: Is this not doable? I guess an alternative question, is there any way to have multiple binaries(an executable and a bunch of shared libs) built from a single dub package? Or should I just give up on trying to use dub for

Re: dub subpackage output to shared lib not working

2017-01-26 Thread Tofu Ninja via Digitalmars-d-learn
On Sunday, 22 January 2017 at 08:16:49 UTC, Tofu Ninja wrote: Trying to get a dub sub package to output as a shared lib but for some reason I can only get it to output as a static lib. dub.json --- { "name": "tofueng", "targetType": "executable", "targetPath" : "game",

dub subpackage output to shared lib not working

2017-01-22 Thread Tofu Ninja via Digitalmars-d-learn
Trying to get a dub sub package to output as a shared lib but for some reason I can only get it to output as a static lib. dub.json --- { "name": "tofueng", "targetType": "executable", "targetPath" : "game", "sourcePaths": ["eng"], "importPaths": ["eng"],

Re: Proper generic way to get the hash of something?

2016-12-03 Thread Tofu Ninja via Digitalmars-d-learn
Well for now I am going to revert back to 2.071.2, 2.072 seems broke as fuck.

Re: Proper generic way to get the hash of something?

2016-12-03 Thread Tofu Ninja via Digitalmars-d-learn
Actually better question, why was this breaking change allowed? The semantics of hashOf have completely changed, why was this done??

Proper generic way to get the hash of something?

2016-12-03 Thread Tofu Ninja via Digitalmars-d-learn
What is the proper generic way to get the hash of something? It seems that hashOf has been changed to no longer call toHash on anything Just blindly casts to void[]. It actually seems now toHash doesn't call any of the specializations of core.internal.hash.hashOf except the one for void[].

Re: Given two AliasSeq (A and B) and template T, how to make AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])) ?

2016-11-27 Thread Tofu Ninja via Digitalmars-d-learn
On Sunday, 27 November 2016 at 07:38:53 UTC, Nicholas Wilson wrote: Whoops it would help if I read your question. You want to use Iota in conjunction with staticMap. alias pairs(int N, alias a, alias b) = AliasSeq(a[N],b[N]); alias C = staticMap!(T,staticMap(pairs,Iota!N)); That didn't

Given two AliasSeq (A and B) and template T, how to make AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])) ?

2016-11-26 Thread Tofu Ninja via Digitalmars-d-learn
Basically the title says it all. alias A = AliasSeq!(...); alias B = AliasSeq!(...); static assert(A.length == B.length); template T(An, Bn){ ... } alias C = AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])); // how to make this :/ How do I actually make the sequence C?

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 24 November 2016 at 02:11:21 UTC, ketmar wrote: On Thursday, 24 November 2016 at 00:51:01 UTC, Tofu Ninja wrote: Even with std.traits, you can't know which arguments are variadic. sure, you can. see http://dpldocs.info/experimental-docs/std.traits.variadicFunctionStyle.html that

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:36:54 UTC, ketmar wrote: On Thursday, 24 November 2016 at 00:19:04 UTC, Tofu Ninja wrote: You still can't replicate a function with this. you can, by using std.traits and string mixins. Even with std.traits, you can't know which arguments are variadic.

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:15:07 UTC, ketmar wrote: On Thursday, 24 November 2016 at 00:04:51 UTC, Tofu Ninja wrote: On Wednesday, 23 November 2016 at 23:21:53 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 23:02:30 UTC, Tofu Ninja wrote: Being able to get an alias to (ref int)

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 23:21:53 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 23:02:30 UTC, Tofu Ninja wrote: Being able to get an alias to (ref int) seems like a bug. you are unable to alias it, `ref` will be erased on aliasing. the only way to retain it is to have a tuple

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 22:48:17 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 22:28:57 UTC, Tofu Ninja wrote: On Wednesday, 23 November 2016 at 22:19:28 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 22:14:25 UTC, Tofu Ninja wrote: What is a (ref int)? A tuple with "ref

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 22:19:28 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 22:14:25 UTC, Tofu Ninja wrote: What is a (ref int)? A tuple with "ref int" as its only member? Since when is ref int a type? it is "type with modifier", like "const int" or "immutable int".

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Sunday, 20 November 2016 at 12:06:15 UTC, Tofu Ninja wrote: On Sunday, 20 November 2016 at 11:52:01 UTC, Tofu Ninja wrote: ... Also does not include function linkage :/ Because of the lack of response, I am going to guess there is no way to do this cleanly. Guess I am going to have to

Re: How to declare function with the same call signature as another?

2016-11-20 Thread Tofu Ninja via Digitalmars-d-learn
On Sunday, 20 November 2016 at 11:52:01 UTC, Tofu Ninja wrote: ... Also does not include function linkage :/

Re: How to declare function with the same call signature as another?

2016-11-20 Thread Tofu Ninja via Digitalmars-d-learn
On Sunday, 20 November 2016 at 11:23:37 UTC, Nicholas Wilson wrote: On Sunday, 20 November 2016 at 11:19:24 UTC, Tofu Ninja wrote: I feel like this should be simple but I can't seem to figure it out. How do I declare a function to have the same call signature as another function/callable type?

How to declare function with the same call signature as another?

2016-11-20 Thread Tofu Ninja via Digitalmars-d-learn
I feel like this should be simple but I can't seem to figure it out. How do I declare a function to have the same call signature as another function/callable type? Like if I have: alias Sig = int function(int x, int y); How do I define a function such that it will have the same call

Re: VisualD core.exception.RangeError@pipedmd(286): Range violation

2016-09-08 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 8 September 2016 at 19:56:45 UTC, Rainer Schuetze wrote: I think I fixed both issues in this build: https://ci.appveyor.com/project/rainers/visuald/build/1.0.76/job/kq0a5bqpy7anou46/artifacts Well that was fast :) It does appear to be fixed on my machine, thanks a lot for the

Re: VisualD core.exception.RangeError@pipedmd(286): Range violation

2016-09-08 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 8 September 2016 at 07:45:56 UTC, Rainer Schuetze wrote: Fixed it again. You can find a prebuilt binary of pipedmd.exe here: https://ci.appveyor.com/project/rainers/visuald/build/1.0.75/job/n9tf67jxcir6kpmg/artifacts Thanks for the response, I think there is more going on than

VisualD core.exception.RangeError@pipedmd(286): Range violation

2016-09-05 Thread Tofu Ninja via Digitalmars-d-learn
I get "core.exception.RangeError@pipedmd(286): Range violation" whenever I try to build from visual D. Is there any workaround for this? It was reported[1] almost 9 months ago, does not seem like it's going to be fixed anytime soon. Visual D is completely broken for me right now because of

Re: dub generate visuald

2016-09-05 Thread Tofu Ninja via Digitalmars-d-learn
On Monday, 5 September 2016 at 19:03:00 UTC, Tofu Ninja wrote: On Monday, 5 September 2016 at 17:25:45 UTC, Tofu Ninja wrote: I am not sure what changed but I can no longer build using visuald after generating from dub. When I try to build from visual studio I get the following error LINK :

Re: dub generate visuald

2016-09-05 Thread Tofu Ninja via Digitalmars-d-learn
On Monday, 5 September 2016 at 17:25:45 UTC, Tofu Ninja wrote: I am not sure what changed but I can no longer build using visuald after generating from dub. When I try to build from visual studio I get the following error LINK : warning LNK4001: no object files specified; libraries used

Re: dub generate visuald

2016-09-05 Thread Tofu Ninja via Digitalmars-d-learn
On Monday, 5 September 2016 at 18:22:02 UTC, Guillaume Piolat wrote: On Monday, 5 September 2016 at 17:25:45 UTC, Tofu Ninja wrote: I can build directly from dub with no problem, but building from VS gives that error. Building with dub uses the dmd settings in sc.ini Building with VisualD

Re: Unicode function name? ∩

2016-08-27 Thread Tofu Ninja via Digitalmars-d-learn
On Sunday, 28 August 2016 at 05:28:17 UTC, rikki cattermole wrote: On 28/08/2016 5:21 PM, Tofu Ninja wrote: ... Try Ÿ. Yeah Ÿ and π both work but ∩ does not. I think I found my answer though... http://dlang.org/spec/lex.html#IdentifierChar Identifiers start with a letter, _, or universal

Re: Unicode function name? ∩

2016-08-27 Thread Tofu Ninja via Digitalmars-d-learn
On Sunday, 28 August 2016 at 05:21:03 UTC, Tofu Ninja wrote: ... Also visual D seems to recognize its not a valid character and highlights the error which makes me think its known behavior.

Re: Unicode function name? ∩

2016-08-27 Thread Tofu Ninja via Digitalmars-d-learn
On Sunday, 28 August 2016 at 05:21:03 UTC, Tofu Ninja wrote: Are unicode function names not supported in dmd? bool ∩(A, B)(A a, B b){ return intersect(a, b); } Error: character 0x2229 is not a valid token I won't be terribly disappointed if I can't do this, I really just tried it on a

Unicode function name? ∩

2016-08-27 Thread Tofu Ninja via Digitalmars-d-learn
Are unicode function names not supported in dmd? bool ∩(A, B)(A a, B b){ return intersect(a, b); } Error: character 0x2229 is not a valid token I won't be terribly disappointed if I can't do this, I really just tried it on a whim, but I thought dmd supported unicode.

Using shared libraries for external scripts, looking for advice (windows)

2016-08-15 Thread Tofu Ninja via Digitalmars-d-learn
So this is kind of an open ended question, just looking for advice on doing it in general, if it's possible, and doing it specifically in D on windows. I am not super familiar with how shared libraries work so I had some questions. I would like to attempt to use D to write scripts for a game

Re: Why is ElementType!(char[]) == dchar?

2016-07-09 Thread Tofu Ninja via Digitalmars-d-learn
On Saturday, 9 July 2016 at 11:35:24 UTC, Tofu Ninja wrote: On Saturday, 9 July 2016 at 11:29:18 UTC, ketmar wrote: On Saturday, 9 July 2016 at 11:24:01 UTC, Tofu Ninja wrote: Seems pretty silly to me... due to universally beloved autodecoding. Hmmm... I dont really know the history of

Re: Why is ElementType!(char[]) == dchar?

2016-07-09 Thread Tofu Ninja via Digitalmars-d-learn
On Saturday, 9 July 2016 at 11:29:18 UTC, ketmar wrote: On Saturday, 9 July 2016 at 11:24:01 UTC, Tofu Ninja wrote: Seems pretty silly to me... due to universally beloved autodecoding. Hmmm... I dont really know the history of autodecoding, why was that supposed to be a good idea?

Why is ElementType!(char[]) == dchar?

2016-07-09 Thread Tofu Ninja via Digitalmars-d-learn
Seems pretty silly to me...

Re: Real implicitly converts to float?

2016-06-24 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 24 June 2016 at 20:10:16 UTC, Tofu Ninja wrote: I am glad I was not the only one who thought that sounded a little crazy... I thought D was supposed to be type safe. I think I will make a bug report and see where that goes. https://issues.dlang.org/show_bug.cgi?id=16202

Re: Real implicitly converts to float?

2016-06-24 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 24 June 2016 at 08:52:48 UTC, Ola Fosheim Grøstad wrote: This is so wrong. _especially_ when you have parameter overloading/templates. It means that you accidentally can trash a computation by getting the wrong function. That is not type-safe in my book. Jonathan's max-value

Re: Real implicitly converts to float?

2016-06-23 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 23 June 2016 at 15:25:49 UTC, Steven Schveighoffer wrote: I disagree. I've used languages where converting floating point types is not implicit, and it's painful. Most of the time, the loss in precision isn't important. -Steve Which is why a flag would be nice, for some

Re: Real implicitly converts to float?

2016-06-23 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 23 June 2016 at 13:57:57 UTC, Steven Schveighoffer wrote: Whenever you work with floating point, the loss of precision must be expected -- a finite type cannot represent an infinite precision number. The loss in precision should still be a warning. If I am using reals then I

Re: Real implicitly converts to float?

2016-06-22 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 14:17:42 UTC, Jonathan M Davis wrote: Well, that particular value should probably work thanks to VRP (value range propagation), since 10 can fit into float with no loss of precision. However, what's far more disconcerting is that real x = real.max; float y = x;

Re: Real implicitly converts to float?

2016-06-22 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 08:57:38 UTC, Guillaume Piolat wrote: On Wednesday, 22 June 2016 at 05:04:42 UTC, Tofu Ninja wrote: Is this intended behavior? I can't seem to find it documented anywhere, I would think the loss in precision would atleast be a warning. real x = 10; float y = x;

Real implicitly converts to float?

2016-06-21 Thread Tofu Ninja via Digitalmars-d-learn
Is this intended behavior? I can't seem to find it documented anywhere, I would think the loss in precision would atleast be a warning. real x = 10; float y = x; // No error or warning real to double and double to float also work.

Re: Dub generate visuald, multiple configurations?

2016-06-19 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 17 June 2016 at 08:49:47 UTC, Tofu Ninja wrote: Is there a way to generate a single visuald project file for all dub configurations, selecting the configuration from the visual studio configuration manager? Or do I have to generate a separate project for each configuration? I am

Dub generate visuald, multiple configurations?

2016-06-17 Thread Tofu Ninja via Digitalmars-d-learn
Is there a way to generate a single visuald project file for all dub configurations, selecting the configuration from the visual studio configuration manager? Or do I have to generate a separate project for each configuration?

Re: Are __gshared globals gc scanned?

2016-06-14 Thread Tofu Ninja via Digitalmars-d-learn
On Tuesday, 14 June 2016 at 13:53:10 UTC, ketmar wrote: __gshared globals are gc scanned. Ah cool, thanks I had to login to my work computer just to read your answer lol

Are __gshared globals gc scanned?

2016-06-14 Thread Tofu Ninja via Digitalmars-d-learn
Title says it all...

Re: Shallow copy object when type is know

2016-04-20 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 18:48:58 UTC, Alex Parrill wrote: On Wednesday, 20 April 2016 at 12:32:48 UTC, Tofu Ninja wrote: Is there a way to shallow copy an object when the type is known? I cant seem to figure out if there is a standard way. I can't just implement a copy function for the

Shallow copy object when type is know

2016-04-20 Thread Tofu Ninja via Digitalmars-d-learn
Is there a way to shallow copy an object when the type is known? I cant seem to figure out if there is a standard way. I can't just implement a copy function for the class, I need a generic solution.

Re: Anonymous structure

2016-04-19 Thread Tofu Ninja via Digitalmars-d-learn
On Tuesday, 19 April 2016 at 16:16:39 UTC, ZombineDev wrote: On Monday, 18 April 2016 at 23:00:42 UTC, captaindet wrote: On 2016-04-18 14:12, Tofu Ninja wrote: Also is there a way to have a named substructure, not a nested structure but something to just add an additional name, maybe something

Re: Anonymous structure

2016-04-19 Thread Tofu Ninja via Digitalmars-d-learn
On Monday, 18 April 2016 at 23:00:42 UTC, captaindet wrote: not sure what you mean by "named substructure, not a nested structure" but this works: struct Outer{ struct Inner{ int x; int y; int z; } Inner inner; int

Re: Anonymous structure

2016-04-17 Thread Tofu Ninja via Digitalmars-d-learn
On Monday, 18 April 2016 at 03:33:53 UTC, Adam D. Ruppe wrote: The struct inside union is the main pure-language use case I know of though. Actually curiously I found another potential use, applying attributes/UDAs to multiple members at once. enum testUDA; struct T{ @testUDA

Re: Anonymous structure

2016-04-17 Thread Tofu Ninja via Digitalmars-d-learn
On Monday, 18 April 2016 at 03:33:53 UTC, Adam D. Ruppe wrote: The struct inside union is the main pure-language use case I know of though. I understand the reason for allowing it in a union, I just don't see the reason it was extended to all aggregates as it seems to do nothing.

Re: Anonymous structure

2016-04-17 Thread Tofu Ninja via Digitalmars-d-learn
On Monday, 18 April 2016 at 02:42:15 UTC, Nicholas Wilson wrote: On Monday, 18 April 2016 at 02:12:24 UTC, Tofu Ninja wrote: Just out of curiosity, what is the point of the following? struct a{ struct{ int x; int y; int z; } } As

Anonymous structure

2016-04-17 Thread Tofu Ninja via Digitalmars-d-learn
Just out of curiosity, what is the point of the following? struct a{ struct{ int x; int y; int z; } } As far as I can tell, the anonymous structure does nothing. How is it different from struct a{ int x; int y;

Implicit conversion from string to custom type?

2016-02-14 Thread Tofu Ninja via Digitalmars-d-learn
So I wrote a simple ref counted string type because using the built in strings without the GC is extremely painful. It there any way I can get strings to implicitly convert to my custom string type? Some way to make this work... struct rstring {...} void fun(rstring s) {...} ... fun("hello

How is the TypeInfo assigned?

2016-02-13 Thread Tofu Ninja via Digitalmars-d-learn
Is the TypeInfo given by typeid() guaranteed to be the same for a type regardless of where I call it? I guess my question is, is the TypeInfo a valid way to dynamically check types? I am implementing a message passing system for an entity-component system, I was planning to use structs as

Re: Octree implementation?

2016-02-09 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 4 February 2016 at 17:56:06 UTC, Marco Leise wrote: Am Mon, 01 Feb 2016 02:56:06 + schrieb Tofu Ninja : Just out of curiosity, does anyone have an octree implementation for D laying around? Just looking to save some time. I have one written in Delphi

Re: foreach seems to work with opIndex()

2016-02-06 Thread Tofu Ninja via Digitalmars-d-learn
On Saturday, 6 February 2016 at 15:02:16 UTC, H. S. Teoh wrote: Not really sure, but opIndex() with no arguments is supposed to be the current way of implement the [] slicing operator for user-defined types. I'm not sure when foreach started supporting that, but it's certainly a nice thing!

Re: foreach seems to work with opIndex()

2016-02-06 Thread Tofu Ninja via Digitalmars-d-learn
On Saturday, 6 February 2016 at 14:43:52 UTC, Tofu Ninja wrote: Foreach seems to work if there is an opIndex() with no arguments that returns a range interface, is this documented? I can't seem to find anything that say this is supposed to happen. I am not really complaining, its nice, but I

foreach seems to work with opIndex()

2016-02-06 Thread Tofu Ninja via Digitalmars-d-learn
Foreach seems to work if there is an opIndex() with no arguments that returns a range interface, is this documented? I can't seem to find anything that say this is supposed to happen. I am not really complaining, its nice, but I just didnt really expect it because I feel like I remember this

Octree implementation?

2016-01-31 Thread Tofu Ninja via Digitalmars-d-learn
Just out of curiosity, does anyone have an octree implementation for D laying around? Just looking to save some time.

Re: Compiling dmd -m64 on windows?

2016-01-29 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 29 January 2016 at 18:26:15 UTC, Tofu Ninja wrote: For some reason it complains that link.exe is missing. Anyone know what's up? dmd test.d dmd test.d -m64 Can't run '\bin\link.exe', check PATH link.exe is definitely on PATH... where link.exe C:\D\dmd2\windows\bin\link.exe

Compiling dmd -m64 on windows?

2016-01-29 Thread Tofu Ninja via Digitalmars-d-learn
For some reason it complains that link.exe is missing. Anyone know what's up? dmd test.d dmd test.d -m64 Can't run '\bin\link.exe', check PATH

Output range for file?

2016-01-24 Thread Tofu Ninja via Digitalmars-d-learn
I tried looking for this in phobos but cant seem to find it which is really annoying. For my uses this works: struct fileOutRange { File f; void put(ubyte[] a) { f.rawWrite(a); } } But was just wondering if there was a real output range for files

Re: Output range for file?

2016-01-24 Thread Tofu Ninja via Digitalmars-d-learn
On Sunday, 24 January 2016 at 15:08:33 UTC, H. S. Teoh wrote: On Sun, Jan 24, 2016 at 12:38:22PM +, Tofu Ninja via Digitalmars-d-learn wrote: I tried looking for this in phobos but cant seem to find it which is really annoying. For my uses this works: What kind of data do you need

Re: Reset all Members of a Aggregate Instance

2015-12-03 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 3 December 2015 at 21:04:00 UTC, Nordlöw wrote: ... I think reflection will be a bad choice for this because of private members and what not. I think the correct way is: void reset(C)(ref C c) { static if(is(C == class)) { auto init =

Re: Reset all Members of a Aggregate Instance

2015-12-03 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 4 December 2015 at 04:08:33 UTC, Tofu Ninja wrote: On Thursday, 3 December 2015 at 21:04:00 UTC, Nordlöw wrote: ... I think reflection will be a bad choice for this because of private members and what not. I think the correct way is: void reset(C)(ref C c) { static

Re: isAllocator

2015-12-01 Thread Tofu Ninja via Digitalmars-d-learn
On Tuesday, 1 December 2015 at 08:58:56 UTC, BBaz wrote: I think that `is(CAllocatorImpl!Alloc)` should work too then. According to the 'is' version, int is an allocator. No idea why it thinks this works... enum isAllocator(Alloc) = is(CAllocatorImpl!Alloc); static assert(isAllocator!int);

Re: isAllocator

2015-11-30 Thread Tofu Ninja via Digitalmars-d-learn
On Monday, 30 November 2015 at 14:21:49 UTC, Tofu Ninja wrote: Is there something like isInputRange for allocators, I tried looking for something but couldn't find anything? If not, why not? Aka, some way to check that type T is an allocator.

isAllocator

2015-11-30 Thread Tofu Ninja via Digitalmars-d-learn
Is there something like isInputRange for allocators, I tried looking for something but couldn't find anything? If not, why not?

Re: Compile time strings auto concatenation!?

2015-11-21 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 20 November 2015 at 20:39:58 UTC, Ilya wrote: Can DMD frontend optimize string concatenation ``` enum Double(S) = S ~ S; assert(condition, "Text " ~ Double!"+" ~ ___FUNCTION__); ``` to ``` assert(condition, "Text ++_function_name_"); ``` ? If you really want to make sure it is

Re: Manually allocate delegate?

2015-11-21 Thread Tofu Ninja via Digitalmars-d-learn
On Saturday, 21 November 2015 at 00:30:45 UTC, userABCabc123 wrote: Yes: class Foo { void bar(){writeln(__PRETTY_FUNCTION__);} } auto uncollectedDelegate(T, string name)(ref T t) { import std.experimental.allocator.mallocator; struct Dg{void* ptr,

Re: std.experimental.allocator optlink error

2015-11-20 Thread Tofu Ninja via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 11:39:56 UTC, Rikki Cattermole wrote: One already exists. I've confirmed it in the build scripts. It only effects Windows. Any fix for this right now?

Re: std.experimental.allocator optlink error

2015-11-20 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 20 November 2015 at 12:49:02 UTC, Rikki Cattermole wrote: Dunno if its been fixed in ~master (doubt it), but all you need to do in your code, is copy it in. Cool, that worked. I've personally marked (well voted anyway) for this bug to be critical. It seems I'm the only one who

Re: BidirectionalRange switching direction

2015-09-24 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 03:26:29 UTC, John Colvin wrote: On Wednesday, 23 September 2015 at 02:10:22 UTC, Tofu Ninja wrote: Trying to implement a bi directional range and it is slightly unclear what the semantics are supposed to be and just wanted some clarification. Are

BidirectionalRange switching direction

2015-09-22 Thread Tofu Ninja via Digitalmars-d-learn
Trying to implement a bi directional range and it is slightly unclear what the semantics are supposed to be and just wanted some clarification. Are bidirectional ranges supposed to be able to support switching direction mid iteration? Like if I do popFront popFront popBack should that be

Re: Theoretical Best Practices

2015-08-14 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 14 August 2015 at 22:25:15 UTC, DarthCthulhu wrote: Ahh, that is a much cleaner way to do it rather than using a singleton. By 'module level', I assume you mean in the module that defines the Logger class? An 'import debug.logger' or somesuch would then give all relevant modules

Yieldable function?

2015-08-13 Thread Tofu Ninja via Digitalmars-d-learn
Is there any way to have a yieldable function that can be resumed at a later time in D? Some thing like: void test() { writeln(A); yeild(); writeln(B); } ... auto x = yieldable!test(); x.resume(); // prints A x.resume(); // prints B x.resume(); // throws an error or something,

Re: Yieldable function?

2015-08-13 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 13 August 2015 at 22:29:17 UTC, MrSmith wrote: http://dlang.org/phobos/core_thread.html#.Fiber Man I feel like I saw that before but when I went looking for it I couldn't find it. Didn't think to check in core. :/ Welp that solves my question, thanks :D

Re: Find on sorted range slower?

2015-08-07 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 7 August 2015 at 08:18:04 UTC, Nordlöw wrote: On Friday, 7 August 2015 at 05:21:32 UTC, Tofu Ninja wrote: HAHAH wow, this is hilarious, I just checked, nothing in std.algo takes advantage of sorted ranges, sort doesn't even take advantage of it! You pass a sorted range into sort and

Re: Find on sorted range slower?

2015-08-07 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 7 August 2015 at 10:01:39 UTC, Timon Gehr wrote: On 08/07/2015 11:03 AM, Tofu Ninja wrote: On Friday, 7 August 2015 at 08:18:04 UTC, Nordlöw wrote: On Friday, 7 August 2015 at 05:21:32 UTC, Tofu Ninja wrote: HAHAH wow, this is hilarious, I just checked, nothing in std.algo takes

Re: Template-Parameterized Variadic isInstaceOf

2015-08-07 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 7 August 2015 at 14:45:44 UTC, Nordlöw wrote: On Friday, 7 August 2015 at 14:30:55 UTC, Nordlöw wrote: Any suggestions on adding support for `binaryFun!pred` aswell? I cracked it. template isSortedRange(T, alias pred = a b) { import std.traits : TemplateArgsOf; static if

Re: Find on sorted range slower?

2015-08-06 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 7 August 2015 at 04:23:21 UTC, Ali Çehreli wrote: Do you want to see SortedRange 1700 times faster? ;) On 08/06/2015 05:35 PM, Tofu Ninja wrote: void main() auto temp = assumeSorted(a).find(f); SortedRange does not have a find() member. What happens is, it goes to find()

Re: Find on sorted range slower?

2015-08-06 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 7 August 2015 at 05:01:41 UTC, Tofu Ninja wrote: On Friday, 7 August 2015 at 04:23:21 UTC, Ali Çehreli wrote: Do you want to see SortedRange 1700 times faster? ;) On 08/06/2015 05:35 PM, Tofu Ninja wrote: void main() auto temp = assumeSorted(a).find(f); SortedRange does

  1   2   >