Re: Passing D reimplementation of C++ template as argument to a C++ function

2022-09-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 24 September 2022 at 07:04:34 UTC, Gregor Mückl wrote: Hi! I have a D template struct that reimplements a C++ class template with identical memory layout for a set of types that matter to me. Now, I want to use some C++ functions and classes that use these template instances,

Re: how to install the new dmd on Mac M1?

2022-08-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 26 August 2022 at 00:34:30 UTC, MichaelBi wrote: when using ldc2, has this error "ld: library not found for -lssl" after dub build --compiler=ldc2 So where is your ssl library located and how (if at all) are you telling the compiler/linker where to find it?

Re: Using LDC2 with --march=amdgcn

2022-07-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 24 July 2022 at 18:44:42 UTC, realhet wrote: Hello, I noticed that the LDC2 compiler has an architecture target called "AMD GCN". Is there an example code which is in D and generates a working binary of a hello world kernel. I tried it, and just failed at the very beginning:

Re: Obtain pointer from static array literal

2021-10-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 8 October 2021 at 05:31:21 UTC, codic wrote: On Friday, 8 October 2021 at 05:01:00 UTC, Nicholas Wilson wrote: note that if the pointer is not escaped from the function (i.e. thing is void thing(scope int* abc)note the addition of scope) LDC will perform promotion of GC allocation

Re: Obtain pointer from static array literal

2021-10-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 8 October 2021 at 02:49:17 UTC, codic wrote: I am working with a C API (XCB) which uses `void*` a lot to obtain parameter packs; these are very small and throwaway so I want them to be allocated to the stack. CUDA has something similar that I have to deal with for dcompute[1]. The

Re: How can we view source code that has been generated (say via "static foreach") ?

2021-09-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 16 September 2021 at 04:54:21 UTC, james.p.leblanc wrote: Thank you for your kind response. Wow, at first the large output file from a small test program was a bit surprising .., but actually it is manageable to dig through to find the interesting bits. So, this is quite useful!

Re: yet another segfault - array out of bound is not caught by try catch

2021-09-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 17 September 2021 at 11:10:33 UTC, seany wrote: I have now this function, as a private member in a Class : } catch (RangeError er) { I can't remember if you can catch an index OOB error but try `catch (Throwable er)` will work if it is catchable at all and you can

Re: Now can build and run d on RISC-V arch?

2021-06-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 6 June 2021 at 04:14:20 UTC, lili wrote: I want learn RISC-V and write a simple kernel on it using d. but can not find any support about RISC-V. LDC can compile for riscv 32 and 64 bit. https://github.com/ldc-developers/ldc/releases/tag/v1.26.0 use `-mtriple=riscv32` or

Re: Strange error

2021-03-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 22 March 2021 at 07:52:14 UTC, MichaelJames wrote: Tell me, did you manage to solve this problem? https://github.com/dlang/dmd/pull/12300

synthesising instantiated template parameters and arguments

2020-10-27 Thread Nicholas Wilson via Digitalmars-d-learn
Given template ScopeClass(C) { //... } where C is a, possibly templated, class I want the eponymous member of ScopeClass!(C) to have the same templatedness (both parameters and arguments)as C. For a non-template C this is a simple as: template ScopeClass(C) { class ScopeClass {

Re: Two ways of receiving arrays on the C ABI

2020-10-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 20 October 2020 at 00:16:48 UTC, Ali Çehreli wrote: On the D side, both of the following extern(C) functions take the same arguments. https://github.com/dlang/dmd/pull/8120 there are issues with structs. Not sure about length/ptr.

Re: Asserting that a base constructor is always called

2020-05-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 24 May 2020 at 06:38:46 UTC, Tim wrote: Oh right. I mean it makes sense but I got confused when super() is valid syntax. Why would you need to call the super constructor when it's called automatically? A base class with a constructor that has no args will automatically get called

Re: determine ldc version in static if or version?

2020-04-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 1 April 2020 at 21:19:54 UTC, Adam D. Ruppe wrote: I want to do like static if(__LDC_VERSION == 1.19) { // declaration } All the tricks I know that I have tried so far give the dmd numbers. Perhaps I could use that to identify a particular version as a hack, but I

Re: No UFCS with nested functions?

2019-11-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 4 November 2019 at 19:51:26 UTC, Tobias Pankrath wrote: Why does the following not work? It works, if I move the 'prop' out of 'foo'. --- struct S { ubyte[12] bar; } bool foo (ref S s) { static bool prop(const(ubyte)[] f) { return f.length > 1; } return

Re: exceptions and optimization

2019-10-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 21 October 2019 at 21:09:32 UTC, Peter Jacobs wrote: On Monday, 21 October 2019 at 20:37:32 UTC, Nicholas Wilson wrote: What kind of conditions are you wanting to throw exception on? infinities, NaNs, ill conditioning, something else? As always the best way to check is to mark

Re: contains method on immutable sorted array

2019-10-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 21 October 2019 at 10:14:54 UTC, Andrey wrote: Hello, I have got a global constant immutable array: immutable globalvalues = sort(cast(wstring[])["й", "ц", "ук", "н"]); Somewhere in program I want to check an existance: globalvalues.contains("ук"w).writeln; But get an error:

Re: exceptions and optimization

2019-10-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 21 October 2019 at 20:12:19 UTC, Peter Jacobs wrote: Toward the end of Walter's recent talk, D at 20, he says something to the effect that optimizations are disabled when exceptions can be thrown. We have a compressible flow solver in which it is very convenient to be able to throw

Re: Is there a way to do the same thing in entry and return of a bunch of functions?

2019-09-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 17 September 2019 at 17:11:09 UTC, Stefanos Baziotis wrote: I think it's better to give a concrete example rather than explaining this vaguely. -- The question -- Can we do better ? For one, I believe that because D does not have a preprocessor, we have to do an actual declaration

Re: LDC asm for int128

2019-09-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 10 September 2019 at 06:18:05 UTC, Newbie2019 wrote: I want to translate this c code into d (build with ldc), so I can use -flto and inline with other code. uint64_t _wymum(uint64_t A, uint64_t B){ __uint128_t r = A ; r *= B; return (r>>64)^r; } Do i need

Re: Undefined reference - built from source DMD

2019-09-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 10 September 2019 at 11:12:30 UTC, Stefanos Baziotis wrote: I don't if this the right group to post this. DMD built from source fails to link / find `main`. The error is: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start': (.text+0x20):

Re: Why is sformat and formattedWrite (appender) allocating GC mem here?

2019-08-31 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 31 August 2019 at 21:12:32 UTC, ag0aep6g wrote: I've made a pull request to get rid of those allocations: https://github.com/dlang/phobos/pull/7163 Merged.

Re: Shadertoy in Dcompute?

2019-08-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 22 August 2019 at 00:57:26 UTC, Bert wrote: How hard would it be to do something like Shadertoy in Dcompute and would it be any faster? I don't like the basics of Shadertoy, lots of nonsense to do basic stuff. E.g., to work with complex numbers one must essentially do everything

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 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

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

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

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

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

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

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

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

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: 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

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: 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

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

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

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

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 :

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

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

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

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

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

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

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(, b, c); } ``` The type of T has to be a pointer to a shared int (you get a

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: 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

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

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

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

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 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

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

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,

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

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: 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

Re: D & C++ class question

2018-11-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 28 November 2018 at 13:13:40 UTC, bauss wrote: Well unfortunately I cannot control the C++ side of things, but I assume that it'll work properly with extern(C++) so I guess I will just go ahead and try and see if everything works out. I have access to the C++ source so at the

Re: D & C++ class question

2018-11-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 28 November 2018 at 07:22:46 UTC, bauss wrote: If I have a class from D. How would you use that class in C++? Like what's the correct approach to this. Would it work just by doing "extern(C++)" or will that only work for D to use C++ classes? If you have foo.d class Foo

Re: memoize & __traits(compiles...)

2018-11-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 23 November 2018 at 10:34:11 UTC, John Chapman wrote: I'm doing a fair amount of repeatedly checking if a function compiles with __traits(compiles...), executing the function if so, erroring out if not, like this: static if (__traits(compiles, generateFunc1())) { return

Re: D is supposed to compile fast.

2018-11-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 23 November 2018 at 08:57:57 UTC, Chris Katko wrote: Any time I see people mention the benefits of D, I see "compile times" "compile times" "compile times" over and over. I'm using very modest amounts of templates, for a fairly small sized program (very early work toward a game),

Re: Making external types available to mixins

2018-11-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 17 November 2018 at 17:58:54 UTC, John Chapman wrote: The following code doesn't compile because the generated type name needs to be available inside the mixin's scope, whereas it's actually in another module. auto makeWith(string className, Args…)(auto ref Args args) {

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 17 November 2018 at 13:13:36 UTC, aliak wrote: On Friday, 16 November 2018 at 13:21:39 UTC, Stanislav Blinov wrote: auto assumeNoGC(T)(return scope T t) @trusted { /* ... */ } Sawweet! Thanks, that made the printing possible! "scope" is const from what I understand right? It

Re: dip1000: why can't the addressee come into existence later?

2018-11-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 10 November 2018 at 06:56:29 UTC, Neia Neutuladh wrote: Is this right? Are you sure you added @safe to the second example? https://run.dlang.io/is/2RbOwK fails to compile.

Re: Dealing with raw types as attributes

2018-11-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 2 November 2018 at 04:18:47 UTC, Neia Neutuladh wrote: On Fri, 02 Nov 2018 04:01:00 +, Nicholas Wilson wrote: By noting that all (interesting for the purpose of UDA's i.e. not void) types have a .init or you could do static if (is(typeof(uda) == Foo) || is(uda == Foo))

Re: Dealing with raw types as attributes

2018-11-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 2 November 2018 at 03:13:19 UTC, Neia Neutuladh wrote: On Fri, 02 Nov 2018 00:36:18 +, Nicholas Wilson wrote: What do you do to handle this? @Foo() int bar; instead of @Foo int bar; Right. And if you're offering a library with UDAs for other people to use? I mean I

Re: Dealing with raw types as attributes

2018-11-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 1 November 2018 at 16:14:45 UTC, Neia Neutuladh wrote: The spec says that a user-defined attribute must be an expression, but DMD accepts a wide range of things as UDAs: Indeed UDA are odd beasts: https://issues.dlang.org/show_bug.cgi?id=19127 What do you do to handle this?

Re: Removing the precision from double

2018-11-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 1 November 2018 at 23:59:26 UTC, kerdemdemir wrote: I have two numbers First The price = 0.0016123 Second Maximum allowed precision = 0.0001(it can be only 0.001, 0.0001, 0.1, ..., 0.01 bunch of zeros and than a one that is it) Anything more precise than

Re: link errors when using extern (C) structs

2018-10-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 28 October 2018 at 06:59:31 UTC, DanielG wrote: For the benefit of anybody who encounters a problem like this in the future ... originally I had my C library "header" files (renamed from .di to .d after the feedback from Nicholas) in a special 'headers/' subdir, used as an import

Re: link errors when using extern (C) structs

2018-10-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 28 October 2018 at 04:23:27 UTC, DanielG wrote: On Sunday, 28 October 2018 at 03:39:41 UTC, Nicholas Wilson wrote: write struct Foo { double bar = 0.0; // The bitpattern of 0.0 is 0 } Thank you for your response. Can you elaborate on 'write struct...'? Is that special syntax?

Re: Dub Renaming source/app.d makes project a library

2018-10-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 28 October 2018 at 03:34:57 UTC, Neia Neutuladh wrote: targetType "executable" does it for me (dub 1.11.0). Can you post your full dub.sdl? I'm an idiot, I was in the wrong directory that does seem to work.

Re: link errors when using extern (C) structs

2018-10-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 28 October 2018 at 03:28:20 UTC, DanielG wrote: I'm wrapping a C library which has a lot of structs defined, and I keep running into issues where dmd complains that .init isn't defined ("Symbol Undefined __xxx__initZ" etc). I'm struggling to narrow it down to a simple example

Dub Renaming source/app.d makes project a library

2018-10-27 Thread Nicholas Wilson via Digitalmars-d-learn
So I have a project that is a simple dub app with source/ app.d $dub Performing "debug" build using /Library/D/dmd/bin/dmd for x86_64. foo ~master: building configuration "application"... Linking... Running ./foo Edit source/app.d to start your project. $mv source/app.d source/foo.d $dub

Re: Help needed to extend the core.thread

2018-10-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 26 October 2018 at 01:58:47 UTC, Heromyth wrote: Maybe it's better to extend core.thread.Thread by inheriting it. Am I right? Thanks! Yes, see the example at https://dlang.org/phobos/core_thread.html#.Thread

Re: Reading binary streams with decoding to Unicode

2018-10-15 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 15 October 2018 at 21:48:05 UTC, Vinay Sajip wrote: On Monday, 15 October 2018 at 19:56:22 UTC, Nicholas Wilson wrote: import std.file : readText; import std.uni : byCodePoint, byGrapheme; // or import std.utf : byCodeUnit, byChar /*utf8*/, byWchar /*utf16*/, byDchar /*utf32*/,

Re: Reading binary streams with decoding to Unicode

2018-10-15 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 15 October 2018 at 18:57:19 UTC, Vinay Sajip wrote: On Monday, 15 October 2018 at 17:55:34 UTC, Dukc wrote: This is done automatically for character arrays, which includes strings. wchar arrays wil iterate by UTF-16, and dchar arrays by UTF-32. If you have a byte/ubyte array you

Re: Trying to make FreeList Allocator example compile

2018-10-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 8 October 2018 at 21:50:33 UTC, Per Nordlöw wrote: I'm trying to compile the example import std.experimental.allocator.building_blocks.free_list : FreeList; theAllocator = allocatorObject(FreeList!8()); at https://dlang.org/phobos/std_experimental_allocator.html but fails

Re: Details on how aggregates are constructed with `new` and later destroyed by the GC

2018-10-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 8 October 2018 at 11:19:40 UTC, Per Nordlöw wrote: I want to understand how calls to `new` for classes see _d_newclass and structs are lowered by the compiler and druntime to a GC-allocation (specifically how the `ba`-argument bits are determined) followed by an initialization

Re: Is there an efficient byte buffer queue?

2018-10-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 8 October 2018 at 09:39:55 UTC, John Burton wrote: My use case is sending data to a socket. One part of my program generates blocks of bytes, and the socket part tries to send them to the socket and then removes from the queue the number that got sent. [...] Try searching for

Re: Is there a function for this?

2018-10-06 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 6 October 2018 at 13:17:22 UTC, bauss wrote: Let's say you have a range with struct, but some of the struct are duplicates of each other. Is there a standard function in Phobos to remove duplicates? My first thought was "uniq", but it can't really do it like that, but it doesn't

Re: Error: variable 'xyz' has scoped destruction, cannot build closure

2018-10-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 5 October 2018 at 19:31:56 UTC, Jon Degenhardt wrote: On Friday, 5 October 2018 at 16:34:32 UTC, Paul Backus wrote: You can thread multiple arguments through to `each` using `std.range.zip`: tenRandomNumbers .zip(repeat(output)) .each!(unpack!((n, output) =>

Re: Error: variable 'xyz' has scoped destruction, cannot build closure

2018-10-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 5 October 2018 at 06:44:08 UTC, Nicholas Wilson wrote: Alas is does not because each does not accept additional argument other than the range. Shouldn't be hard to fix though. https://issues.dlang.org/show_bug.cgi?id=19287

Re: Error: variable 'xyz' has scoped destruction, cannot build closure

2018-10-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 5 October 2018 at 06:22:57 UTC, Nicholas Wilson wrote: tenRandomNumbers.each!((n,o) => o.appendln(n.to!string))(output); or tenRandomNumbers.each!((n, ref o) => o.appendln(n.to!string))(output); should hopefully do the trick (run.dlang.io seems to be down atm). Alas is does

Re: Error: variable 'xyz' has scoped destruction, cannot build closure

2018-10-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 5 October 2018 at 03:27:17 UTC, Jon Degenhardt wrote: I got the compilation error in the subject line when trying to create a range via std.range.generate. Turns out this was caused by trying to create a closure for 'generate' where the closure was accessing a struct containing a

Re: Wrong module initialization order when building with Dub on Windows?

2018-10-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 01:57:00 UTC, Vladimir Panteleev wrote: Ran into this today, don't have time to dig in now but maybe someone ran into this too. Steps to reproduce: - git clone https://github.com/CyberShadow/ae - cd ae/demo/inputtiming - (download/unpack

Re: New With Struct and Getting Class Object Pointers

2018-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 30 September 2018 at 09:30:38 UTC, Vijay Nayar wrote: Is there a way to either have a constant reference to a class that can be set to a new value, or is there a way to convert the class variable to a class pointer? Alex has mentioned Rebindable, which is the answer to your first

Re: New With Struct and Getting Class Object Pointers

2018-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 30 September 2018 at 07:29:00 UTC, Vijay Nayar wrote: I have two brief questions. Code that uses "new" to create struct objects appears to compile and run. Is this an actual language feature, to get structs on the heap? void main() { struct S {int data = 1;} S* s1

Re: How to use math functions in dcompute?

2018-09-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 20 September 2018 at 12:43:02 UTC, Nicholas Wilson wrote: Hmm, I can reproduce. Will look into it. pragma(LDC_intrinsic, "llvm.nvvm.cos.approx.f") float cos(float val); does work but is an approximation.

Re: How to use math functions in dcompute?

2018-09-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 20 September 2018 at 05:16:04 UTC, Sobaya wrote: On Wednesday, 19 September 2018 at 00:22:44 UTC, Nicholas Wilson wrote: On Wednesday, 19 September 2018 at 00:11:13 UTC, Nicholas Wilson wrote: On Tuesday, 18 September 2018 at 06:25:33 UTC, Sobaya wrote: On Tuesday, 18 September

Re: How to use math functions in dcompute?

2018-09-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 19 September 2018 at 00:11:13 UTC, Nicholas Wilson wrote: On Tuesday, 18 September 2018 at 06:25:33 UTC, Sobaya wrote: On Tuesday, 18 September 2018 at 01:39:51 UTC, Nicholas Wilson wrote: On Tuesday, 18 September 2018 at 00:25:33 UTC, Sobaya wrote: I'm waiting for the update.

Re: How to use math functions in dcompute?

2018-09-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 18 September 2018 at 06:25:33 UTC, Sobaya wrote: On Tuesday, 18 September 2018 at 01:39:51 UTC, Nicholas Wilson wrote: On Tuesday, 18 September 2018 at 00:25:33 UTC, Sobaya wrote: I'm waiting for the update. How's your progress? I t appears I have broke SPIR-V completely

Re: How to use math functions in dcompute?

2018-09-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 18 September 2018 at 00:25:33 UTC, Sobaya wrote: I'm waiting for the update. How's your progress? I t appears I have broke SPIR-V completely somewhere along the line, I may release a v0.2 with out it, hopefully within the week.

Re: How to use math functions in dcompute?

2018-09-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 18 September 2018 at 00:25:33 UTC, Sobaya wrote: On Friday, 7 September 2018 at 10:53:25 UTC, Sobaya wrote: On Friday, 7 September 2018 at 10:17:47 UTC, Nicholas Wilson wrote: On Friday, 7 September 2018 at 06:45:32 UTC, Sobaya wrote: [...] You're missing an "m" in "nvvm", dunno

Re: dub windows unrecognised file extension a

2018-09-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 9 September 2018 at 04:53:05 UTC, Nicholas Wilson wrote: On Sunday, 9 September 2018 at 04:01:30 UTC, Nicholas Wilson wrote: On windows with dub it seems to be creating libfoo.a instead of foo.lib, I don't think I changed any settings. Old build based on 2.078 DMDFE seem to have

Re: dub windows unrecognised file extension a

2018-09-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 9 September 2018 at 04:01:30 UTC, Nicholas Wilson wrote: On windows with dub it seems to be creating libfoo.a instead of foo.lib, I don't think I changed any settings. Old build based on 2.078 DMDFE seem to have built .lib but LDC based on 2.082 seems to be building .a This

dub windows unrecognised file extension a

2018-09-08 Thread Nicholas Wilson via Digitalmars-d-learn
On windows with dub it seems to be creating libfoo.a instead of foo.lib, I don't think I changed any settings. Old build based on 2.078 DMDFE seem to have built .lib but LDC based on 2.082 seems to be building .a

Re: How to use math functions in dcompute?

2018-09-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 7 September 2018 at 06:45:32 UTC, Sobaya wrote: Sorry for being late for reply. I'm using CUDA for back-end. So you mean if required function is "cos", pragma(LDC_intrinsic, "llvm.nvv.cos") T cos(T a); Is it right? You're missing an "m" in "nvvm", dunno if that will fix it. I

Re: How to use math functions in dcompute?

2018-08-31 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 30 August 2018 at 10:34:33 UTC, Sobaya wrote: On Monday, 27 August 2018 at 12:47:45 UTC, Nicholas Wilson wrote: On Monday, 27 August 2018 at 09:57:18 UTC, Sobaya wrote: On Monday, 27 August 2018 at 09:41:34 UTC, 9il wrote: On Monday, 27 August 2018 at 08:25:14 UTC, Sobaya wrote:

Re: How to use math functions in dcompute?

2018-08-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 27 August 2018 at 09:57:18 UTC, Sobaya wrote: On Monday, 27 August 2018 at 09:41:34 UTC, 9il wrote: On Monday, 27 August 2018 at 08:25:14 UTC, Sobaya wrote: I'm using dcompute(https://github.com/libmir/dcompute). In the development, I have got to use math functions such as sqrt in

  1   2   3   4   5   6   7   >