Re: Global variable type does not match previous declaration

2017-12-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 13 December 2017 at 21:39:40 UTC, Satoshi wrote: On Wednesday, 13 December 2017 at 21:38:49 UTC, Satoshi wrote: What means this error and how to solve it? object.d-mixin-1072(1112): Error: Global variable type does not match previous declaration with same mangled name:

Re: Is there anyway to access LLVM's 128 bit int type for C from LDC?

2017-12-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 14 December 2017 at 19:47:53 UTC, Jack Stouffer wrote: Clang has __int128. Is there anyway to use this with D with LDC? Not really as a plain type, although there is effort to get [u]cent working. I could have sworn that mir was using InlineIR with it for multiplication. But

Re: Is there anyway to access LLVM's 128 bit int type for C from LDC?

2017-12-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 15 December 2017 at 01:17:17 UTC, Jack Stouffer wrote: On Thursday, 14 December 2017 at 23:33:34 UTC, Nicholas Wilson wrote: On Thursday, 14 December 2017 at 19:47:53 UTC, Jack Stouffer wrote: Clang has __int128. Is there anyway to use this with D with LDC? Not really as a plain

Re: Inline assembly question

2017-11-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 12 November 2017 at 11:01:39 UTC, Dibyendu Majumdar wrote: Hi, I have recently started work on building a VM for Lua (actually a derivative of Lua) in X86-64 assembly. I am using the dynasm tool that is part of LuaJIT. I was wondering whether I could also write this in D's inline

Re: One liner alternatives for initing and pushing some values into array

2017-11-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 20 November 2017 at 08:37:32 UTC, kerdemdemir wrote: I need to init and push some values into a array something like: //DMD64 D Compiler 2.072.2 import std.stdio; import std.array; void main() { bool a = true; bool b = false; bool c = false; bool[] boolList;

Re: problem with multiwayMerge and chunkBy

2017-11-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 5 November 2017 at 22:47:10 UTC, Nicholas Wilson wrote: f.multiwayMerge.chunks(128).joiner.chunkBy!(pred).writeln; since it seems to be the iteration that stuff things up and this changes it. If that doesn't work you could try rolling your own version of chunk with `take` and a

Re: problem with multiwayMerge and chunkBy

2017-11-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 5 November 2017 at 13:32:57 UTC, Matthew Gamble wrote: On Sunday, 5 November 2017 at 03:21:06 UTC, Nicholas Wilson wrote: On Saturday, 4 November 2017 at 18:57:17 UTC, Matthew Gamble wrote: [...] It should, this looks like a bug somewhere, please file one at issues.dlang.org/ .

Re: problem with multiwayMerge and chunkBy

2017-11-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 4 November 2017 at 18:57:17 UTC, Matthew Gamble wrote: Dear most helpful and appreciated D community, I'm a non-pro academic biologist trying to code a modeler of transcription in D. I've run into a small roadblock. Any help would be greatly appreciated. I'm hoping someone can

Re: Request Assistance Calling D from C++: weird visibility issue inside struct and namespace

2017-11-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 06:34:27 UTC, Andrew Edwards wrote: I'm having a little bit of problem calling D code from C++ and would appreciate some assistance. First, given the following C++ program wich compiles, links, and runs without any problem: Try using `nm` on the C++ object to

Re: Cannot reduce an empty iterable w/o an explicit seed value

2017-11-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 9 November 2017 at 12:40:49 UTC, Vino wrote: Hi All, Request your help, when i execute the below line of code i am getting an error message as "Cannot reduce an empty iterable w/o an explicit seed value" , The below lie of code will iterate several file system and will report

Re: Cannot reduce an empty iterable w/o an explicit seed value

2017-11-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 9 November 2017 at 12:40:49 UTC, Vino wrote: Hi All, Request your help, when i execute the below line of code i am getting an error message as "Cannot reduce an empty iterable w/o an explicit seed value" , The below lie of code will iterate several file system and will report

Re: check mountpoint status and send email on timeout/failure?

2017-12-11 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 11 December 2017 at 10:50:17 UTC, biocyberman wrote: For someone using NFS or some other remote filesystems, one may have experienced many times the nasty silent hang. For example, if I run `ls /mnt/remote/nfsmount`, and the remote NFS server is down while /mnt/remote/nfsmount was

Re: Removing some of the elements from vibe.core.concurrency.Future[] futurelist

2017-10-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 28 October 2017 at 13:51:42 UTC, kerdemdemir wrote: I am trying to make non blocking web requests to a web service. vibe.core.concurrency.Future!(UserData)[] futurelist; // I will make http requests in for loop and push them to futureList foreach( elem; elemList ) { //

Re: Removing some of the elements from vibe.core.concurrency.Future[] futurelist

2017-10-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 29 October 2017 at 01:44:37 UTC, Nicholas Wilson wrote: Alternatively you could use a singly linked list and splice out elements that pass the filter predicate. I think you'd have to roll your own though. Something like https://github.com/dlang/phobos/pull/5821

Why are deprecated aliases considered equal for resolution?

2018-05-11 Thread Nicholas Wilson via Digitalmars-d-learn
- module a; struct foo {} deprecated alias bar = foo; -- module b; struct bar {}; --- module c; import a; import b; void baz(bar b) {} Error: `a.bar` at source/a.d(5,1) conflicts with `b.bar` at .b.d(2,1) I would have thought the undeprecated alias would have

Re: Efficient idiom for fastest code

2018-05-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 23 May 2018 at 02:24:08 UTC, IntegratedDimensions wrote: Many times in expensive loops one must make decisions. Decisions must be determined and the determination costs. for(int i = 0; i < N; i++) { if(decision(i)) A; else B; } the if statement costs N times the cycle

Re: Efficient idiom for fastest code

2018-05-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 23 May 2018 at 03:12:52 UTC, IntegratedDimensions wrote: I knew someone was going to say that and I forgot to say DON'T! Saying to profile when I clearly said these ARE cases where they are slow is just moronic. Please don't use default answers to arguments. This was a general

Re: Translate C/C++ patern: return a pointer

2018-05-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 24 May 2018 at 08:16:30 UTC, biocyberman wrote: Some C and C++ projects I am working on use pointers and references extensively: to pass as function arguments, and to return from a function. For function argument I would use `ref`, but for return types, I can't use `ref` and can't

Re: scope(success) lowered to try-catch ?

2018-06-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 17 June 2018 at 10:58:29 UTC, Cauterite wrote: Hello, I'm not sure whether I'm missing something obvious here, but is there a reason for scope(success) being lowered to a try-catch statement? I would have expected only scope(exit) and scope(failure) to actually interact with

Re: using wkhtmltopdf with D

2018-05-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 29 May 2018 at 01:43:17 UTC, Mike Parker wrote: In pdf.h, that CAPI macro is used in every function declaration. That means that on Windows, all of the functions have the __stdcall calling convention (which, in D, would be extern(Windows)) and the standard cdecl calling convetion

Re: using wkhtmltopdf with D

2018-05-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 29 May 2018 at 04:49:34 UTC, Nicholas Wilson wrote: On Tuesday, 29 May 2018 at 01:43:17 UTC, Mike Parker wrote: In pdf.h, that CAPI macro is used in every function declaration. That means that on Windows, all of the functions have the __stdcall calling convention (which, in D,

Re: using wkhtmltopdf with D

2018-05-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 28 May 2018 at 01:28:10 UTC, Dr.No wrote: I'm trying to use wkhtmltopdf[1] with D. I converted this header[2] with little modification using htod tool which resulted in this[3]. The libray is passed to link using: pragma(lib, "wkhtmltox.lib"); (that file is in wkhtmltopdf\lib

Re: Conditionally set nothrow: for a block of code.

2018-05-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 24 May 2018 at 18:51:31 UTC, Mike Franklin wrote: I'm trying to find a way to declare a block of code `nothrow:` when compiling with -betterC, but not `nothrow` when not compiling with -betterC. [...] Not one now but, DIP 1012 will allow this as nothrow will become a regular

Re: Debugging compile time memory usage

2018-06-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 24 June 2018 at 14:16:26 UTC, Kamil Koczurek wrote: I recently wrote a brainfuck compiler in D, which loads the BF source at compile time, performs some (simple) optimizations, translates everything to D and puts it into the source code with a mixin. I did manage to get some

Re: DerelictVorbis and string pointer

2018-06-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 24 June 2018 at 01:43:41 UTC, ANtlord wrote: On Sunday, 24 June 2018 at 01:26:48 UTC, ANtlord wrote: Actually I get it worked replacing `string filepath2` by `char[] filepath2` but filepath is string still and it works correctly. It doesn't work Vorbis is a C library, so you

Re: Empty UDA for classes not allowed?

2017-10-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 26 October 2017 at 15:09:48 UTC, bauss wrote: Why is it not allowed to have empty UDAs for classes? Let's say we have an UDA like this: struct Exclude { } Then we want to put it on a class like: @Exclude class Foo { ... } This will fail with the following error: Error: type

Re: opCast fails when this is null.

2017-10-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 28 October 2017 at 13:24:49 UTC, Mike Wey wrote: The following code runs correctly when compiled with ldc (1.4.0) but fails with an assert error when compiled with dmd (2.076 and ldc 1.2.0) ``` class A { } class B { T opCast(T)() { return this;

Re: opCast fails when this is null.

2017-10-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 28 October 2017 at 14:19:01 UTC, Nicholas Wilson wrote: As Basile mentioned, this is compiler sticking checks in behind your back. The reason it works on new LDC is because #6982 was cherry picked to LDC (1.3?) before it was merged into dmd (not sure what version, I though it was

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 29 December 2017 at 12:03:59 UTC, Mike Franklin wrote: In C#, structs can inherit from and implement interfaces. using System; interface IPrint { void Print(); } struct MyStruct : IPrint { public void Print() { Console.WriteLine(ToString()); } } public

Re: -L--demangle=dlang doesn't work

2018-01-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 6 January 2018 at 05:44:28 UTC, Venkat wrote: Why does gcc say "unknown demangling style `dlang'" ? Do I need GDC for demangling to work ? 85198AB7DE24894B5F742FBD5/libvibe-d_data.a

Re: Class instance memory overhead lower than 3 words?

2018-01-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 24 January 2018 at 21:48:21 UTC, Nordlöw wrote: Why is the memory overhead for a class instance as high as 3 words (24 bytes on 64-bit systems? I find that annoyingly much for my knowledge database application. I'm aware of extern(C++), having one word overhead, but such

Re: Class instance memory overhead lower than 3 words?

2018-01-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 24 January 2018 at 22:27:40 UTC, Nordlöw wrote: On Wednesday, 24 January 2018 at 21:47:26 UTC, H. S. Teoh wrote: On Wed, Jan 24, 2018 at 09:48:21PM +, Nordlöw via Digitalmars-d-learn wrote: Why is the memory overhead for a class instance as high as 3 words (24 bytes on 64-bit

Re: __gshared as part of alias

2018-01-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 17 January 2018 at 07:53:24 UTC, Jonathan M Davis wrote: I don't know what you're doing, and maybe __gshared is the appropriate solution for what you're trying to do, but in general, if you're not trying to bind to a C global variable, you should be using shared, and using

Re: __gshared as part of alias

2018-01-16 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 17 January 2018 at 02:37:07 UTC, Steven Schveighoffer wrote: On 1/11/18 11:25 PM, Nicholas Wilson wrote: Is there a way to make __gshared part of an alias? No, __gshared is a storage class, not a type constructor, so it has no meaning as part of a type: __gshared int x; int

Re: C++ function mangling Linux GCC

2018-01-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 18 January 2018 at 04:16:18 UTC, Laeeth Isharc wrote: Am I missing something, or should extern(C++) just work for binding to gcc C++ on Linux. It works fine for primitives but fails for pointer type arguments. Extern "C" works fine. Does D know how to mangle function names

Re: String Type Usage. String vs DString vs WString

2018-01-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 15 January 2018 at 02:05:32 UTC, Chris P wrote: Hello, I'm extremely new to D and have a quick question regarding common practice when using strings. Is usage of one type over the others encouraged? When using 'string' it appears there is a length mismatch between the string

__gshared as part of alias

2018-01-11 Thread Nicholas Wilson via Digitalmars-d-learn
Is there a way to make __gshared part of an alias? as in enum AddrSpace : uint { Private = 0, Global = 1, Shared = 2, Constant = 3, Generic = 4, } struct Variable(AddrSpace as, T) { T val; alias val this; } alias Global(T) = __gshared

Re: union/toString: crash/segfault: What's happening here?

2018-01-11 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 12 January 2018 at 00:54:03 UTC, kdevel wrote: crash.d ``` import std.stdio; union U { float f; int i; string toString () { string s; return s; } } void main () { U u; writeln (u); } ``` $ dmd crash.d $ ./crash because you don't initialise `s` in

Re: parallelism

2018-01-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 27 January 2018 at 10:28:10 UTC, Arun Chandrasekaran wrote: ``` import std.parallelism; auto pool = new TaskPool(options.threadCount); foreach (_; 0 .. options.iterationCount) { switch (options.operation) { static foreach(e; EnumMembers!Operation) {

Re: Vibe.d rest & web service?

2018-02-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 18:38:15 UTC, Seb wrote: How about using the normal Vibe.d Web Service? Stupid question: whats the difference? An example from my WIP project vibe-by-example project: https://github.com/wilzbach/vibe-d-by-example/blob/master/web/service.d I also have a

Re: Vibe.d rest & web service?

2018-02-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 17:57:09 UTC, Jesse Phillips wrote: On Wednesday, 7 February 2018 at 17:04:13 UTC, Nicholas Wilson wrote: Is it possible to have some urls routed to serve content and some to receive JSON in the same class? This seems unlikely to me, the function signature

Debugging bad requests with vibe

2018-02-08 Thread Nicholas Wilson via Digitalmars-d-learn
I have set up a vibe.d rest interface (on a server) and have a client on my machine. struct Observation { string desc; DateTime time; } interface Obsever { @property void observe(Observation ra); } void main() { auto test = Observation("a duck",

Re: Debugging bad requests with vibe

2018-02-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote: I have set up a vibe.d rest interface (on a server) and have a client on my machine. struct Observation { string desc; DateTime time; } interface Obsever { @property void observe(Observation ra); } void main() {

Re: Vibe.d rest & web service?

2018-02-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 18:47:05 UTC, Steven Schveighoffer wrote: Yes you can, but it's not pretty. interface MyInterface { void postGiveMeData(SomeData d); } class MyInterfaceImpl : MyInterface { void postGiveMeData(SomeData d) { ... } void getPage() { ... } void index()

Re: Vibe.d rest & web service?

2018-02-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 19:50:31 UTC, Jacob Carlborg wrote: Have you tried this? No. But apart from the fact that I forgot to make the class inherit from an interface to that the rest interface would actually compile, the web interface is routed before the rest interface and so the

Re: Debugging bad requests with vibe

2018-02-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote: On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote: Is there a way I can see/log what requests are being made? I can change both the client and server. -v and -vv So it turns out that structs do not work as parameters

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 9 February 2018 at 15:50:24 UTC, Ralph Doncaster wrote: On Friday, 9 February 2018 at 15:24:27 UTC, Mike Parker wrote: On Friday, 9 February 2018 at 15:05:33 UTC, Ralph Doncaster wrote: This seems odd to me. Is there a way I can make a function that takes an array of any type but

Re: dpq2: spurious error message

2018-02-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 13 February 2018 at 17:08:24 UTC, Nicholas Wilson wrote: Is this a problem with the library or me? Can I work around it? How? Thanks Nic So digging around in the library code, commenting it out seems to work for now as I don't use UUIDs. Error didn't originate from my code

dpq2: spurious error message

2018-02-13 Thread Nicholas Wilson via Digitalmars-d-learn
import vibe.vibe; import vibe.db.postgresql; QueryParams p; p.sqlCommand = "select title,url,url_title,messagebody,generationtime from items order by generationtime;"; auto _items = conn.execParams(p); struct Range { immutable Answer a; size_t i; immutable(Row) front() {

Re: dpq2: spurious error message

2018-02-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 13 February 2018 at 17:17:41 UTC, Nicholas Wilson wrote: On Tuesday, 13 February 2018 at 17:08:24 UTC, Nicholas Wilson wrote: Is this a problem with the library or me? Can I work around it? How? Thanks Nic So digging around in the library code, commenting it out seems to work

vib.d suppress 404 for no content written

2018-02-14 Thread Nicholas Wilson via Digitalmars-d-learn
I have an endpoint that is a post: void postStuff(HTTPServerRequest req, HTTPServerResponse res) { // do some stuff with req res.statusCode = 200; } I do not write anything to res (deliberately) but want to set the status code. However it returns 404, because no content is written.

Re: vib.d suppress 404 for no content written

2018-02-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 14 February 2018 at 14:58:14 UTC, Seb wrote: On Wednesday, 14 February 2018 at 14:30:19 UTC, Nicholas Wilson wrote: I have an endpoint that is a post: void postStuff(HTTPServerRequest req, HTTPServerResponse res) { // do some stuff with req res.statusCode = 200; } I do

Re: opDispatch with string mixin does not work as I would expect.

2018-02-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 10 February 2018 at 06:32:43 UTC, German Diago wrote: Hello everyone, I am trying to forward some member functions from a struct as a Catch-all function, so I did something like this: struct A { struct HeaderData { align(1): char [21] id;

Re: Debugging bad requests with vibe

2018-02-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote: On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote: Is there a way I can see/log what requests are being made? I can change both the client and server. -v and -vv All that gives me is a bunch of [FAC3BFF6:FAC451F6 dia]

Re: Debugging bad requests with vibe

2018-02-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 8 February 2018 at 20:24:19 UTC, Nicholas Wilson wrote: On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote: I have set up a vibe.d rest interface (on a server) and have a client on my machine. struct Observation { string desc; DateTime time; } interface

Re: Vibe.d rest & web service?

2018-02-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 8 February 2018 at 10:51:39 UTC, Arjan wrote: On Wednesday, 7 February 2018 at 20:23:10 UTC, Nicholas Wilson wrote: On Wednesday, 7 February 2018 at 19:50:31 UTC, Jacob Carlborg wrote: Have you tried this? No. But apart from the fact that I forgot to make the class inherit from

Vibe.d rest & web service?

2018-02-07 Thread Nicholas Wilson via Digitalmars-d-learn
Is it possible to have some urls routed to serve content and some to receive JSON in the same class? Basically I want: shared static this() { auto router = new URLRouter; auto a = new MyInterface; router.registerWebInterface(new MyInterface); //?? selective combination

Re: ubyte[4] to int

2018-02-15 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 15 February 2018 at 16:51:05 UTC, Kyle wrote: Hi. Is there a convenient way to convert a ubyte[4] into a signed int? I'm having trouble handling the static arrays returned by std.bitmanip.nativeToLittleEndian. Is there some magic sauce to make the static arrays into input ranges

Re: Manually allocating a File

2018-02-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 20 February 2018 at 15:32:45 UTC, Chris M. wrote: Thanks for the info, that clears things up. Like I said, it was more experimentation rather than me planning to actually use it. Works now with the following modifications. import std.stdio; import core.stdc.stdlib; import

Re: Negative index range violation

2018-02-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 22 February 2018 at 00:13:43 UTC, SrMordred wrote: string x = "123"; auto c = x.ptr; c++; writeln(c[-1]); // 1 writeln(c[-1..0]); //BOOM Range violation Can I do this / Bug / some mistake ? youd have to do (c-1)[0 .. 1];

Re: multithread/concurrency/parallel methods and performance

2018-02-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 18 February 2018 at 17:54:58 UTC, SrMordred wrote: I´m experimenting with threads and related recently. (i´m just started so may be some terrrible mistakes here) With this base work: foreach(i ; 0 .. SIZE) { results[i] = values1[i] * values2[i]; } and then with this 3 others

Re: std.array.array for immutable data types

2018-02-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 19 February 2018 at 07:08:49 UTC, Fra Mecca wrote: Is there a way to avoid using to! conversion here? immutable string[] dst = to!(immutable string[])(array(pipe.readEnd.byLineCopy)); assumeUnique. immutable string[] dst = pipe.readEnd.byLineCopy.array.assumeUnique;

Re: Is this an okay representation of a dynamically sized Matrix, to be used for HMM matrices m = (A,B)

2017-12-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 28 December 2017 at 01:34:10 UTC, Enjoys Math wrote: Code: module matrix; import std.array; struct Matrix(E) { private: E[][]; this() { } void deleteRow(int i) { E = E[0..i] ~ E[i..$]; } void deleteColumn(int j) { for (int i=0; i <

Re: std way to remove multiple indices from an array at once

2017-12-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 21 December 2017 at 00:23:08 UTC, Steven Schveighoffer wrote: On 12/20/17 6:01 PM, aliak wrote: Hi, is there a way to remove a number of elements from an array by a range of indices in the standard library somewhere? I wrote one (code below), but I'm wondering if there's a

Re: Function in a slice instead of just pointer?

2018-06-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 21 June 2018 at 21:00:46 UTC, Michael Brown wrote: Hi D Community, Is it possible to get a slice of a function, rather than just its start pointer? No. I'm interested in currying a function at runtime - So I would need to copy a function block (Either the original function,

Linking to dynamic druntime with dub

2018-07-31 Thread Nicholas Wilson via Digitalmars-d-learn
My application needs to load shared libraries: on Posix this is only supported with a shared druntime. How does one link to the dynamic druntime with dub?

Re: Linking to dynamic druntime with dub

2018-07-31 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 31 July 2018 at 13:52:21 UTC, rikki cattermole wrote: On 01/08/2018 1:43 AM, Nicholas Wilson wrote: My application needs to load shared libraries: on Posix this is only supported with a shared druntime. How does one link to the dynamic druntime with dub? The same way you do it

Re: Linking to dynamic druntime with dub

2018-07-31 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 31 July 2018 at 14:27:18 UTC, rikki cattermole wrote: On 01/08/2018 2:18 AM, Nicholas Wilson wrote: On Tuesday, 31 July 2018 at 13:52:21 UTC, rikki cattermole wrote: On 01/08/2018 1:43 AM, Nicholas Wilson wrote: My application needs to load shared libraries: on Posix this is only

Re: Compiler build error

2018-08-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 4 August 2018 at 18:12:05 UTC, Alex wrote: On Saturday, 4 August 2018 at 13:26:01 UTC, Nicholas Wilson wrote: 0 ldc2 0x000106fcc4e7 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37 1 ldc2 0x000106fcb9ea

Re: Compiler build error

2018-08-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 4 August 2018 at 12:21:36 UTC, Alex wrote: I'm a little bit confused by following situation: I have code, say around 8000 lines. Now, I'm facing a build error which just says dmd failed with exit code -11, (same for ldc2, with some lines of stack information, which do not

Re: Compiler build error

2018-08-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 5 August 2018 at 10:12:39 UTC, Alex wrote: On Sunday, 5 August 2018 at 01:15:07 UTC, Nicholas Wilson wrote: On Saturday, 4 August 2018 at 18:12:05 UTC, Alex wrote: On Saturday, 4 August 2018 at 13:26:01 UTC, Nicholas Wilson That is a very long stacks trace and combined with the very

Re: pointer cast from const(Y) to immutable(void*)** is not supported at compile time

2018-08-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 1 August 2018 at 20:10:44 UTC, Hakan Aras wrote: On Wednesday, 1 August 2018 at 16:25:28 UTC, Hakan Aras wrote: https://run.dlang.io/is/dSVruv Whoops, that was the wrong one. It's fixed now. https://issues.dlang.org/show_bug.cgi?id=19134 As a workaround remove static, as

Re: pointer cast from const(Y) to immutable(void*)** is not supported at compile time

2018-08-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 2 August 2018 at 02:13:41 UTC, Hakan Aras wrote: On Thursday, 2 August 2018 at 01:39:58 UTC, Nicholas Wilson wrote: https://issues.dlang.org/show_bug.cgi?id=19134 I wasn't quite sure whether it's a bug since it happens in both compilers. Thanks for opening the issue. For

Re: countUntil's constraints

2018-08-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 8 August 2018 at 01:33:26 UTC, Steven Schveighoffer wrote: On 8/7/18 9:20 PM, Nicholas Wilson wrote: the first overload is ptrdiff_t countUntil(alias pred = "a == b", R, Rs...)(R haystack, Rs needles) if (isForwardRange!R && Rs.length > 0 && isForwardRange!(Rs[0]) ==

countUntil's constraints

2018-08-07 Thread Nicholas Wilson via Digitalmars-d-learn
the first overload is ptrdiff_t countUntil(alias pred = "a == b", R, Rs...)(R haystack, Rs needles) if (isForwardRange!R && Rs.length > 0 && isForwardRange!(Rs[0]) == isInputRange!(Rs[0]) && is(typeof(startsWith!pred(haystack, needles[0]))) && (Rs.length == 1 ||

Re: countUntil's constraints

2018-08-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 8 August 2018 at 01:33:26 UTC, Steven Schveighoffer wrote: On 8/7/18 9:20 PM, Nicholas Wilson wrote: the first overload is ptrdiff_t countUntil(alias pred = "a == b", R, Rs...)(R haystack, Rs needles) if (isForwardRange!R && Rs.length > 0 && isForwardRange!(Rs[0]) ==

Re: is this a betterC bug ?

2018-08-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 14 August 2018 at 13:01:57 UTC, learnfirst1 wrote: enum string[] a = ["a"]; extern(C) void main() { int i = 0; auto s = a[i]; } --- Error: TypeInfo cannot be used with -betterC Yes. https://issues.dlang.org/show_bug.cgi?id=19169

Re: is this a betterC bug ?

2018-08-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 14 August 2018 at 13:16:50 UTC, Nicholas Wilson wrote: On Tuesday, 14 August 2018 at 13:01:57 UTC, learnfirst1 wrote: enum string[] a = ["a"]; extern(C) void main() { int i = 0; auto s = a[i]; } --- Error: TypeInfo cannot be used with -betterC Yes.

Re: unimplemented abstract function compiles.

2018-08-11 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 11 August 2018 at 23:12:43 UTC, ag0aep6g wrote: On 08/11/2018 11:20 PM, rikki cattermole wrote: On 12/08/2018 8:55 AM, Eric wrote: Code below compiles while I would not expect it to compile. Is there a reason that this compiles? [...] No bug. You forgot to throw -unittest when

Re: Generically call a function on Variant's payload?

2018-08-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 20 August 2018 at 00:27:04 UTC, Nick Sabalausky (Abscissa) wrote: Suppose I've wrapped a Variant in a struct/class which ensures the Variant *only* ever contains types which satisfy a particular constraint (for example: isInputRange, or hasLength, etc...). Is there a way to call a

Re: Can passing an address of this to a non-copyable object be made trusted? - i.e. can I disable moving?

2018-08-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 26 August 2018 at 20:17:30 UTC, aliak wrote: So if we had this: struct A(T) { auto proxy() @trusted { return B!T(); } } struct B(T) { private A!T* source; private this(A!T* s) { source = s; } @disable this(); @disable this(this) {} @disable void opAssign(B!T); }

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

HMAC and toHexString

2018-07-17 Thread Nicholas Wilson via Digitalmars-d-learn
... string key = "blahblahblah"; auto mac = hmac!SHA256(key.representation); string s = ...,t=...u=...,v=...; foreach(w;AliasSeq!(s,t,u,v)) mac.put(w.representation); ubyte[32] s = mac.finish; string sig = toHexString!(LetterCase.lower)(s); writeln(sig); // From what I understand

Re: HMAC and toHexString

2018-07-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 18 July 2018 at 05:54:48 UTC, Nicholas Wilson wrote: ... string key = "blahblahblah"; auto mac = hmac!SHA256(key.representation); string s = ...,t=...u=...,v=...; foreach(w;AliasSeq!(s,t,u,v)) mac.put(w.representation); ubyte[32] s = mac.finish; string sig =

Re: HMAC and toHexString

2018-07-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 18 July 2018 at 11:29:42 UTC, baz@dlang-community wrote: On Wednesday, 18 July 2018 at 11:22:36 UTC, Nicholas Wilson wrote: On Wednesday, 18 July 2018 at 05:54:48 UTC, Nicholas Wilson wrote: [...] Ahh, the joys of memory corruption. You've reached

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

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

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: Inference of auto storage classes for interface function return type

2018-07-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 4 July 2018 at 14:07:35 UTC, Timoses wrote: How can I return inferred storage class from interface functions? I can't use auto as return value in interface. Neither can I use "inout" as I don't pass a parameter. // Ref Type interface IRef {

Re: function template specialization question D vs. C++

2018-01-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 14 January 2018 at 00:09:42 UTC, kdevel wrote: fusp.d ``` import std.stdio; import std.typecons; void foo (T) () { writeln ("(1) foo T = ", T.stringof); } void foo (T : float) () { writeln ("(2) foo T = ", T.stringof); } // void foo (T : double) () // { //writeln ("(2)

Re: Can't "is null" an interface?!?! Incompatible types???

2018-03-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 8 March 2018 at 04:48:08 UTC, Nick Sabalausky (Abscissa) wrote: - import vibe.core.net; TCPConnection mySocket; void main() { auto b = mySocket is null; } - That's giving me: - Error: incompatible types for

Re: How give a module to a CTFE function

2018-03-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 12 March 2018 at 22:24:15 UTC, Xavier Bigand wrote: mixin(implementFunctionsOf("derelict.opengl3.functions")); As string I get the following error: ..\src\api_entry.d(16): Error: variable `mod` cannot be read at compile time ..\src\api_entry.d(48):called from here:

Re: complex arithmetic in D: multiple questions

2018-03-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 9 March 2018 at 12:34:40 UTC, J-S Caux wrote: Please bear with me, this is a long question! To explain, I'm a scientist considering switching from C++ to D, but before I do, I need to ensure that I can: - achieve execution speeds comparable to C++ (for the same accuracy; I can

Re: complex arithmetic in D: multiple questions

2018-03-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 9 March 2018 at 14:41:47 UTC, J-S Caux wrote: Is this a case for a bug report? Seems pretty bizarre to do that, like an oversight/neglect. Yes if there's not one there for it already. OK thanks. I looked at libmir, and saw many good things there. I was wondering: is it still

Re: Passing directory as compiler argument not finding file

2018-04-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 12 April 2018 at 07:48:28 UTC, Jamie wrote: On Thursday, 12 April 2018 at 06:30:25 UTC, Tony wrote: On Thursday, 12 April 2018 at 05:39:21 UTC, Jamie wrote: Am I using the -I compiler option incorrectly? I believe so. I think it is for finding import files, not the files you

Re: Is using function() in templates possible at all?

2018-04-11 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 11 April 2018 at 22:13:33 UTC, Sjoerd Nijboer wrote: On Wednesday, 11 April 2018 at 21:29:27 UTC, Alex wrote: I would say, alias template parameter is your friend. https://dlang.org/spec/template.html#TemplateAliasParameter class SortedList(T, alias comparer) It works, thank

Re: Passing directory as compiler argument not finding file

2018-04-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 12 April 2018 at 06:22:30 UTC, Nicholas Wilson wrote: On Thursday, 12 April 2018 at 05:39:21 UTC, Jamie wrote: Am I using the -I compiler option incorrectly? is it thinking /../A is an absolute path? try -I=./../A Er, scratch that. I see you already tried it.

Re: Passing directory as compiler argument not finding file

2018-04-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 12 April 2018 at 05:39:21 UTC, Jamie wrote: With a directory structure as follows: run/ A/ a.d Where a.d is: === module A.d; I'm attempting to compile from the run/ directory. If I run with dmd ../A/a.d it compiles successfully, however if I

<    1   2   3   4   5   6   7   >