Re: File .. byLine

2018-12-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 3 December 2018 at 06:09:21 UTC, Joel wrote: I can't seem to get this to work! ``` foreach(line; File("help.txt").byLine) { writeln(line.stripLeft); ``` With the code above, I get this compile error: source/app.d(360,36): Error: template std.algorithm.mutation.stripLeft cannot d

Re: 2D-all?

2018-12-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 14 December 2018 at 12:43:40 UTC, berni wrote: I've got a lot of code with two-dimensional arrays, where I use stuff like: assert(matrix.all!(a=>a.all!(b=>b>=0))); Does anyone know if there is a 2D-version of all so I can write something like: assert(matrix.all2D!(a=>a>=0));

Re: Mixin operator 'if' directly

2018-12-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 22 December 2018 at 03:44:09 UTC, Timoses wrote: On Wednesday, 19 December 2018 at 15:40:50 UTC, Neia Neutuladh wrote: On Wed, 19 Dec 2018 15:12:14 +, bauss wrote: Or while instantiating it: mixin template foo() { int _ignoreme() { if (readln.strip == "abort") throw new

Re: Understanding SIGSEGV issues

2019-01-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 3 January 2019 at 06:25:46 UTC, Russel Winder wrote: So I have a D program that used to work. I come back to it, recompile it, and: [...] __GI___libc_free (mem=0xa) at malloc.c:3093 You've tried to free a pointer that, while not null, was derived from a pointer that was, i.e.

Re: Understanding SIGSEGV issues

2019-01-03 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 3 January 2019 at 08:35:17 UTC, Russel Winder wrote: Sorry about that, fairly obvious that the backtrace is needed in hindsight. :- ) #0 __GI___libc_free (mem=0xa) at malloc.c:3093 #1 0x5558f174 in dvb_file_free (dvb_file=0x555a1320) at dvb_file.d:282 #2 0x5

Re: Understanding SIGSEGV issues

2019-01-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 5 January 2019 at 07:34:17 UTC, Russel Winder wrote: TransmitterData has a destructor defined but with no code in it. This used to work fine – but I cannot be certain which version of LDC that was. The problem does seem to be in the construction of the TransmitterData object beca

Re: Understanding SIGSEGV issues

2019-01-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 5 January 2019 at 10:52:48 UTC, Russel Winder wrote: I found the problem and then two minutes later read your email and bingo we have found the problem. Well done. Previously I had used File_Ptr* and on this occasion I was using File_Ptr and there was no copy constructor because

Re: Understanding SIGSEGV issues

2019-01-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 5 January 2019 at 12:14:15 UTC, Russel Winder wrote: Indeed. I should do that to see if I can reproduce the problem to submit a proper bug report. File_Ptr is wrapping a dvb_file * from libdvbv5 to try and make things a bit for D and to ensure RAII. libdvbv5 is a C API with class

Re: Co-developing application and library

2019-01-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 5 January 2019 at 13:01:24 UTC, Russel Winder wrote: Dub seems to have the inbuilt assumption that libraries are dependencies that do not change except via a formal release when you developing an application. Clearly there is the workflow where you want to amend the library but not

Re: Understanding SIGSEGV issues

2019-01-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 10:23:30 UTC, Russel Winder wrote: Actually that is not a worry since the TransmitterData instance is only needed to call the scan function which creates a ChannelsData instance that holds no references to the TransmitterData instance. It turns out that whilst th

Re: Understanding SIGSEGV issues

2019-01-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 9 January 2019 at 16:48:47 UTC, Russel Winder wrote: It really is totally weird. My new Rust binding to libdvbv5 and associated version of the same application works fine. So libdvbv5 itself is not the cuprit. This has to mean it is something about the D compilers that has changed

Re: Deprecation: foreach: loop index implicitly converted from size_t to int

2019-01-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 18 January 2019 at 12:27:17 UTC, Michael wrote: Hello all, I am getting this deprecation warning when compiling using DMD64 D Compiler v2.084.0 on Linux. I'm a little unsure what the problem is, however, because the code producing these warnings tends to be of the form: foreach

Re: How to use core.atomic.cas with (function) pointers?

2019-01-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 14:13:23 UTC, Johan Engelen wrote: The following code compiles: ``` alias T = shared(int)*; shared T a; shared T b; shared T c; void foo() { import core.atomic: cas; cas(&a, b, c); } ``` The type of T has to be a pointer to a shared int (you get a templa

Re: Can LDC compile to supported legacy LLVM versions?

2019-01-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 28 January 2019 at 11:37:56 UTC, Dukc wrote: I have recenty updated my LDC to the most recent version (1.14). The problem is that it compiles to LLVM code version 7.0.1, but I need it to compile to LLVM 6.x.x or LLVM 5.x.x. The last release note said that LLVM versions from 3.someth

Re: Compile Time Fun Time

2019-02-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 25 February 2019 at 06:51:20 UTC, Yevano wrote: I am writing a domain specific language of sorts in D for the lambda calculus. One of my requirements is that I should be able to generate expressions like this: new Abstraction(v1, M) like this: L!(x => M) It is common to want to w

Re: DMD2 vs LDC2 inliner

2019-02-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 25 February 2019 at 02:49:36 UTC, James Blachly wrote: Any ideas why DMD2 cannot inline this, but LDC2 has no problem doing so -- or suggestions for what I can do to make DMD2 inline it? Alternatively, I could version(DigitalMars) and version(LDC), but AFAICT this requires me to du

Re: DMD2 vs LDC2 inliner

2019-02-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 25 February 2019 at 04:08:38 UTC, Jonathan M Davis wrote: One issue that's commonly brought up about dmd's inliner is that it's in the front-end, which apparently is a poor way to do inlining. One side effect of that though would be that unless the ldc folks go to extra effort to dis

Re: Template recursion exceeded

2019-02-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 27 February 2019 at 05:45:19 UTC, Michelle Long wrote: Basically void foo(int k = 20)() { static if (k <= 0 || k >= 100) return; foo!(k-1)(); } Error Error: template instance `foo!-280` recursive expansion Yep, that return is a dynamic return, not a stat

Re: dcompute - Error: unrecognized `pragma(LDC_intrinsic)

2019-02-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 27 February 2019 at 22:56:14 UTC, Michelle Long wrote: Trying to get dcompute to work... after a bunch of issues dealing with all the crap this is what I can't get past: Error: unrecognized `pragma(LDC_intrinsic) This is actually from the ldc.intrinsics file, which I had to rena

Re: how to pass a malloc'd C string over to be managed by the GC

2019-02-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 28 February 2019 at 03:33:25 UTC, Sam Johnson wrote: ``` string snappyCompress(const string plaintext) { import deimos.snappy.snappy : snappy_compress, snappy_max_compressed_length, SNAPPY_OK; import core.stdc.stdlib : malloc, free; import std.string : fromStringz,

Re: dcompute - Error: unrecognized `pragma(LDC_intrinsic)

2019-02-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 28 February 2019 at 09:58:35 UTC, Michelle Long wrote: I've included it in Visual D as di and it seems not to add it to the include line... Is it in any way possible that it being an di file would allow that? Seems that it is an LDC issue though but LDC has some usage of it I bel

Re: Phobos in BetterC

2019-03-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 8 March 2019 at 09:24:25 UTC, Vasyl Teliman wrote: I've tried to use Mallocator in BetterC but it seems it's not available there: https://run.dlang.io/is/pp3HDq This produces a linker error. I'm wondering why Mallocator is not available in this mode (it would be intuitive to assum

Re: Phobos in BetterC

2019-03-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 9 March 2019 at 12:42:34 UTC, Sebastiaan Koppe wrote: There might also be the option to use @nogc exceptions (dip 1008), but I am not sure. That won't work as the implementation on DIP1008 cheats the type system but doesn't actually work, i.e. the exceptions are still CG allocate

Re: Why a template with Nullable does not compile?

2019-03-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 12 March 2019 at 05:14:21 UTC, Victor Porton wrote: Why does this not compile? import std.typecons; template FieldInfo(T, Nullable!T default_) { } /usr/lib/ldc/x86_64-linux-gnu/include/d/std/typecons.d(2570,17): Error: `alias T = T;` cannot alias itself, use a qualified name to cr

Re: Request some GtkD Assistance

2019-03-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 27 March 2019 at 06:55:53 UTC, Andrew Edwards wrote: Good day all, I've installed Gtk+ and GtkD on my MacBookPro which is running macOS Mojave but am having some issues linking to and using it. Any assistance to resolve this is appreciated. Steps taken: 1. Install Gtk+

Re: template with enum parameter doesn't compile

2019-04-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 5 April 2019 at 14:47:42 UTC, Sjoerd Nijboer wrote: So the following code doesn't compile for some reason, and I can't figure out why. enum MyEnum { A, B, C } class MyClass(MyEnum myEnum) { /*...*/ } int main() { MyClass!MyEnum.A a; } The error: Error: template instan

Re: Problems instantiating template class

2019-04-06 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 6 April 2019 at 17:30:45 UTC, Mek101 wrote: I'm rewriting from C# a small library of mine to practice with D. I have a class: class WeightedRandom(T, W = float) if(isNumeric!W) { // Fields private W[T] _pairs; // The total sum of all the weights;

Re: Error: template instance `Reflect!(type)` cannot use local `type` as parameter to non-global template `Reflect(Ts...)()`

2019-04-06 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 7 April 2019 at 05:24:38 UTC, Alex wrote: Error: template instance `Reflect!(type)` cannot use local `type` as parameter to non-global template `Reflect(Ts...)()` mixin(`import `~moduleName!(T)~`;`); mixin(`alias X = T.`~name~`;`); super.Reflect!(X); I realize X

Call delegate from C++

2019-04-24 Thread Nicholas Wilson via Digitalmars-d-learn
How do you pass a delegate to a c++ function to be called by it? The function to pass the delegate to is: extern (C++) int fakeEntrypoint( extern(C++) void function(void* /*delegate's context*/) func, void* /*delegate's context*/ arg); What I want is: int entrypoint(scope void delegat

Re: I had a bad time with slice-in-struct array operation forwarding/mimicing. What's the best way to do it?

2019-05-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 4 May 2019 at 15:18:58 UTC, Random D user wrote: I wanted to make a 2D array like structure and support D slice like operations, but I had surprisingly bad experience. I quickly copy pasted the example from the docs: https://dlang.org/spec/operatoroverloading.html#array-ops It's

Re: Compiler/Phobos/Types problem — panic level due to timing.

2019-05-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 5 May 2019 at 19:18:47 UTC, lithium iodate wrote: On Sunday, 5 May 2019 at 18:53:08 UTC, Russel Winder wrote: Hi, I had merrily asumed I could implement nth Fibonacci number with: takeOne(drop(recurrence!((a, n) => a[n-1] + a[n-2])(zero, one), n)).front where zero and one a

Re: is there a way to embed python 3.7 code in D program?

2019-05-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 12 May 2019 at 20:06:34 UTC, torea wrote: Hi, I'd like to use D for the "brain" of a small robot (Anki vector) whose API is coded in Python 3.6+. I had a look at Pyd but it's limited to python 2.7... It isn't. You may needs to set a dub version, or it may pick up the 2.7 as the d

Re: DIP 1016 and const ref parameters

2019-06-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 19:25:59 UTC, Jonathan M Davis wrote: Aside from looking through the newsgroup/forum for discussions on DIPs, that's pretty much all you're going to find on that. Andrei's talk is the most up-to-date information that we have about this particular DIP. The prel

Re: Illegal Filename after basic install and trying Hello World

2019-06-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 26 June 2019 at 13:57:22 UTC, Gilbert Fernandes wrote: I am using VS 2019 into which I have C# and C++ active. Installed the following : DMD 2.086.1 then Visual D 0.50.0 DMD has been installed at the base of C:\ at C:\D Created a D project, which contains a default Hello world pro

Re: D on ARM laptops?

2019-07-03 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 3 July 2019 at 20:49:20 UTC, JN wrote: Does anyone know if and how well D works on ARM laptops (such as Chromebooks and similar)? For example this one https://www.pine64.org/pinebook/ . Can it compile D? Obviously DMD is out because it doesn't have ARM builds. Not sure about GDC

Re: Wrong vtable for COM interfaces that don't inherit IUnknown

2019-07-15 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 15 July 2019 at 22:01:25 UTC, KytoDragon wrote: I am currently trying to write a XAudio2 backend and have come across the problem, that some of the interfaces for XAudio2's COM objects seem to be missing the first entry in their vtable. After reading the iterface article in the spec

Re: D and .lib files. C++/Other?

2017-07-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 1 July 2017 at 20:47:55 UTC, Damien Gibson wrote: Well I finally somehow got it to stop complaining about a bad lib file, but now it wants to tell me the entry point for the functions i list isnt correct, so now im just unsure if its being stupid on me or im not writing something w

Re: D, Game Development, GLSL, Math

2017-07-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 1 July 2017 at 19:23:57 UTC, Void-995 wrote: On Saturday, 1 July 2017 at 19:16:12 UTC, drug wrote: 01.07.2017 22:07, Void-995 пишет: (Void-995) Hi, everyone. I'm pretty excited with what have D to offer for game development, especially meta programming, traits, object.factory, sig

Re: std.string.format call from varyargs

2017-07-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 2 July 2017 at 00:49:30 UTC, LeqxLeqx wrote: Hello! How does one go about invoking a templated-variatic function such as std.string.format with an array of objects? For example: string stringMyThing (string formatForMyThings, MyThing[] myThings) { return format( formatForM

Re: D and .lib files. C++/Other?

2017-07-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 2 July 2017 at 05:33:45 UTC, Damien Gibson wrote: K im retarded... So I forgot the golden rule, debug libs with debug app, release libs with release app.. I attempted loading the debug version of dll with D again just to see what kinda errors (may) come up there, sure enough there is

Re: Append to 'map' result

2017-07-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 4 July 2017 at 23:27:25 UTC, Jean-Louis Leroy wrote: I want to create a range that consists of the result of a map() followed by a value, e.g.: int[] x = [ 1, 2, 3]; auto y = map!(x => x * x)(x); auto z = y ~ 99; // how??? I have tried several variations: convert 99 to a dyna

Error: variable foo forward referenced

2017-07-06 Thread Nicholas Wilson via Digitalmars-d-learn
Why does this: enum AddrSpace { Global,Shared } struct Pointer(AddrSpace as, T) { T* ptr; alias ptr this; } struct AutoIndexed(T) if (is(T : Pointer!(n,U),AddrSpace n,U)) { T p; private @property auto idx() { static if (n == AddrSpace.Global) return G

Re: Error: variable foo forward referenced

2017-07-06 Thread Nicholas Wilson via Digitalmars-d-learn
Ignore, I was trying to analyse an uninstantiated template.

Finding source of typeid use

2017-07-07 Thread Nicholas Wilson via Digitalmars-d-learn
My library is generating a typeid from somewhere. e.g. typeid(const(Pointer!(cast(AddrSpace)1u, float))) but I have never declared a const of that type nor have I used typeid explicitly in my program. Where is this coming from? The program is just: enum AddrSpace { Global, Shared } st

Re: Finding source of typeid use

2017-07-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 7 July 2017 at 08:49:58 UTC, Nicholas Wilson wrote: My library is generating a typeid from somewhere. e.g. typeid(const(Pointer!(cast(AddrSpace)1u, float))) [...] It seems to be coming from the need to hash the type, goodness knows why, which explains why I only get the const varie

Re: Finding source of typeid use

2017-07-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 8 July 2017 at 05:36:49 UTC, rikki cattermole wrote: On 08/07/2017 2:35 AM, Nicholas Wilson wrote: On Friday, 7 July 2017 at 08:49:58 UTC, Nicholas Wilson wrote: My library is generating a typeid from somewhere. e.g. typeid(const(Pointer!(cast(AddrSpace)1u, float))) [...] It see

Re: Finding source of typeid use

2017-07-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 8 July 2017 at 08:56:17 UTC, Rainer Schuetze wrote: On 08.07.2017 07:55, Nicholas Wilson wrote: On Saturday, 8 July 2017 at 05:36:49 UTC, rikki cattermole wrote: On 08/07/2017 2:35 AM, Nicholas Wilson wrote: On Friday, 7 July 2017 at 08:49:58 UTC, Nicholas Wilson wrote: My libr

Re: Function with static array as parameter

2017-07-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote: What is the best way in D to create a function that receives a static array of any length? Do know that static arrays are passed by value in D, so passing a static array of a million elements will copy them... There are two solution

Re: Whats the correct way to pass a D array type to a win32 api function wanting a buffer?

2017-07-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 13 July 2017 at 01:15:46 UTC, FoxyBrown wrote: Everything I do results in some problem, I've tried malloc but then converting the strings resulted in my program becoming corrupted. Heres the code: auto EnumServices() { auto schSCManager = OpenSCManager(null, null, SC_MANAG

Re: nogc string concatenation?

2017-07-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 14 July 2017 at 00:40:38 UTC, FoxyBrown wrote: Anyone have an efficient implementation that is easy to use? If you are OK with just a range spanning the two or more strings, then you could use chain as is.

Re: Get which derived class an object is if it's stored in an array of its base class

2017-07-15 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 15 July 2017 at 13:45:40 UTC, Morimur55 wrote: On Saturday, 15 July 2017 at 13:12:49 UTC, Adam D. Ruppe wrote: On Saturday, 15 July 2017 at 13:02:52 UTC, Morimur55 wrote: [...] The `typeid(obj)` will give the type... but why do you need it? The classinfo returned by that doesn't

Re: Avoid if statements for checking neighboring indexes in a 2D array

2017-07-16 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 16 July 2017 at 10:37:39 UTC, kerdemdemir wrote: My goal is to find connected components in a 2D array for example finding connected '*' chars below. x x x x x x x x x x x x x x * * x x x x * * x x x x x * * x * x x x x x There are two connected

Re: D doesn't read the first character of a file (reads everything but the first chararacter) with either read() or readText()

2017-07-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 02:21:59 UTC, Enjoys Math wrote: DMD32 D Compiler v2.074.1 import std.file; void main() { string bigInput = readText("input.txt"); } The file is 7 MB of ascii text, don't know if that matters... Should I upgrade versions? I wonder if it thinks there is a BOM

Re: Idiomatic way of writing nested loops?

2017-07-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 17 July 2017 at 11:07:35 UTC, Anton Fediushin wrote: Hello! What is the best way of rewriting this code in idiomatic D manner? -- foreach(a; ["foo", "bar"]) { foreach(b; ["baz", "foz", "bof"]) { foreach(c; ["FOO", "BAR"]) { // Some operations on a, b and c } } }

Re: How does one determine the UDAs of all symbols contained in a given module?

2017-07-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 19 July 2017 at 07:29:55 UTC, Andrew Edwards wrote: Given a module (somepackage.somemodule) how does one programmatically determine the symbols contained therein and associated UDAs? Where symbol is a variable, function, UDT, etc... is this possible? foreach (symbol; somep

module convicts with package

2017-07-19 Thread Nicholas Wilson via Digitalmars-d-learn
Im probably missing something really obvious but Error: module dcompute.driver.ocl120 from file source/dcompute/driver/ocl120/packge.d conflicts with package name ocl120 the package.d file in question ``` module dcompute.driver.ocl120; public import dcompute.driver.error; public import dco

Re: module convicts with package

2017-07-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 20 July 2017 at 04:38:40 UTC, Adam D. Ruppe wrote: On Thursday, 20 July 2017 at 04:33:55 UTC, Nicholas Wilson wrote: Error: module dcompute.driver.ocl120 from file source/dcompute/driver/ocl120/packge.d conflicts with package Is that a copy/paste error or did you actually misspel

Re: find difference between two struct instances.

2017-07-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 21 July 2017 at 23:38:51 UTC, FoxyBrown wrote: On Friday, 21 July 2017 at 22:35:20 UTC, Era Scarecrow wrote: On Friday, 21 July 2017 at 21:03:22 UTC, FoxyBrown wrote: Is there a way to easily find the differences between to struct instances? I would like to report only the difference

Re: Cast to subclass in the dmd compiler

2017-07-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 25 July 2017 at 21:06:25 UTC, unDEFER wrote: I have found the answer in the code. Right code is: Import imp = m.isImport(); if (imp !is null) Thank you. grep for kluge in code, you'll find all the places it does its own RTTI.

Re: using DCompute

2017-07-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 27 July 2017 at 21:33:29 UTC, James Dean wrote: I'm interested in trying it out, says it's just for ldc. Can we simply compile it using ldc then import it and use dmd, ldc, or gdc afterwards? The ability to write kernels is limited to LDC, though there is no practical reason that

Re: using DCompute

2017-07-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 28 July 2017 at 00:39:43 UTC, James Dean wrote: On Friday, 28 July 2017 at 00:23:35 UTC, Nicholas Wilson wrote: On Thursday, 27 July 2017 at 21:33:29 UTC, James Dean wrote: I'm interested in trying it out, says it's just for ldc. Can we simply compile it using ldc then import it and

std.meta.Replace using index

2017-07-28 Thread Nicholas Wilson via Digitalmars-d-learn
Hi I want to replace each occurrence of a particular type in an AliasSeq with a type from another AliasSeq (the both have the same length) with the corresponding index i.e. (int long long float) (byte char double dchar) replacing long should yield (int char double float) std.meta.Replace wo

Re: std.meta.Replace using index

2017-07-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 28 July 2017 at 22:06:27 UTC, Ali Çehreli wrote: I think it works: template replace(T) { template inside(Src...) { template from(Dst...) { import std.meta; enum f = staticIndexOf!(T, Src); static if (f == -1) { alias from

Re: Question on SSE intrinsics

2017-07-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 29 July 2017 at 22:45:12 UTC, piotrekg2 wrote: On Saturday, 29 July 2017 at 18:19:47 UTC, Johan Engelen wrote: On Saturday, 29 July 2017 at 16:01:07 UTC, piotrekg2 wrote: Hi, I'm trying to port some of my c++ code which uses sse2 instructions into D. The code calls the following i

Re: Question on SSE intrinsics

2017-07-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 30 July 2017 at 02:05:32 UTC, Nicholas Wilson wrote: On Saturday, 29 July 2017 at 22:45:12 UTC, piotrekg2 wrote: What about __builtin_ctz? https://github.com/ldc-developers/druntime/blob/ldc/src/ldc/intrinsics.di#L325 you can also make it out of bsf or bsr (i can't remember which)

Re: rename file, execute os, etc at compile time

2017-08-06 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 6 August 2017 at 19:56:06 UTC, Johnson Jones wrote: is it possible to do? I would like to pre-configure some stuff at "pre-compilation"(in ctfe but before the rest of the program actually gets compiled). I know it's not safe and all that but in my specific case it would help. I'll

Re: std.math module

2017-08-06 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 6 August 2017 at 23:33:26 UTC, greatsam4sure wrote: import std.math; import std.stdio; cos(90*PI/180) = -2.7e-20 instead of zero. I will appreciate any help. thanks in advance. tan(90*PI/180) = -3.689e+19 instead of infinity. What is the best way to use this module in addition t

Re: Real naive template question

2017-08-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 14 August 2017 at 00:44:05 UTC, WhatMeForget wrote: module block_template; void main() { template BluePrint(T, U) { T integer; U floatingPoint; } BluePrint!(int, float); } // DMD returns // template.d(13): Error: BluePrint!(int, float) has no effect

Re: real simple delegate question.

2017-08-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 19 August 2017 at 18:33:37 UTC, WhatMeWorry wrote: Or maybe another approach would be to ask, what type is the compiler replacing auto with. If you want to find out compile with `-vcg-ast`

Re: Using mixin templates for operator overloading.

2017-08-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 19 August 2017 at 10:16:18 UTC, Balagopal Komarath wrote: Let us say I want to automatically define subtraction given that addition and negation are defined. I tried the following using mixin templates. If I simply mixin the template using "mixin sub;", then it gives the error [.

Re: fasta parser with iopipe?

2017-08-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 23 August 2017 at 09:53:49 UTC, biocyberman wrote: I lost my momentum to learn D and want to gain it up again. Therefore I need some help with this seemingly simple task: # Fasta sequence \>Entry1_ID header field1|header field2|... CAGATATCTTTGATGTCCTGATTGGAAGGACCGTTGGCCACC

wrapping a C style delegate

2017-08-23 Thread Nicholas Wilson via Digitalmars-d-learn
I want to wrap: ErrorEnum function(Struct* s, void function(Struct*, ErrorEnum status, void *userData) callback, void *userData, uint flags); as a member of a wrapping struct struct Mystruct { Struct* s; // wrapped ErrorEnum addCallback(void delegate(Struct*, ErrorEnum status))

Re: wrapping a C style delegate

2017-08-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 25 August 2017 at 13:49:20 UTC, Kagamin wrote: You're not specific enough. What would be semantics of such wrapper? The C function I'm trying to wrap takes a function pointer which is essentially a delegate, but not quite: ErrorEnum function(Struct* s, void function(Struct*, Error

Re: wrapping a C style delegate

2017-08-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 26 August 2017 at 00:27:47 UTC, Ali Çehreli wrote: I think you need a variation of intermediateCallback() below. I passed the address of the delegate as userData but you can construct any context that contains everything that you need (e.g. the address of ms). import std.stdio;

hijack dub test

2017-08-30 Thread Nicholas Wilson via Digitalmars-d-learn
My project is a library, but I also need to test it and unit tests won't cut it (external hardware). How do you set up the dub.json to build the library normally but when it is invoked with `dub test` it runs a separate configuration that also includes files in the `source/test` folder, but a

Re: hijack dub test

2017-08-31 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 31 August 2017 at 07:04:13 UTC, Jacob Carlborg wrote: On 2017-08-31 08:41, Nicholas Wilson wrote: My project is a library, but I also need to test it and unit tests won't cut it (external hardware). How do you set up the dub.json to build the library normally but when it is invok

Re: Synax for variadic template

2017-09-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 1 September 2017 at 09:38:59 UTC, Alex wrote: Hi all! Say, I have struct A(T...) { T arr; } struct B(T...) { T[] arr; } void main() { A!(int[], double[]) a; a.arr[0] ~= 5; a.arr[0] ~= 6; static assert(!__traits(compiles, a.arr[0] ~= 3.

Template substitution for function parameters

2017-09-01 Thread Nicholas Wilson via Digitalmars-d-learn
So I have the following types struct DevicePointer(T) { T* ptr; } struct Buffer(T) { void* driverObject; T[] hostMemory; } and a function auto enqueue(alias k)(HostArgsOf!k) { ... } where k would be a function like void foo( DevicePointer!float a, float b , int c) { ... } How can I

Re: Template substitution for function parameters

2017-09-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 1 September 2017 at 10:58:51 UTC, user1234 wrote: On Friday, 1 September 2017 at 10:15:09 UTC, Nicholas Wilson wrote: So I have the following types ... i.e. it substitutes the template DevicePointer for the template Buffer in Parameters!foo, The templates can be assumed to not be nes

Re: Template substitution for function parameters

2017-09-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 1 September 2017 at 11:33:15 UTC, Biotronic wrote: On Friday, 1 September 2017 at 10:15:09 UTC, Nicholas Wilson wrote: So I have the following types struct DevicePointer(T) { T* ptr; } struct Buffer(T) { void* driverObject; T[] hostMemory; } and a function auto enqueue(ali

Re: 24-bit int

2017-09-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 1 September 2017 at 22:10:43 UTC, Biotronic wrote: On Friday, 1 September 2017 at 19:39:14 UTC, EntangledQuanta wrote: Is there a way to create a 24-bit int? One that for all practical purposes acts as such? This is for 24-bit stuff like audio. It would respect endianness, allow for

Re: Template substitution for function parameters

2017-09-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 1 September 2017 at 11:33:15 UTC, Biotronic wrote: On Friday, 1 September 2017 at 10:15:09 UTC, Nicholas Wilson wrote: So I have the following types struct DevicePointer(T) { T* ptr; } struct Buffer(T) { void* driverObject; T[] hostMemory; } and a function auto enqueue(ali

Re: Help required on Array appender

2017-09-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 2 September 2017 at 10:15:04 UTC, Vino.B wrote: Hi All, Can you please guide me how can i use array appender for the below piece of code string[][] cleanFiles (string FFs, string Step) { auto dFiles = dirEntries(FFs, SpanMode.shallow).filter!(a => a.isFile).map!(a => tuple(a.na

Re: Help required on Array appender

2017-09-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 2 September 2017 at 21:11:17 UTC, Vino.B wrote: On Saturday, 2 September 2017 at 15:47:31 UTC, Vino.B wrote: On Saturday, 2 September 2017 at 12:54:48 UTC, Nicholas Wilson wrote: [...] Hi, [...] Hi, Was able to resolve the above issue, but again getting the same for other

Re: Using closure causes GC allocation

2017-09-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 4 September 2017 at 05:45:18 UTC, Vino.B wrote: On Saturday, 2 September 2017 at 20:54:03 UTC, Vino.B wrote: On Saturday, 2 September 2017 at 20:10:58 UTC, Moritz Maxeiner wrote: On Saturday, 2 September 2017 at 18:59:30 UTC, Vino.B wrote: [...] Cannot reproduce under Linux with d

Re: SIMD under LDC

2017-09-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 4 September 2017 at 20:39:11 UTC, Igor wrote: I found that I can't use __simd function from core.simd under LDC Correct LDC does not support the core.simd interface. and that it has ldc.simd but I couldn't find how to implement equivalent to this with it: ubyte16* masks = ...; fo

Re: Ranges seem awkward to work with

2017-09-11 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 12 September 2017 at 01:13:29 UTC, Hasen Judy wrote: Is this is a common beginner issue? I remember using an earlier version of D some long time ago and I don't remember seeing this concept. Now, a lot of library functions seem to expect ranges as inputs and return ranges as outpu

Re: Catching C++ Exceptions in D - Windows and Linux

2017-09-11 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 12 September 2017 at 03:51:45 UTC, Laeeth Isharc wrote: Hi. I'm here in HK with Ilya, Atila, John Colvin, and Jonathan Davis. I wondered what the current state of D catching C++ exceptions was on Linux and Windows. I know that some work was done on making this possible, and my u

Re: Temporarily adding -vgc to a DUB build

2017-09-16 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 16 September 2017 at 21:45:34 UTC, Nordlöw wrote: How do I temporarily enable -vgc when building my app with DUB? I've tried DFLAGS=-vgc /usr/bin/dub build --build=unittest but it doesn't seem to have any effect as it doesn't rebuild directly after the call /usr/bin/dub build -

Re: Error 16: Index Range error while building examples from D Web development

2017-09-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 17 September 2017 at 11:42:16 UTC, kerdemdemir wrote: Hi, Thanks its price dropped to 10 Euros I bought the the D Web Development book and I were trying to build some examples. The example in Chapter3 called noteapp4 is giving me this error : [...] Optlink bug I guess? try usin

Re: How to compile for Win64 with Visual D? Optlink error?

2017-09-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 11:47:00 UTC, Timothy Foster wrote: I'm trying to compile my project as a Win64 application but this is happening: Building C:\Users\me\test\test.exe... OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.

Re: Connecting python to D on socket of localhost : target machine actively refuses connection

2017-09-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 22 September 2017 at 04:37:44 UTC, Enjoys Math wrote: On Friday, 22 September 2017 at 04:25:00 UTC, Enjoys Math wrote: I've tried opening the port for TCP with windows 10 firewall settings. Same result. What tool would best help me debug this? Wireshark or is that too low level?

Dub use local fork

2017-09-22 Thread Nicholas Wilson via Digitalmars-d-learn
I want to use a fork of one of my dub dependencies so I can make sure that it works before I merge the fork into upstream. http://code.dlang.org/advanced_usage says Path-based dependencies Package descriptions in the dub.json/dub.sdl can specify a path instead of a version; this can be

Re: Dub use local fork

2017-09-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 23 September 2017 at 04:45:47 UTC, Mike Parker wrote: On Saturday, 23 September 2017 at 03:13:15 UTC, Nicholas Wilson wrote: my dub.selections.json is currently: { "fileVersion": 1, "versions": { "derelict-cl": "2.0.0", "derelict-cu

Re: Dub use local fork

2017-09-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 23 September 2017 at 09:37:54 UTC, rikki cattermole wrote: On 23/09/2017 10:34 AM, Guillaume Piolat wrote: On Saturday, 23 September 2017 at 03:16:30 UTC, rikki cattermole wrote: Alternatively you can alter the package that dub already knows about. Does the trick more easily ;)

Re: [FreeBSD] 0x000000000061d8cd in rt.aaA.Impl.findSlotLookup(ulong, const(void*), const(TypeInfo)) inout ()

2017-09-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 23 September 2017 at 08:45:00 UTC, Mengu wrote: hello everyone i have a small program that parses an xml file, holding a list with 13610 elements. after making the list, it iterates over the list (paralele), goes to a web site and grabs the related data for that element. it wor

Re: [FreeBSD] 0x000000000061d8cd in rt.aaA.Impl.findSlotLookup(ulong, const(void*), const(TypeInfo)) inout ()

2017-09-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 23 September 2017 at 11:23:26 UTC, Nicholas Wilson wrote: Only other thing I can suggest is try linking against a debug phobos to see if you can get some more diagnostics. You might also try LDC's -fsanitize=address option for catching memory bugs.

Re: how to build project with locally compiled phobos

2017-09-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 23 September 2017 at 11:58:40 UTC, Mengu wrote: hi all i've successfully compiled phobos master with gmake on freebsd. (make fails, i've no clue at all as to why) how do i compile my project now against my local phobos with dub? with plain dmd? i tried (in dub.sdl): - full pat

Re: Can I skip sub directories with file.dirEntries() ?

2017-09-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 27 September 2017 at 09:00:55 UTC, Ky-Anh Huynh wrote: Hi, Can I have a `break` option when using `dirEntries()` (similar to `break` in a loop)? I want to study sub-directories but if any sub-directory matches my criteria I don't to look further into their subdirectories ```

Re: Sectioned variables?

2017-09-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 27 September 2017 at 11:59:16 UTC, Arav Ka wrote: GCC supports a `__attribute((section("...")))` for variables to put them in specific sections in the final assembly. Is there any way this can be achieved in D? Does GDC support this? GDC should https://github.com/D-Programming-GD

<    1   2   3   4   5   6   7   >