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

Template substitution for function parameters

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

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

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: 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: 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: 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: 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: Real naive template question

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

Re: 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: 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: Question on SSE intrinsics

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

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

std.meta.Replace using index

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

Re: using DCompute

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

Re: using DCompute

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

Re: Cast to subclass in the dmd compiler

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

Re: find difference between two struct instances.

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

Re: module convicts with package

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

module convicts with package

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

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

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

Re: Idiomatic way of writing nested loops?

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

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

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

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

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

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

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

Re: nogc string concatenation?

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

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

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

Re: Function with static array as parameter

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

Re: Finding source of typeid use

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

Re: Finding source of typeid use

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

Re: Finding source of typeid use

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

Finding source of typeid use

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

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.

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: 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: D and .lib files. C++/Other?

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

Re: std.string.format call from varyargs

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

Re: D, Game Development, GLSL, Math

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

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

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

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: 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: 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: 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: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 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: 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: 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: 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: 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: 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: 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: Rosetta Commatizing numbers

2017-05-30 Thread Jordan Wilson via Digitalmars-d-learn
On Tuesday, 30 May 2017 at 10:54:49 UTC, Solomon E wrote: The earlier version of the page made D look more error prone than other languages, but short. Now my solution is as long as some of the other language's solutions, but it's well commented and tested, I think. Now I doubt any of the

Re: howto count lines - fast

2017-05-30 Thread Jordan Wilson via Digitalmars-d-learn
On Tuesday, 30 May 2017 at 20:37:44 UTC, Jordan Wilson wrote: On Tuesday, 30 May 2017 at 20:02:38 UTC, Nitram wrote: After reading https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ , i was wondering how fast one can do a simple "wc -l" in D. So i made a couple short

Re: howto count lines - fast

2017-05-30 Thread Jordan Wilson via Digitalmars-d-learn
On Tuesday, 30 May 2017 at 20:02:38 UTC, Nitram wrote: After reading https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ , i was wondering how fast one can do a simple "wc -l" in D. So i made a couple short implementations and found myself confronted with slow results compared

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: 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: 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: 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: Out of memory error (even when using destroy())

2017-05-26 Thread Jordan Wilson via Digitalmars-d-learn
On Friday, 26 May 2017 at 06:31:49 UTC, realhet wrote: Hi, I'm kinda new to the D language and I love it already. :D So far I haven't got any serious problems but this one seems like beyond me. import std.stdio; void main(){ foreach(i; 0..2000){ writeln(i); auto st = new

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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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 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: 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: 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: How to avoid throwing an exceptions for a built-in function?

2017-05-11 Thread Jordan Wilson via Digitalmars-d-learn
On Thursday, 11 May 2017 at 18:07:47 UTC, H. S. Teoh wrote: On Thu, May 11, 2017 at 05:55:03PM +, k-five via Digitalmars-d-learn wrote: On Thursday, 11 May 2017 at 17:18:37 UTC, crimaniak wrote: > On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote:

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: 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++ 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: Recently added __equal

2017-04-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 17 April 2017 at 19:15:06 UTC, Nordlöw wrote: What's the plan for the recent adding __equal overloads at https://github.com/dlang/druntime/pull/1808/files Is it only meant for runtime and phobos to be updated? Or does user-libraries, such as container libraries, need to be updated

Re: check Input

2017-04-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 17 April 2017 at 11:51:45 UTC, dennis wrote: Hi, try to build a little programm, but need to know how to check the input. For example: input only numbers: 0 - 9 but 1.5 for example is ok. thanks I will point you to Ali's book (free), it goes through the basics of input and

Re: Compilation problems with GDC/GCC

2017-04-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 14 April 2017 at 11:32:57 UTC, DRex wrote: I have project which involves both C and D code. For reasons that are much too long to explain, I have to use GCC to compile the C code into object files (GDC to compile the D code into object files) and then ld to link all the object

<    1   2   3   4   5   6   7   >