Does DUB create .dll files?

2016-05-16 Thread WhatMeWorry via Digitalmars-d-learn
I just incorporated DerelictALURE into a project and it compiled and linked fine, but when I ran the executable, it aborted with: derelict.util.exception.SharedLibLoadException@N:\DUB_Packages\DerelictOrg\DerelictUtil\source\derelict\util\exception.d(35): Failed to load one or more

Re: Formatted Output: Exact number of Decimal Places

2016-05-16 Thread Ali Çehreli via Digitalmars-d-learn
On 05/16/2016 01:24 PM, Q. Schroll wrote: Lets say I want to print a table with floats. How can it be formatted like that: | 2.4 | | 12.2 | | 8.131 | | 17.44 | Also acceptable is | 2.400 | | 12.200 | | 8.131 | | 17.440 | but not | 02.4 | | 12.2 | | 08.131 | | 17.44 | or any other

Re: Small-Size-Optimized Array

2016-05-16 Thread Vladimir Panteleev via Digitalmars-d-learn
On Monday, 16 May 2016 at 11:05:40 UTC, Nordlöw wrote: Does Phobos contain any standard small-size-optimized (SSO) array that starts with a stack array and union-converts into a standard builtin D-array when grown beyond the size of the stack array? Have a look at tempCString, but it's for

Re: Formatted Output: Exact number of Decimal Places

2016-05-16 Thread Andrew Chamberlain via Digitalmars-d-learn
On Monday, 16 May 2016 at 20:24:51 UTC, Q. Schroll wrote: Lets say I want to print a table with floats. How can it be formatted like that: | 2.4 | | 12.2 | | 8.131 | | 17.44 | Also acceptable is | 2.400 | | 12.200 | | 8.131 | | 17.440 | but not | 02.4 | | 12.2 | | 08.131 | | 17.44

Re: Formatted Output: Exact number of Decimal Places

2016-05-16 Thread Marco Leise via Digitalmars-d-learn
Am Mon, 16 May 2016 20:24:51 + schrieb Q. Schroll : > Lets say I want to print a table with floats. How can it be > formatted like that: > | 2.4 | > | 12.2 | > | 8.131 | > | 17.44 | > Also acceptable is > | 2.400 | > | 12.200 | > | 8.131 | > | 17.440 |

Re: Small-Size-Optimized Array

2016-05-16 Thread Jack Stouffer via Digitalmars-d-learn
On Monday, 16 May 2016 at 11:05:40 UTC, Nordlöw wrote: Does Phobos contain any standard small-size-optimized (SSO) array that starts with a stack array and union-converts into a standard builtin D-array when grown beyond the size of the stack array? No. If not has anybody put together one?

Re: Void pointers

2016-05-16 Thread ag0aep6g via Digitalmars-d-learn
On 05/17/2016 12:43 AM, Alex wrote: The point is, that in my model the slice has a meaning itself. So, the language provides one of a needed constructs... Huh? As far as I understand, the pointer of the slice is invalid, and you never dereference it. What kind of additional meaning can the

Re: Void pointers

2016-05-16 Thread Alex via Digitalmars-d-learn
On Monday, 16 May 2016 at 22:28:04 UTC, ag0aep6g wrote: I can't say that I understand the setup you describe. But are you sure that iota has a higher cost than (ab)using a slice? I mean, they're pretty much exactly the same: an offset, a length, and an increment operation. If inlining

Re: Void pointers

2016-05-16 Thread ag0aep6g via Digitalmars-d-learn
On 05/16/2016 11:33 PM, Alex wrote: Well... not wanting to have a variable, which stores numbers, which are natural numbers, beginning with zero, used for counting only. But you have such a variable: b. I may still be missing the point.

Re: Void pointers

2016-05-16 Thread ag0aep6g via Digitalmars-d-learn
On 05/16/2016 11:35 PM, Alex wrote: Background: Say, I have objects of kind E, which operate on structs of kind M. The problem: if an action is done on a struct, say M42, there should be also some action done on other structs, which have some relation to M42, but neither the operating object,

Re: Void pointers

2016-05-16 Thread Alex via Digitalmars-d-learn
On Monday, 16 May 2016 at 21:41:20 UTC, Steven Schveighoffer wrote: Hey, there's nothing wrong with for-loops. Just trying to answer the question :) You could also do something like: foreach(i; 0 .. b.length) writeln([i]); Ha! Yes! :) Thanks :) -Steve

Re: Void pointers

2016-05-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/16/16 5:38 PM, Alex wrote: On Monday, 16 May 2016 at 21:15:16 UTC, Steven Schveighoffer wrote: On 5/16/16 4:39 PM, Alex wrote: // something that does not worked as expected: // how to rewrite a for loop for(auto i = 0; i < b.length; i++) writeln([i]); // into a foreach

Re: Void pointers

2016-05-16 Thread Alex via Digitalmars-d-learn
On Monday, 16 May 2016 at 21:15:16 UTC, Steven Schveighoffer wrote: On 5/16/16 4:39 PM, Alex wrote: // something that does not worked as expected: // how to rewrite a for loop for(auto i = 0; i < b.length; i++) writeln([i]); // into a foreach loop? What you need is a

Re: Void pointers

2016-05-16 Thread Alex via Digitalmars-d-learn
Background: Say, I have objects of kind E, which operate on structs of kind M. The problem: if an action is done on a struct, say M42, there should be also some action done on other structs, which have some relation to M42, but neither the operating object, nor M42 is aware of them (and the

Re: Void pointers

2016-05-16 Thread Alex via Digitalmars-d-learn
On Monday, 16 May 2016 at 21:04:32 UTC, ag0aep6g wrote: Typo here. Should be `ptr[a .. b]`. Thanks void main() { void* ptr; // this will stay uninitialized during the whole program run The pointer is being initialized, though. To null, which is why your shenanigans below work

Re: Void pointers

2016-05-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/16/16 4:39 PM, Alex wrote: // something that does not worked as expected: // how to rewrite a for loop for(auto i = 0; i < b.length; i++) writeln([i]); // into a foreach loop? What you need is a range that produces void * instead element itself. This would probably

Re: Void pointers

2016-05-16 Thread ag0aep6g via Digitalmars-d-learn
On 05/16/2016 10:39 PM, Alex wrote: // This function is intentionally templated, as it should take slices and return something // boundchecked only @nogc T[] getSlice(T)(T* ptr, size_t a, size_t b) { return T[a .. b]; Typo here. Should be `ptr[a .. b]`. } void main() { void* ptr;

Re: `return ref`, DIP25, and struct/class lifetimes

2016-05-16 Thread Dicebot via Digitalmars-d-learn
There is also another counter-obvious bit regarding current implementation - it only tracks lifetime of actual references. Check this example: ref int wrap ( return ref int input ) { return input; } int badWrapper() { int z; { int x = 42; z = wrap(x); }

Void pointers

2016-05-16 Thread Alex via Digitalmars-d-learn
Hi all! Let's talk about void pointers a little bit. Found this already http://forum.dlang.org/thread/codoixfeqstvqswir...@forum.dlang.org?page=1 but my question/problem differs from the above, so maybe, I have found a useful application for void pointers... Form of the posting: I have some

Formatted Output: Exact number of Decimal Places

2016-05-16 Thread Q. Schroll via Digitalmars-d-learn
Lets say I want to print a table with floats. How can it be formatted like that: | 2.4 | | 12.2 | | 8.131 | | 17.44 | Also acceptable is | 2.400 | | 12.200 | | 8.131 | | 17.440 | but not | 02.4 | | 12.2 | | 08.131 | | 17.44 | or any other solutions with leading zeros.

Re: Request assistance converting C's #ifndef to D

2016-05-16 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On Thursday, 12 May 2016 at 22:51:17 UTC, Andrew Edwards wrote: The following preprocessor directives are frequently encountered in C code, providing a default constant value where the user of the code has not specified one: #ifndef MIN #define MIN 99 #endif

Re: `return ref`, DIP25, and struct/class lifetimes

2016-05-16 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On Monday, 16 May 2016 at 15:33:09 UTC, Dicebot wrote: tl; dr: DIP25 is so heavily under-implemented in its current shape it can be considered 100% broken and experimenting will uncover even more glaring holes. Well, it's always fun to find the holes in things ... :-) To be more precise,

Re: D equivalent of C++ bind ?

2016-05-16 Thread Dsby via Digitalmars-d-learn
On Monday, 16 May 2016 at 15:11:26 UTC, chmike wrote: On Thursday, 12 May 2016 at 10:38:37 UTC, Dsby wrote: [...] Thank you. Would you agree to help me understand it ? The only thing I don't understand is why the function template argument is defined as T and the argument as auto ref T

Re: `return ref`, DIP25, and struct/class lifetimes

2016-05-16 Thread Dicebot via Digitalmars-d-learn
tl; dr: DIP25 is so heavily under-implemented in its current shape it can be considered 100% broken and experimenting will uncover even more glaring holes. To be more precise, judging by experimental observation, currently dip25 only works when there is explicitly a `ref` return value in

Re: D equivalent of C++ bind ?

2016-05-16 Thread chmike via Digitalmars-d-learn
On Thursday, 12 May 2016 at 10:38:37 UTC, Dsby wrote: I write one, bind functon to a delegate. In here: https://github.com/putao-dev/collie/blob/master/source/collie/utils/functional.d this is the code: auto bind(T,Args...)(auto ref T fun,Args args) if (isCallable!(T)) { alias

`return ref`, DIP25, and struct/class lifetimes

2016-05-16 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
Hello all, Consider a struct that wraps a pointer to some other piece of data as follows: struct MyWrapper(T) { private T* data; public this(ref T input) { this.data = } ... other methods that use `this.data` ... } Is there

Re: source/protocols.d(40, 34): Error: uninitialized variable 'value' cannot be returned from CTFE

2016-05-16 Thread Stefan via Digitalmars-d-learn
On Monday, 16 May 2016 at 11:13:52 UTC, ag0aep6g wrote: On 05/16/2016 11:24 AM, Stefan wrote: source/protocols.d(40,34): Error: uninitialized variable 'value' cannot be returned from CTFE Ouch. That's not a good error message. There is no `value` on that line. I've filed an issue:

Re: source/protocols.d(40, 34): Error: uninitialized variable 'value' cannot be returned from CTFE

2016-05-16 Thread ag0aep6g via Digitalmars-d-learn
On 05/16/2016 11:24 AM, Stefan wrote: source/protocols.d(40,34): Error: uninitialized variable 'value' cannot be returned from CTFE Ouch. That's not a good error message. There is no `value` on that line. I've filed an issue: https://issues.dlang.org/show_bug.cgi?id=16030 this ist the code

Small-Size-Optimized Array

2016-05-16 Thread Nordlöw via Digitalmars-d-learn
Does Phobos contain any standard small-size-optimized (SSO) array that starts with a stack array and union-converts into a standard builtin D-array when grown beyond the size of the stack array? If not has anybody put together one?

source/protocols.d(40,34): Error: uninitialized variable 'value' cannot be returned from CTFE

2016-05-16 Thread Stefan via Digitalmars-d-learn
Hello, i try to port some go code to D i get this error messages from my current code. source/protocols.d(40,34): Error: uninitialized variable 'value' cannot be returned from CTFE source/protocols.d(41,34): Error: uninitialized variable 'value' cannot be returned from CTFE