Re: mixin templates as ailas paramters

2016-11-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 25 November 2016 at 01:08:38 UTC, ketmar wrote: On Friday, 25 November 2016 at 00:43:25 UTC, Nicholas Wilson wrote: works like a charm: mixin template Foo(T) { int z = 42; } auto Bar(alias a) () { mixin a!int; return z; } void main () { writeln(Bar!Foo); } Hmm, maybe i

mixin templates as ailas paramters

2016-11-24 Thread Nicholas Wilson via Digitalmars-d-learn
Is there any reason why mixin template Foo(T) { } Struct Bar(ailas a) { mixin a!int } doesn't work? It gives an error saying that mixin templates are not normal templates. I hacked around this by making Bar take an enumeration and then "static switch"ing on it to select the correct

Re: Get return type of a template function without instantiating it

2016-11-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 12:21:18 UTC, Yuxuan Shui wrote: Is there a way to get a template function return type with instantiating it? The return type is independent of the template arguments. I'm asking because there's potentially recursive template instantiation if I do try to

Re: Memory allocation failed. Why?

2016-11-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 20 November 2016 at 18:58:04 UTC, Basile B. wrote: On Sunday, 20 November 2016 at 17:47:50 UTC, MGW wrote: [...] For me there's no exception. Maybe the GC is poluted. Try to add this after each iteration in the first test loop: import core.memory: GC;

Re: How to declare function with the same call signature as another?

2016-11-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 20 November 2016 at 11:19:24 UTC, Tofu Ninja wrote: I feel like this should be simple but I can't seem to figure it out. How do I declare a function to have the same call signature as another function/callable type? Like if I have: alias Sig = int function(int x, int y); How do I

Re: How to declare function with the same call signature as another?

2016-11-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 20 November 2016 at 11:19:24 UTC, Tofu Ninja wrote: I feel like this should be simple but I can't seem to figure it out. How do I declare a function to have the same call signature as another function/callable type? Like if I have: alias Sig = int function(int x, int y); How do I

Re: what is mean? ( Offset 78887H Record Type 00C3)

2016-11-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 19 November 2016 at 06:54:37 UTC, xky wrote: hello. i got a problem when i build my source code(windows7 x64 / DMD32 D Compiler v2.072.0), here: OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars

Re: typeof(SortedRange) and is operator

2016-11-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 8 November 2016 at 13:22:35 UTC, RazvanN wrote: Sorry, I accidentally posted the above message and I don't know how to erase it. You can't, this is a mailing list not a forum. The following post is the complete one: Given the following code: int[] arr = [1, 2, 9, 4, 10, 6];

Re: system's "kill " signal

2016-11-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 5 November 2016 at 02:24:00 UTC, Konstantin Kutsevalov wrote: Hi, is there a way to catch system signal of "kill" command or "shutdown"? PS: are there some other ways also to send signals to running a D application? have a look in std.process I don't think you can catch

dub build --force but only for this package

2016-10-28 Thread Nicholas Wilson via Digitalmars-d-learn
So I'm trying to debug a project with the work flow of ssh into remote box edit/compile/run if it hangs yank the power out repeat this appears to corrupt the the last modification time to some time in the future and leads to the warning File

Re: [vibe.d] showing images

2016-10-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 18:39:00 UTC, Rene Zwanenburg wrote: On Wednesday, 26 October 2016 at 12:42:09 UTC, Nicholas Wilson wrote: [...] You need to make the images accessible over HTTP. Note the use of staticFileServer in the following example: http://vibed.org/docs#http-routing

Re: [vibe.d] showing images

2016-10-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 12:57:24 UTC, wobbles wrote: On Wednesday, 26 October 2016 at 12:42:09 UTC, Nicholas Wilson wrote: [...] When you get the 404, do you see the contents of 'writeln(images);' in your terminal? yes. the 404 is only for the image the page still renders fine,

[vibe.d] showing images

2016-10-26 Thread Nicholas Wilson via Digitalmars-d-learn
doctype html html body -foreach(s; images) // it doesn't seem to like #{s} or !{s} img(src=s) -- shared static this() { auto router = new URLRouter; router.registerWebInterface(new CamController); auto settings = new HTTPServerSettings;

Re: Should I brush up on my C before plunging fully into D?

2016-10-15 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 15 October 2016 at 01:46:52 UTC, Chris Nelson wrote: I'm mainly a scripting language, .NET, and SQL programmer. I've been looking for a good programming language for Linux/BSD other than Python. I've surveyed the options and D appears to be a sane modern choice for me. (Thanks Ali

Re: How to create dynamically sized objects

2016-09-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 29 September 2016 at 07:10:44 UTC, Straivers wrote: Hi, Say I wanted to create an object that has a string member, and I want the string to be allocated with the object contiguously instead of as a pointer to another location (as a constructor would do). For example: class C {

Re: how to access struct member using [] operator?

2016-09-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 25 September 2016 at 04:54:31 UTC, grampus wrote: Dear all For example, I have a struct struct point{int x;int y} point a; Is there an easy way to access x and y by using a["x"] and a["y"] I guess I need to overload [], but can't figure out how. Someone can help? Thank you very

Re: D and math, can you isolate this ?

2016-09-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 08:21:29 UTC, Basile B. wrote: On Wednesday, 21 September 2016 at 01:34:06 UTC, Nicholas Wilson wrote: On Tuesday, 20 September 2016 at 12:35:18 UTC, Basile B. wrote: [...] So if we rearrange and take the logs of both sides and divide by c we get

Re: D and math, can you isolate this ?

2016-09-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 12:35:18 UTC, Basile B. wrote: I've recently started an easing/interpolation family of function in my D user library. It's based on something I know well since I've already used them in 2012 in a VST plugin called GrainPlot (RIP). However for one of the

Re: construct range from tuple?

2016-09-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 18 September 2016 at 08:06:54 UTC, Lutger wrote: I have a tuple of strings generated at compile time, for example: alias names = AliasSeq!("Alice", "Bob"); How is it possible to construct a range of strings from this, in order to use it at runtime with other range algorithms?

Re: Binary heap: obtain a _reference_ to the front of the heap

2016-09-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 13 September 2016 at 08:19:04 UTC, Johan Engelen wrote: In the binary heap documentation, I read that `BinaryHeap.front()` "Returns a copy of the front of the heap". [1] Is there no function to access the front of the heap without a copy? (micro-optimization) Thanks, Johan

Re: Using OpenGL

2016-09-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 3 September 2016 at 17:13:49 UTC, Darren wrote: On Saturday, 3 September 2016 at 16:07:52 UTC, Mike Parker wrote: [...] The dynamic array! Thank you so much, I changed that on another file and it finally drew the triangle. And I ran your code and it works brilliantly. I

Re: Keen to learn D

2016-09-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 4 September 2016 at 20:12:09 UTC, Abhishek Mishra wrote: Hi! I am a newbie and I would like to know more about D language. I have prior knowledge of C++(12th Grade/ Pre-University College Level). How should I start? What more do I need to learn. Thanks in advance. :) in addition

Re: Equivalent of FirstOrDefault with ranges

2016-09-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 2 September 2016 at 06:56:07 UTC, Lutger wrote: I was looking for something like FirstOrDefault* from .NET in phobos. For example, I have this piece of code: string findBobOrReturnNull(string[] names) { auto r = names.find("bob"); if(r.empty) return null; return r.front;

Re: How to call a method of class D from function of C++ in DLL?

2016-08-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 28 August 2016 at 08:20:52 UTC, MGW wrote: On Saturday, 27 August 2016 at 07:13:01 UTC, Nicholas Wilson wrote: easiest method would be to mark the D class extern(C++) noting that in C++ a D class reference becomes a pointer to the C++ class. In "the D class extern(C++)" do't work

Re: How to call a method of class D from function of C++ in DLL?

2016-08-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 27 August 2016 at 04:44:10 UTC, MGW wrote: Method which I use now: source D: - extern (C) { int on_metFromD(CEditWin* uk, int aa, int bb) { return (*uk).metFromD(int aa, int bb); } } class CEditWin { . . . // Method for to call int metFromD(int

Re: Metaprogramming, generate argument list.

2016-08-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 22 August 2016 at 22:01:51 UTC, ciechowoj wrote: Is it possible to generate an argument list that contains pointers to local variables at compile time? For example, consider following code: template Repeat(alias int N, alias variable) { // Magic alias Repeat = /* Even more

Re: Best way of checking for a templated function instantiation

2016-08-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 10 August 2016 at 12:36:14 UTC, Arafel wrote: Hi, I'm trying to check at compilation time if a given type implements some operator (let's assume it's '+' in this case), without caring about the type of the parameters it accepts. Since operator overloading is expressed in D

Re: Replace (ie: substitute) a type in varadic args

2016-08-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 08:22:15 UTC, Saurabh Das wrote: On Tuesday, 2 August 2016 at 08:20:22 UTC, Saurabh Das wrote: On Tuesday, 2 August 2016 at 08:16:48 UTC, Sean Campbell wrote: [...] Thanks. Yes that is one approach. I figured out another approach that seems decent: auto

Re: Template Inheritance

2016-07-31 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 31 July 2016 at 03:04:27 UTC, Gorge Jingale wrote: I like to build structures using template mixins because one can pick and choose functionality at compile time, but still have a relationship between different types. It would be really nice if one could sort of test if a template

dub set default compiler for project

2016-07-25 Thread Nicholas Wilson via Digitalmars-d-learn
dub build has the --compiler= option. Is there any way to set it to default a custom version (own branch, resides in ../../ldcbuild/bin/ldc2 ) of ldc2 in the dub.json (or .sdl)? The project will only compile with that compiler.

Re: extract .manglof of template with lambda parameters

2016-07-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 24 July 2016 at 06:03:59 UTC, Nicholas Wilson wrote: so I have a main as follows int main(string[] args) { int a = 3; map!((int x) => x*x)((GlobalPointer!int()),a); return 0; } I want to get the mangleof of the generated call to map but without referencing it in the .o

Re: extract .manglof of template with lambda parameters

2016-07-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 24 July 2016 at 06:03:59 UTC, Nicholas Wilson wrote: so I have a main as follows int main(string[] args) { int a = 3; map!((int x) => x*x)((GlobalPointer!int()),a); return 0; } I want to get the mangleof of the generated call to map but without referencing it in the .o

extract .manglof of template with lambda parameters

2016-07-24 Thread Nicholas Wilson via Digitalmars-d-learn
so I have a main as follows int main(string[] args) { int a = 3; map!((int x) => x*x)((GlobalPointer!int()),a); return 0; } I want to get the mangleof of the generated call to map but without referencing it in the .o and then pass the mangleof to another function. the call to map

Re: Is there a way to "see" source code generated by templates after a compile?

2016-07-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 17 July 2016 at 16:30:38 UTC, Stefan Koch wrote: On Sunday, 17 July 2016 at 14:54:34 UTC, zabruk70 wrote: On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote: If you want to see template expansions you have to wait a little longer. Wow! Is this really possible?! So long

Re: Fast MSB to LSB

2016-07-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 18 July 2016 at 04:54:07 UTC, Rufus Smith wrote: Is there any MSB to LSB and vice versa in phobos? Or some tricks with templates that make it fast as possible? you mean endianness conversions? then yes. see std.bitmanip:swapendian and friends.

Re: Is logical subsetting of an array possible ?

2016-07-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 14 July 2016 at 10:51:33 UTC, Nicholas Wilson wrote: On Thursday, 14 July 2016 at 10:43:12 UTC, Sahil wrote: (I am totally new to D) easily. The function you are looking for is called 'filter' import std.algorithm; import std.array; int[] a = [ 4,5,8,1,3,2,9,10]; auto b =

Re: Is logical subsetting of an array possible ?

2016-07-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 14 July 2016 at 10:43:12 UTC, Sahil wrote: This is with reference to documentation about use of array in D (https://dlang.org/spec/arrays.html#array-setting). In languages tailor-made for data mining, like R, a subset of an array (not necessarily contiguous values) can be

Re: Second class pointers

2016-07-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 8 July 2016 at 11:05:36 UTC, ZombineDev wrote: On Friday, 8 July 2016 at 06:17:43 UTC, Nicholas Wilson wrote: On Friday, 8 July 2016 at 05:53:21 UTC, Nicholas Wilson wrote: So as part of my effort to get D running on GPUs I need to make a "second class" pointer type that I can alter

Re: opOpAssign

2016-07-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 8 July 2016 at 07:15:06 UTC, ketmar wrote: auto opOpAssign(string op)(ptrdiff_t i) if(op =="+" || op == "-") Derp. Thanks!

opOpAssign

2016-07-08 Thread Nicholas Wilson via Digitalmars-d-learn
struct Pointer(uint p, T) if(p <= Generic) { T* ptr; ref T opUnary(string op)() if(op=="*") { return *ptr; } ref T opIndex(size_t i) { return *(ptr+i); } auto opBinary(string op)(ptrdiff_t i) if(op == "+" || op == "-") { return

Re: Second class pointers

2016-07-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 8 July 2016 at 05:53:21 UTC, Nicholas Wilson wrote: So as part of my effort to get D running on GPUs I need to make a "second class" pointer type that I can alter in the backend of LDC to the correct address space. to that end I have made the following module

Second class pointers

2016-07-07 Thread Nicholas Wilson via Digitalmars-d-learn
So as part of my effort to get D running on GPUs I need to make a "second class" pointer type that I can alter in the backend of LDC to the correct address space. to that end I have made the following module dcompute.types.pointer; enum Private = 0; enum Global = 1; enum Shared = 2; enum

Re: static __gshared struct

2016-07-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 2 July 2016 at 00:08:10 UTC, Hiemlick Hiemlicker wrote: On Friday, 1 July 2016 at 23:36:35 UTC, Basile B. wrote: On Friday, 1 July 2016 at 23:26:19 UTC, Hiemlick Hiemlicker wrote: On Friday, 1 July 2016 at 23:03:17 UTC, Basile B. wrote: [...] Ok, Does that mean [...]

Re: Tuple fields/types

2016-06-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 30 June 2016 at 21:53:42 UTC, Jordan Wilson wrote: Hello, For tuples, does the fieldNames property have a 1-1 correspondence with the Types property? It appears that way in my testing: alias MyData = Tuple!(string,"a",int,"b"); foreach (i, type; MyData.Types){ writeln

Tuple fields/types

2016-06-30 Thread Jordan Wilson via Digitalmars-d-learn
Hello, For tuples, does the fieldNames property have a 1-1 correspondence with the Types property? It appears that way in my testing: alias MyData = Tuple!(string,"a",int,"b"); foreach (i, type; MyData.Types){ writeln (MyData.fieldNames[i]," ",type.stringof); // a string // b int

Re: Is it legal to place a UDA on a module?

2016-06-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 20 June 2016 at 19:14:42 UTC, Jacob Carlborg wrote: On 2016-06-20 16:23, Jacob Carlborg wrote: On 2016-06-20 11:59, Nicholas Wilson wrote: as in @myattr module foo; not module foo; @myattr: No, I don't think so. Because "module" can only appear the the top of the file (except

Is it legal to place a UDA on a module?

2016-06-20 Thread Nicholas Wilson via Digitalmars-d-learn
as in @myattr module foo; not module foo; @myattr:

Legal operator overloading

2016-05-29 Thread Nicholas Wilson via Digitalmars-d-learn
Is it legal/possible to overload the unary * operator? Also is it legal/possible to individually overload the comparison operators and not return a bool? (Before you ask no I'm not crazy, I am trying to make a library solution to multiple address spaces for supporting OpenCL/CUDA in D, and

Re: Is there a 128-bit integer in D?

2016-05-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 21 May 2016 at 09:43:38 UTC, Saurabh Das wrote: I see that 'cent' and 'ucent' are reserved for future use but not yet implemented. Does anyone have a working implementation of these types? Alternatively, is there an any effort towards implementation of arbitrary-sized integers

Re: Using a string generated at compile-time in a @nogc function

2016-05-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 1 May 2016 at 05:28:36 UTC, Mithun Hunsur wrote: Hi all, I'm working on removing the string mixins from my code, but have run into an issue: http://dpaste.dzfl.pl/ecd7eb53947e As far as I can tell, this should work; the enum should force compile-time execution (which it does, as

Re: vibe.d is blocking threads

2016-04-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 27 April 2016 at 13:00:29 UTC, RuZzz wrote: Code: import std.concurrency; import core.thread; //import vibe.http.client; // If uncommented this line, the thread "worker" does not start void worker() { foreach (i; 0 .. 5) {

Re: Newbie: Error parsing csv file with very long lines

2016-04-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 23 April 2016 at 10:57:04 UTC, salvari wrote: Fixed!!! Thanks a lot. :-) But I have to think about this. I don't understand the failure. stdin.byLine() reuses its buffer. so the old arrays in columns point to the data in byLine's buffer and they get overwritten by subsequent

Re: Adding a float with all four elements of a float4

2016-04-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 21 April 2016 at 01:48:15 UTC, Nicholas Wilson wrote: On Thursday, 21 April 2016 at 00:14:53 UTC, Straivers wrote: Hi, I want to make a utility wrapper around a core.simd.float4, and have been trying to make the following code work, but have been met with no success. [...]

Re: Adding a float with all four elements of a float4

2016-04-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 21 April 2016 at 00:14:53 UTC, Straivers wrote: Hi, I want to make a utility wrapper around a core.simd.float4, and have been trying to make the following code work, but have been met with no success. [...] you want to broadcast the rhs to a float4 and then adds them. Can

Re: Anonymous structure

2016-04-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 18 April 2016 at 02:12:24 UTC, Tofu Ninja wrote: Just out of curiosity, what is the point of the following? struct a{ struct{ int x; int y; int z; } } As far as I can tell, the anonymous structure does nothing. How is

Re: Dealing with type information loss in Parameters Fields and Return type

2016-04-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 17 April 2016 at 13:56:38 UTC, Jonathan M Davis wrote: Perhaps, but be aware that Walter Bright thinks that size_t should stay as-is: http://forum.dlang.org/post/nevrsb$2ge1$1...@digitalmars.com Maybe some sort of general change to how aliases work would be acceptable and would

Re: Dealing with type information loss in Parameters Fields and Return type

2016-04-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 17 April 2016 at 11:47:52 UTC, Jonathan M Davis wrote: On Sunday, April 17, 2016 11:00:15 Nicholas Wilson via Digitalmars-d-learn wrote: On Sunday, 17 April 2016 at 10:48:08 UTC, Jonathan M Davis wrote: > [...] Sorry for the confusion, I didn't. getting the string &quo

Re: Dealing with type information loss in Parameters Fields and Return type

2016-04-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 17 April 2016 at 10:48:08 UTC, Jonathan M Davis wrote: On Sunday, April 17, 2016 10:12:29 Nicholas Wilson via Digitalmars-d-learn wrote: [...] I'm actually surprised that you got the compiler to give you size_t in any form. size_t is simply an alias to either ulong (on 64-bit

Re: Dealing with type information loss in Parameters Fields and Return type

2016-04-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 17 April 2016 at 10:22:00 UTC, Anonymouse wrote: On Sunday, 17 April 2016 at 10:12:29 UTC, Nicholas Wilson wrote: So currently there is a loss of information when Parameters Fields and Return type. i.e. assuming 64 bits size_t foo(ptrdiff_t) {}; writeln(ReturnType!foo); // prints

Dealing with type information loss in Parameters Fields and Return type

2016-04-17 Thread Nicholas Wilson via Digitalmars-d-learn
So currently there is a loss of information when Parameters Fields and Return type. i.e. assuming 64 bits size_t foo(ptrdiff_t) {}; writeln(ReturnType!foo); // prints ulong Is there any way to get the types as (tuples of) strings of the the types as they are in the source file? auto foos =

Re: foreach of classes

2016-04-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 9 April 2016 at 10:56:34 UTC, Lucien wrote: On Saturday, 9 April 2016 at 10:28:05 UTC, Basile B. wrote: On Saturday, 9 April 2016 at 10:10:19 UTC, Lucien wrote: Hello. When I do: - class MyClass{..} class YourClass{..} class OurClass{..} YourClass yc = new

Re: State of windows DLL support

2016-04-03 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 3 April 2016 at 14:34:07 UTC, Vladimir Panteleev wrote: On Sunday, 3 April 2016 at 14:19:17 UTC, rikki cattermole wrote: [...] Have you actually tried doing this in practice and getting it to work? Even with correct function signatures, you'd need more than just the types to

Re: State of windows DLL support

2016-04-03 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 3 April 2016 at 15:34:33 UTC, Vladimir Panteleev wrote: On Sunday, 3 April 2016 at 15:32:00 UTC, rikki cattermole wrote: On 04/04/2016 2:34 AM, Vladimir Panteleev wrote: [...] LabVIEW is the one that calls the functions. You declare the signature there. Nothing fancy pretty much

Re: State of windows DLL support

2016-04-03 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 3 April 2016 at 13:59:29 UTC, Vladimir Panteleev wrote: 2. If the main program is in D and you want to use a C DLL, then it is no different to how D already uses the Windows API runtime or any other C library. You will need to find, create or convert an import library in order to

Re: State of windows DLL support

2016-04-03 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 3 April 2016 at 12:20:33 UTC, rikki cattermole wrote: I'm just guessing context here. Oh. Needed functionality is in DLL. Need it in LV. Can't / don't know how to in LV. setting up a server for that functionality in D ( I/O to some power inverters DAQ ). set up a pipe /local host

Re: State of windows DLL support

2016-04-03 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 3 April 2016 at 11:46:24 UTC, rikki cattermole wrote: On 03/04/2016 11:36 PM, Nicholas Wilson wrote: What is the state of DLL support on windows? I ask because I have a project coming up very soon which will require interacting with DLLs (I think it is a C interface) and I would

State of windows DLL support

2016-04-03 Thread Nicholas Wilson via Digitalmars-d-learn
What is the state of DLL support on windows? I ask because I have a project coming up very soon which will require interacting with DLLs (I think it is a C interface) and I would much rather do it in D than C given the opportunity. I don't think the choice of language matters, users and

Re: string to uppercase

2016-04-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 3 April 2016 at 03:05:08 UTC, stunaep wrote: Is there any easy way to convert a string to uppercase? I tried s.asUpperCase, but it returns a ToCaserImpl, not a string, and it cant be cast to string. I also tried toUpper but it wasnt working with strings asUpperCase returns a range

Re: Dustmiting a dmft assert

2016-03-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 30 March 2016 at 09:06:20 UTC, Nicholas Wilson wrote: so Oops. should be $ dfmt out.d core.exception.AssertError@/Users/nicholaswilson/d/phobos/std/conv.d(4061): emplace: Chunk is not aligned.

Dustmiting a dmft assert

2016-03-30 Thread Nicholas Wilson via Digitalmars-d-learn
so $core.exception.AssertError@/Users/nicholaswilson/d/phobos/std/conv.d(4061): emplace: Chunk is not aligned. 4 dfmt0x000109536ace _d_assert_msg + 142 5 dfmt0x0001094d600f

Re: Vibelog: dyaml compilation problems

2016-03-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 27 March 2016 at 09:57:40 UTC, Nicholas Wilson wrote: So I'm trying to run vibelog and have cloned the repo used $dub run. One dependency is dyaml. This doesn't compile, but looks like the latest commit to master fixes this. where in the dependency chain is this? Or in other words:

way to warn about __traits(compiles , ...) that fail due to compile time interpretation lacking body ?

2016-03-21 Thread Nicholas Wilson via Digitalmars-d-learn
So I was recently trying to optimise a string substitution function by reserving capacity. however this was being used at compile time (mixin) and the body of arr.reserve(n) was not available causing a bug that was easy to observe but very difficult to determine why. As a result code was

Re: Destructor order

2016-03-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 18 March 2016 at 10:20:40 UTC, Temtaime wrote: Hi ! I wonder if i can rely on this code : http://dpaste.dzfl.pl/745cc5b1cdfb There's two questions: 1) Is dtors always called in reverse order ? yes 2) Is all the dtors always called when i call destroy ? yes. destroy calls __dtor()

Re: std.stdio.File.seek error

2016-03-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 14 March 2016 at 05:24:48 UTC, stunaep wrote: On Monday, 14 March 2016 at 03:07:05 UTC, Nicholas Wilson wrote: [...] I'm currently on windows 7. The code you gave me prints 022. It's weird because it always tries to convert longs to ints and I think that is weird because the

Re: std.stdio.File.seek error

2016-03-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 14 March 2016 at 00:12:46 UTC, stunaep wrote: On Sunday, 13 March 2016 at 12:21:11 UTC, Nicholas Wilson wrote: On Sunday, 13 March 2016 at 10:32:41 UTC, stunaep wrote: I have a very large file I need to read data from at certain positions, but I have run into this error [...] when

Re: std.stdio.File.seek error

2016-03-13 Thread Nicholas Wilson via Digitalmars-d-learn
f.seek(173445340 , SEEK_SET); f.seek(173445340 , SEEK_REL); oops that should be 3173445340.

Re: std.stdio.File.seek error

2016-03-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 13 March 2016 at 10:32:41 UTC, stunaep wrote: I have a very large file I need to read data from at certain positions, but I have run into this error std.conv.ConvOverflowException@std\conv.d(1328): Conversion positive overflow when seeking to 6346890680. Seeking to smaller values

Re: Bikeshed: Implementing a command queue.

2016-03-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 12 March 2016 at 15:10:16 UTC, maik klein wrote: I wanted to implement a simple command queue in D. To give a bit of context, I want to create a command queue for opengl. Instead of interacting directly with opengl, you will create commands, put them in a queue and then the

Re: Bikeshed: Implementing a command queue.

2016-03-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 12 March 2016 at 15:10:16 UTC, maik klein wrote: I wanted to implement a simple command queue in D. To give a bit of context, I want to create a command queue for opengl. Instead of interacting directly with opengl, you will create commands, put them in a queue and then the

Re: D and devkitARM

2016-03-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 9 March 2016 at 00:34:44 UTC, TheGag96 wrote: Hi guys, for a possibly-in-over-my-head project I'd like to get working a simple "Hello World" type program in which I call a D function from C in a 3DS homebrew app (or maybe even have it all in plain D with bindings to libctru). The

Re: Missing Symbol Accessing Templated Function Through Interface

2016-03-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 8 March 2016 at 11:50:32 UTC, Peter wrote: Hi, Can anyone explain to me what's causing the following code to generate a missing symbol error... import std.stdio; interface IProblem { void writeln(T...)(T arguments); } class Problem : IProblem { void writeln(T...)(T

Re: Error: constructor Foo.this default constructor for structs only allowed with @disable, no body, and no parameters

2016-03-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 7 March 2016 at 13:23:58 UTC, Nicholas Wilson wrote: struct Fence { VkFence fence; alias fence this; static struct CreateInfo { VkFenceCreateInfo ci; alias ci this; this( )

Error: constructor Foo.this default constructor for structs only allowed with @disable, no body, and no parameters

2016-03-07 Thread Nicholas Wilson via Digitalmars-d-learn
struct Fence { VkFence fence; alias fence this; static struct CreateInfo { VkFenceCreateInfo ci; alias ci this; this( ) { ci = typeof(ci)(

Re: Forwarding varadic function arguments

2016-03-03 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 4 March 2016 at 01:13:37 UTC, Ali Çehreli wrote: On 03/03/2016 04:50 PM, Nicholas Wilson wrote: > [...] I think so. Also noting that C-style varargs can only work with fundamental types (Am I correct there? I am carrying this assumption from C++.), you may be happier with a

Forwarding varadic function arguments

2016-03-03 Thread Nicholas Wilson via Digitalmars-d-learn
//f is a File* void fwrite(int line = __LINE__)(...) { f.write("/*",line,"*/ "); f.write(_argptr); //prints e.g 7FFF5B055440 } basically i want fwrite("1 ","2\t","3\n"); to print /*7*/ 1 23 do I have to iterate through _argptr

Re: Backslash escaping weirdness

2016-02-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 04:48:01 UTC, Adam D. Ruppe wrote: On Tuesday, 1 March 2016 at 04:18:11 UTC, Nicholas Wilson wrote: What is causing these errors? I'm using \t and \n in string all over the place and they work. I don't think there's enough context to know for sure... but my guess

Backslash escaping weirdness

2016-02-29 Thread Nicholas Wilson via Digitalmars-d-learn
line 620: for(auto i = 1; i < pits3.length - 2; i++) { f.write(params3[i].fixup_T,"\t", pits3[i],","); } f.write(params3[$-2].fixup_T,"\t", pits3[$-1]); f.write(")\n\t\t{typeof(return) _p;\n\t\t", m2,"(",mainVarName); for(auto i = 1; i < pits3.length - 2; i++) {

Re: Is DUB the best place to get examples of "Best of" D code?

2016-02-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 28 February 2016 at 05:59:39 UTC, WhatMeWorry wrote: If so, is there a way to do a global search of all projects in DUB? Aside downloading them all and loading them into an IDE, Ctrl+F for keywords in the description. For what purpose? Learning? Ctrl+F finds me

Re: all functions that have a first arg of type T

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 26 February 2016 at 04:21:15 UTC, BBasile wrote: On Friday, 26 February 2016 at 04:19:29 UTC, BBasile wrote: static if (__traits(isStaticFunction,typeof(m2))) static if (__traits(isStaticFunction, __traits(getMember, vulkan_input, m2 Sorry don't copy paste like this there's a

all functions that have a first arg of type T

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
foreach(m; __traits(allMembers, vulkan_input)) { static if (m.endsWith("_T")) { foreach(m2; __traits(allMembers, vulkan_input)) { static if (__traits(isStaticFunction,typeof(m2)))// <- what here? { enum fn =

Re: how to initialise const variables

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 26 February 2016 at 02:48:35 UTC, cym13 wrote: On Friday, 26 February 2016 at 02:32:44 UTC, Nicholas Wilson wrote: struct A { const (void *) p; } struct B { Aa; this(void * _p) { a.p = _p; } } I cannot change the definition of A how do I initialise

how to initialise const variables

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
struct A { const (void *) p; } struct B { Aa; this(void * _p) { a.p = _p; } } I cannot change the definition of A how do I initialise b.a.p?

Re: Accessing all data in TypeTupple (AliasSeq) and stringify them

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 20:53:12 UTC, Voitech wrote: On Thursday, 25 February 2016 at 14:29:30 UTC, Nicholas Wilson wrote: On Thursday, 25 February 2016 at 13:16:43 UTC, Voitech wrote: [...] You can (see std.meta/(std.traits?) , with recursive templates), but there is nothing

Re: Accessing all data in TypeTupple (AliasSeq) and stringify them

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 13:16:43 UTC, Voitech wrote: Hi, I have some code processing functions definition in compile time, I want to override them in some other class but not explicitly so created this code: template MixinFunction(alias attributes,alias returnType,alias name,alias

Re: how do you append arrays?

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 13:38:56 UTC, ag0aep6g wrote: On 25.02.2016 14:33, Nicholas Wilson wrote: Note that D has zero based array indexing so assuming your array has 100 elements history[1..100] is going one past the end of the array. No, that's fine. `history[1..100]` gives you 99

Re: how do you append arrays?

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 13:24:09 UTC, asdf wrote: On Thursday, 25 February 2016 at 13:06:10 UTC, cym13 wrote: In D the binary operator "~" is used to concatenate both strings (arrays of characters) and arrays. (also the ~= operator is equivalent to lhs = lhs ~ rhs Nic Just a

Re: how do you append arrays?

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 12:53:37 UTC, asdf wrote: I'm trying to make a terminal input preprocessor with alias/shortcuts and history. import std.stdio; void main() { string line; string[] history; line = readln(); foreach(int i; 0..100) history = history + [""]; //

Re: how do you append arrays?

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 12:53:37 UTC, asdf wrote: I'm trying to make a terminal input preprocessor with alias/shortcuts and history. import std.stdio; void main() { string line; string[] history; line = readln(); foreach(int i; 0..100) history = history + [""]; //

Re: tell if __traits(allMembers, ... ) is an enum (not manifest constant)

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 08:40:00 UTC, nkgu wrote: On Thursday, 25 February 2016 at 04:55:09 UTC, Nicholas Wilson wrote: oops should be writeln(typeof(__traits(getMember, vulkan_input, m)).stringof); that compiles but still prints nothing try pragma(msg,

Re: tell if __traits(allMembers, ... ) is an enum (not manifest constant)

2016-02-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 04:50:14 UTC, Nicholas Wilson wrote: On Thursday, 25 February 2016 at 04:32:24 UTC, Adam D. Ruppe wrote: On Thursday, 25 February 2016 at 04:25:25 UTC, Nicholas Wilson wrote: foreach(m; __traits(allMembers, ...) { static if(is(m== enum)) } That's close

<    1   2   3   4   5   6   7   >