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

Re: Error: variable foo forward referenced

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

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

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 28 April 2017 at 19:08:18 UTC, ParticlePeter wrote: On Friday, 28 April 2017 at 17:57:34 UTC, Ali Çehreli wrote: On 04/28/2017 08:56 AM, ParticlePeter wrote: > C++ Function: > bool cppFunc( float[3] color ); > > D binding: > extern(C++) bool cppFunc( float[3] color ); > > Using with:

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

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

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.

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

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

Re: Do array literals still always allocate?

2017-05-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 14 May 2017 at 10:18:40 UTC, ag0aep6g wrote: On 05/14/2017 01:57 AM, Nicholas Wilson wrote: 1D arrays it doesn't, 2D or higher it does. What do you mean? This works just fine as well: import std.random; import std.stdio; int[2][2] testfunc(int num) @nogc { return [[0,

Re: Do array literals still always allocate?

2017-05-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 14 May 2017 at 12:02:03 UTC, Eugene Wissner wrote: On Sunday, 14 May 2017 at 11:45:12 UTC, ag0aep6g wrote: On 05/14/2017 01:40 PM, Nicholas Wilson wrote: dynamic array literals is what I meant. I don't follow. Can you give an example in code? void main() { ubyte[] arr = [ 1,

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 12 May 2017 at 21:26:01 UTC, Bastiaan Veelo wrote: On Friday, 12 May 2017 at 15:24:52 UTC, k-five wrote: A full version that I just added to my gitgub: https://github.com/k-five/dren You may like getopt[1] for command line argument parsing. https://dlang.org/phobos/std_getopt.html

Re: Structure of Arrays vs Array of Structures

2017-05-15 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 15 May 2017 at 06:44:53 UTC, Nordlöw wrote: After having watched Jonathan Blow's talk on Jai https://www.youtube.com/watch?v=TH9VCN6UkyQ=2880s I realized that we should add his Array-of-Structures (AoS) concept to Phobos, preferrably in std.typecons.StructArrays, as something like

Re: struct File. property size.

2017-05-11 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 11 May 2017 at 07:24:00 UTC, AntonSotov wrote: import std.stdio; int main() { auto big = File("bigfile", "r+"); //bigfile size 20 GB writeln(big.size); // ERROR! return 0; } // std.exception.ErrnoException@std\stdio.d(1029): Could

Re: Processing a gzipped csv-file by line-by-line

2017-05-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 22:20:52 UTC, Nordlöw wrote: What's fastest way to on-the-fly-decompress and process a gzipped csv-fil line by line? Is it possible to combine http://dlang.org/phobos/std_zlib.html with some stream variant of File(path).byLineFast ? I suggest you take a look

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote: I have a line of code that uses "to" function in std.conv for a purpose like: int index = to!int( user_apply[ 4 ] ); // string to int When the user_apply[ 4 ] has value, there is no problem; but when it is empty: "" it throws an

Re: Do array literals still always allocate?

2017-05-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 13 May 2017 at 18:32:16 UTC, Lewis wrote: import std.random; import std.stdio; int[4] testfunc(int num) @nogc { return [0, 1, num, 3]; } int main() { int[4] arr = testfunc(uniform(0, 15)); writeln(arr); return 0; } I've read a bunch of stuff that seems to indicate

Re: Do array literals still always allocate?

2017-05-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 14 May 2017 at 01:15:03 UTC, Lewis wrote: On Saturday, 13 May 2017 at 19:22:09 UTC, Steven Schveighoffer wrote: It's just out of date. Can't remember the version, but this did use to allocate. It doesn't any more. But only for this case. In most cases it does allocate. Okay cool,

Re: D for Web Development?

2017-06-08 Thread Nicholas Wilson via Digitalmars-d-learn
Welcome! On Thursday, 8 June 2017 at 07:32:44 UTC, Michael Reiland wrote: A few questions: - Is vibe.d the recommended way of doing web work? Yes. Adam D. Ruppe also has some easy to use libraries that may suit your need. - Is that book worth purchasing? Don't know. - Does D have a

Re: a way to specily floating-point numbers as bit patters

2017-06-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 9 June 2017 at 16:56:46 UTC, ketmar wrote: Petar Kirov [ZombineDev] wrote: Do HexFloats (http://dlang.org/spec/lex#HexFloat) help? hm. i somehow completely missed "%a" format specifier! yeah, "-0x1.6ep-3" did the trick. tnx. i should do my homework *before* posting big

Re: Using templates with interfaces

2017-06-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 25 June 2017 at 11:39:27 UTC, Andrew Chapman wrote: Hi guys, I'm a little confused as to whether D supports interfaces with templates. I can compile OK, but linking reports an error like this: Error 42: Symbol Undefined

Re: Dub command line knowledge sought

2017-06-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 23 June 2017 at 07:51:51 UTC, Russel Winder wrote: I am likely just staring at and missing the data needed: How does one invoke dub to fetch and build, and put into a place other that ~/.dub/… a package from Dub? dub fetch foo --version=1.0.0 mv ~/.dub/packages/foo-1.0.0

Re: templatized delegate

2017-05-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 23 May 2017 at 10:30:56 UTC, Alex wrote: On Monday, 22 May 2017 at 21:44:17 UTC, ag0aep6g wrote: With that kind of variadics, you're not dealing with a template. A (run-time) variadic delegate is an actual delegate, i.e. a value that can be passed around. But the variadic stuff is

Re: binding to C++

2017-05-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 26 May 2017 at 15:17:08 UTC, drug wrote: Trying to bind to cpp code I stop at some moment having undefined reference to some cpp function. But objdump -Ct cpplibrary.so shows me that this cpp function exists in the library. linker message about cpp function is _identical_ to

Re: Code improvement for DNA reverse complement?

2017-05-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 19 May 2017 at 12:21:10 UTC, biocyberman wrote: On Friday, 19 May 2017 at 09:17:04 UTC, Biotronic wrote: On Friday, 19 May 2017 at 07:29:44 UTC, biocyberman wrote: [...] Question about your implementation: you assume the input may contain newlines, but don't handle any other

Re: Fluent APIs

2017-05-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 21 May 2017 at 05:18:33 UTC, Russel Winder wrote: I am having a crisis of confidence. In two places I have structurally: datum.action() .map!(…) and then the fun starts as I need to actually do a flatMap. In one of the two places I have to: .array .joiner; but

Re: Implicit conversion from 'Ok' to 'Result' type when returning functions

2017-05-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 21 May 2017 at 08:44:31 UTC, David Zhang wrote: Hi, I was reading a bit about this in Rust, and their enum type. I was wondering if this is replicate-able in D. What I've got right now is rather clunky, and involves using `typeof(return).ok` and `typeof(return).error)`.

Re: Implicit conversion from 'Ok' to 'Result' type when returning functions

2017-05-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 21 May 2017 at 09:29:40 UTC, David Zhang wrote: On Sunday, 21 May 2017 at 09:15:56 UTC, Nicholas Wilson wrote: have free functions Result!(T, ErrorEnum) ok(T)(T t) { return Result(t); } Result!(T, ErrorEnum) error(T)(ErrorEnum e) { return Result(e); } then go if (!foo)

Re: Implicit conversion from 'Ok' to 'Result' type when returning functions

2017-05-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 21 May 2017 at 09:55:41 UTC, David Zhang wrote: On Sunday, 21 May 2017 at 09:37:46 UTC, Nicholas Wilson wrote: On Sunday, 21 May 2017 at 09:29:40 UTC, David Zhang wrote: Well then it becomes Result!(T, E) ok(T,E) (T t) { return Result(t); } Result!(T, E) error(T,E)(E e) {

Re: Best way for handle missing args in REST interface in vibed

2017-05-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 29 May 2017 at 12:23:59 UTC, Suliman wrote: I am doing REST interface with vibed. And thinking about handling errors, if users forgot to pass all expected args in function. For example: foo(int x, int y) // get request { } /api/foo?x=111 And if user is forgot to pass `y` we will

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 May 2017 at 08:34:54 UTC, JN wrote: One of my favourite language features of Dart (other one being factory constructors) are auto-assign constructors, for example (writing it in pseudo-D): class Person { string name; int age; this(this.age, this.name); } would translate

Re: How to check a struct exists at a particular memory address?

2017-05-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 18 May 2017 at 20:20:47 UTC, Gary Willoughby wrote: This might be a really silly question but: I've allocated some memory like this (Foo is a struct): this._data = cast(Foo*) calloc(n, Foo.sizeof); How can I then later check that there is a valid Foo at `this._data` or

Re: RAII pointers

2017-05-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 29 May 2017 at 23:39:17 UTC, Russel Winder wrote: C++ allows one to create types that are pointer types but wrap a primitive pointer to give RAII handling of resources. For example: [...] std.stdio.File does basically the same thing with C's FILE*

Re: Error: func(const(A) a) is not callable using argument types (const(A)

2017-05-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 30 May 2017 at 10:20:53 UTC, Andrew Edwards wrote: Sorry, rough day. Could someone please explain what this means and how do go about resolving it? Thanks, Andrew If you want to resolve it just do const label_size = CalcTextSize(...); but as others have mentioned make sure

Re: C macros vs D can't do the right thing

2017-06-03 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 3 June 2017 at 13:17:46 UTC, Russel Winder wrote: A stripped down problem to avoid fluff. The C macro: #define FLOB(t) (sizeof(t)) Can be used in another macro: #define THINGY(a, b) (_THING(a, FLOB(b))) We can use this as in: THINGY(10, __u32) Now the D Way says

Re: "Lazy" initialization of structs

2017-06-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 1 June 2017 at 12:04:05 UTC, Daniel Tan Fook Hao wrote: Somehow this code works for me: ```D auto error (int status, string description){ struct Error { int status; string description; } Error err = { status, description }; return

Re: How to cleanup array of structs?

2017-06-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 4 June 2017 at 12:24:44 UTC, Suliman wrote: // Will reuse the array, overwriting existing data. // If other parts of the program are using existing data // in the array, this will lead to hard-to-track-down bugs. mytracks.length = 0; mytracks.assumeSafeAppend(); Could you give an

Re: import statement placement

2017-06-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 7 June 2017 at 12:39:07 UTC, Russel Winder wrote: Are there any idiom rules as to where to put import statements in D? In Python they can go anywhere but PEP-8 suggests they should all go at the top of a file, just after the module documentation string. Well for ones that

Re: Is D slow?

2017-06-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 10 June 2017 at 12:44:07 UTC, Honey wrote: On Saturday, 10 June 2017 at 12:23:05 UTC, Nicholas Wilson wrote: On Saturday, 10 June 2017 at 12:16:34 UTC, Honey wrote: Is it expected that turning off bounds checking can lead to a performance decrease? Yes, with it on you are doing

Re: Is D slow?

2017-06-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 10 June 2017 at 14:14:53 UTC, Steven Schveighoffer wrote: I can confirm on my system, ldc with bounds check off was at least twice as slow as with just -release. Definitely seems like a bug -Steve Ya, see https://github.com/ldc-developers/ldc/issues/2161

Re: Is D slow?

2017-06-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 10 June 2017 at 12:16:34 UTC, Honey wrote: On Saturday, 10 June 2017 at 11:53:44 UTC, Johan Engelen wrote: `-release` should be synonymous with `-release -boundscheck=off`. Nope it's not.

Re: parallel foreach

2017-05-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 1 May 2017 at 12:42:01 UTC, Alex wrote: Hi all, the last foreach in the following code does not compile... Is this a bug, or is something wrong with my syntax? void main() { import std.parallelism : parallel; import std.range : iota; foreach(i;

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a simple POD struct of two float members. I can use this struct

Re: GDC options

2017-06-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 5 June 2017 at 18:22:31 UTC, Sebastien Alaiwan wrote: On Wednesday, 22 March 2017 at 13:42:21 UTC, Matthias Klumpp wrote: This is why most of my work in Meson to get D supported is adding weird hacks to translate compiler flags between GNU <-> non-GNU <-> DMD. It sucks quite badly,

Re: Advice wanted on garbage collection of sockets for c++ programmer using D

2017-06-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 27 June 2017 at 09:54:19 UTC, John Burton wrote: I'm coming from a C++ background so I'm not too used to garbage collection and it's implications. I have a function that creates a std.socket.Socket using new and connects to a tcp server, and writes some stuff to it. I then

Re: Advice wanted on garbage collection of sockets for c++ programmer using D

2017-06-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 27 June 2017 at 11:43:27 UTC, John Burton wrote: On Tuesday, 27 June 2017 at 10:14:16 UTC, Jonathan M Davis wrote: On Tuesday, June 27, 2017 09:54:19 John Burton via Digitalmars-d-learn wrote: I'm coming from a C++ background so I'm not too used to garbage collection and it's

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

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

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

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?

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

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

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

Re: Dub use local fork

2017-09-23 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",

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

Re: Need importing dcompute.lib into my project

2017-10-06 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 6 October 2017 at 18:12:43 UTC, kerdemdemir wrote: Hi, I have a cuda kernel already working in my cpp project(https://github.com/kerdemdemir/CUDABeamformer/blob/master/CudaBeamformer/kernel.cu) I am trying to convert this to D with using DCompute. I already compiled the DCompute

Re: Need importing dcompute.lib into my project

2017-10-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 7 October 2017 at 10:34:15 UTC, kerdemdemir wrote: do you set "-mdcompute-targets=cuda-xxx" in the dflags for your dub.json for your project? I have added now after your comment. But it seems it didn't changed anything. Here is the dub.json file I have: { "name":

Re: partiallyQualifiedName?

2017-10-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 17 October 2017 at 06:38:52 UTC, Biotronic wrote: If I understand things correctly, you only care about enums nested in scopes up to the module scope, right? If so, this seems to fit the bill: enum A {a} struct S { enum B {b} struct S2 { enum C {c} C c;

partiallyQualifiedName?

2017-10-16 Thread Nicholas Wilson via Digitalmars-d-learn
using fullyQualifiedName [here] (https://github.com/libmir/dcompute/blob/master/source/dcompute/driver/ocl/util.d#L120) leads to a large compilation slowdown, but I only need it to disambiguate up to the module level i.e. so that struct Context { enum Properties {} static struct Info

Re: static this not run?

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 30 September 2017 at 08:49:14 UTC, user1234 wrote: On Saturday, 30 September 2017 at 06:15:41 UTC, Nicholas Wilson wrote: No "initialising onError", the static this is not even being run! I'm using LDC master. See also https://github.com/libmir/dcompute/issues/32 LDC 1.4, DMD

generating @property from structs

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
struct MyType { void* ptr; static struct Info { @(42) int foo; } // Should be generated by the mixin below @property int foo() { int ret; getMyTypeInfo(ptr,42,int.sizeof,); return ret; } mixin generateInfo!getMyTypeInfo; }

static this not run?

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
I want a module level initialised delegate. if I try module foo; enum Status { success, } class StatusException : Exception { Status s; // usual exception constructors } void delegate(Status) onError = (Status s) { throw new StatusException(s);}; I get a error like cannot

[Template] Mixins and foreach

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
struct MyType { void* raw; static struct Info { @(42) int foo; } mixin generateGetInfo!MyTypeGetInfo; } extern(C) void MyTypeGetInfo(void*,int,size_t,void*size_t*); mixin template generateGetInfo(alias func) { foreach(field; typeof(this).Info.tupleof) {

Re: [Template] Mixins and foreach

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 1 October 2017 at 01:05:56 UTC, Nicholas Wilson wrote: struct MyType { void* raw; static struct Info { @(42) int foo; } mixin generateGetInfo!MyTypeGetInfo; } extern(C) void MyTypeGetInfo(void*,int,size_t,void*size_t*); mixin template generateGetInfo(alias

Re: [Template] Mixins and foreach

2017-10-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 1 October 2017 at 06:27:21 UTC, Nicholas Wilson wrote: And am getting util.d(72,12): Error: template instance helper!(foo) cannot use local 'foo' as parameter to non-global template helper(Fields...) Fixed by making helper a global template. Thanks Jonathan!

mtaching types with static if

2017-10-01 Thread Nicholas Wilson via Digitalmars-d-learn
struct ArrayAccesssor(alias ptr, alias len) {} char * p; size_t len; ArrayAccesssor!(p,len) aa; template helper(Fields...) { static if (Fields.length == 0) enum helper = ""; else static if (is(typeof(Fields[0]) : ArrayAccesssor!(ptr,len),ptr, len)) //13 {

Re: mtaching types with static if

2017-10-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 1 October 2017 at 07:21:57 UTC, ag0aep6g wrote: else static if (is(typeof(Fields[0]) : ArrayAccesssor!(ptr,len), alias ptr, alias len)) Ah, so close. Thanks!

Re: [Template] Mixins and foreach

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 1 October 2017 at 02:29:57 UTC, Jonathan M Davis wrote: I would have thought that it would be pretty straightforward to just write a recursive, eponymous template to solve the problem and have it recursively build a single string to mix in for everything. In general though,

Re: [Template] Mixins and foreach

2017-10-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 1 October 2017 at 04:44:16 UTC, Jonathan M Davis wrote: I don't see any reason why the compiler would be complaining about 'this' being required. Neither do I. I would think that that would imply that the compiler thinks that you're accessing the member rather than introspecting

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

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;

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

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

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

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

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 = ...;

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

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

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: 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] ~=

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

hijack dub test

2017-08-31 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

Re: Need importing dcompute.lib into my project

2017-10-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 7 October 2017 at 09:04:26 UTC, kerdemdemir wrote: You should add DCompute as a DUB dependancy. Hi, I inited my project with Dub by unsing "dub init DSharpEar" and I added dependency "dcompute". Even I give extra parameters for using ldc. dub build

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

2017-10-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 23 October 2017 at 12:41:09 UTC, Márcio Martins wrote: What is everyone doing to get proper file name and line number info for callstacks with DMD? addr2line just gives me ??:0 What OS, etc?

Re: LDC Intrinsics

2017-11-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 10 November 2017 at 09:33:17 UTC, Nordlöw wrote: What kinds of intrinsics are explicitly available to the developer when compiling with LDC? And are there any docs? there are some pragmas for bitop stuff. https://github.com/ldc-developers/ldc/blob/master/gen/pragma.cpp#L59 there

Re: How to specify 64 bit architecture in dub configuration file?

2017-11-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 10 November 2017 at 08:30:39 UTC, OlaOst wrote: Using 'dub --arch=x86_64' will get you a 64 bit build, but is it possible to specify 64 bit architecture in the configuration file, so one can just type 'dub' and get a 64 bit build? "dflags" : "-m64" will work. You can probably use

Re: ESR on post-C landscape

2017-11-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 04:31:43 UTC, Laeeth Isharc wrote: He mentions D, a bit dismissively. http://esr.ibiblio.org/?p=7724=1#comment-1912717 I think that the date he mentions in that paragraph (2001) speaks a lot for his argument, i.e. completely outdated.

Re: reduce condition nesting

2017-11-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote: Hello, is there way to reduce this condition: if (c1) { foo(); } else { if (c2) { bar(); } else { if (c3) { ... } } } for instance in kotlin it can be replace with this: when { c1

Re: Passing this to void *

2017-11-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 15:07:08 UTC, Tim Hsu wrote: I am a C++ game developer and I want to give it a try. It seems "this" in Dlang is a reference instead of pointer. How can I pass it as void *? void foo(void *); class Pizza { public: this() { Pizza newone = this;

Re: betterC and noboundscheck

2017-11-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 16:57:10 UTC, Joakim wrote: On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: [...] betterC is a new feature that's still being worked on and still has holes in it: https://github.com/dlang/dmd/pull/7151 I suggest you open an issue for it on

Re: Python and D (PyD)

2017-11-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 29 November 2017 at 06:34:53 UTC, Fat_Umpalumpa wrote: Hello, I have searched these forums a bit to see if it is possible to use python libraries such as matplotlib which I have enough experience with, and wish to continue using this wonderful library within D. Maybe there are

Re: AssocArray to string is ok,but how to get the AssocArray from string? Thanks

2017-12-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 17:32:15 UTC, Frank Like wrote: Hi,everyone, who can help me,about the "AssocArray to string is ok,but how to get the AssocArray from string? ". For example: SysTime[][string] AATimes; AATimes["a1"] =[SysTime(DateTime(2017, 1, 1, 12, 33,

<    1   2   3   4   5   6   7   >