Re: std.algorithm.remove from array of custom classes?

2015-12-09 Thread BBaz via Digitalmars-d-learn
On Wednesday, 9 December 2015 at 13:05:31 UTC, Tim K. wrote: Hi! I'm trying to remove an item from an array of objects. But I get error messages when compiling (see below) which I do not understand. I figured I had to override opEquals for it to work, but no. How do I get this to work?

Re: Real Time-ing

2015-12-08 Thread BBaz via Digitalmars-d-learn
On Tuesday, 8 December 2015 at 16:40:04 UTC, Taylor Hillegeist wrote: On Tuesday, 8 December 2015 at 15:35:18 UTC, Taylor Hillegeist wrote: So, I mostly do programming that is of run to completion I took a stab at the problem: http://dpaste.dzfl.pl/2eef530d00fc 0 nsecs with jitter of

Re: isAllocator

2015-12-01 Thread BBaz via Digitalmars-d-learn
On Tuesday, 1 December 2015 at 03:05:34 UTC, Rikki Cattermole wrote: On 01/12/15 3:23 AM, Tofu Ninja wrote: On Monday, 30 November 2015 at 14:21:49 UTC, Tofu Ninja wrote: Is there something like isInputRange for allocators, I tried looking for something but couldn't find anything? If not, why

Re: isAllocator

2015-12-01 Thread BBaz via Digitalmars-d-learn
On Tuesday, 1 December 2015 at 12:37:12 UTC, Tofu Ninja wrote: On Tuesday, 1 December 2015 at 08:58:56 UTC, BBaz wrote: I think that `is(CAllocatorImpl!Alloc)` should work too then. According to the 'is' version, int is an allocator. No idea why it thinks this works... Me neither,

Re: Range violation instead of empty slice on a[3 .. 2]

2015-11-21 Thread BBaz via Digitalmars-d-learn
On Saturday, 21 November 2015 at 18:03:07 UTC, SimonN wrote: string a = "hello"; string b = a[3 .. 2]; I expect b to become an empty slice, because 3 is >= 2 already after 0 increments, making the slice length 0. Instead, the code throws a range violation. Expressions of this kind

Can someone check this on win32 ?

2015-11-21 Thread BBaz via Digitalmars-d-learn
Seems to be fixed: __ import std.math; void main() {real function(real) c = } __ https://issues.dlang.org/show_bug.cgi?id=4541 At least it works on linux x86_64.

Re: char[] == null

2015-11-19 Thread BBaz via Digitalmars-d-learn
On Wednesday, 18 November 2015 at 20:57:08 UTC, Spacen Jasset wrote: Should this be allowed ? IMHO no. It's better to use `.length` to test if an array is empty. Why ? Because the day you'll have a function whose parameter is a pointer to an array, comparing to null will become completly

Re: std.conv.to!string(array), strange compile error

2015-11-14 Thread BBaz via Digitalmars-d-learn
On Saturday, 14 November 2015 at 12:46:21 UTC, Relja wrote: I've got this strange compile error using std.conv.to!string(double[3]) - or any static array type. It's called in toString override function of a template matrix class, I'm building as a D learning project. [...] Maybe try to use

Re: How do I read one character from stdin? (getc in C)

2015-11-14 Thread BBaz via Digitalmars-d-learn
On Saturday, 14 November 2015 at 13:33:49 UTC, Fer22f wrote: Hello! I'm starting to make some simple command line programs and one thing I miss from C is a function for getting one character from the input. This is for example, an "Press Any Key Program". Anyone that has more experience can

DUB library prefix - rules ?

2015-11-10 Thread BBaz via Digitalmars-d-learn
quoted from the website: Sets the base name of the output file; type and platform specific pre- and suffixes are added automatically - this setting does not support platform suffixes I must be blind but I can't find the code that adds the 'lib' prefix on GitHub. I need to check something:

Re: Deprecation: module std.stream is deprecated

2015-11-08 Thread BBaz via Digitalmars-d-learn
On Saturday, 7 November 2015 at 13:52:29 UTC, Spacen Jasset wrote: [...] I have a used a template, because I cannot directly use the InputRange(char) interface as a type, and auto won't work either, so is there another parameter type I can use, such that I can have the concept of an abstract

Re: Deprecation: module std.stream is deprecated

2015-11-08 Thread BBaz via Digitalmars-d-learn
On Sunday, 8 November 2015 at 08:21:38 UTC, BBaz wrote: On Saturday, 7 November 2015 at 13:52:29 UTC, Spacen Jasset wrote: [...] I have a used a template, because I cannot directly use the InputRange(char) interface as a type, and auto won't work either, so is there another parameter type I

Re: dbgVerifySorted is not nothrow

2015-11-08 Thread BBaz via Digitalmars-d-learn
On Sunday, 8 November 2015 at 08:05:41 UTC, Panke wrote: I've updated my compiler and ran into this regression: https://issues.dlang.org/show_bug.cgi?id=14981 [...] reopened.

Re: opCmp with structs

2015-11-07 Thread BBaz via Digitalmars-d-learn
On Saturday, 7 November 2015 at 10:15:25 UTC, Alex wrote: So the question remains, how to sort? Do you think removing the immutable property from an id is the semantically right way? Or do you have a hint, maybe something like, a dup copy with removing immutability and returning a new, sorted

Re: method has no return statement with switch

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Saturday, 7 November 2015 at 00:30:29 UTC, crimaniak wrote: On Saturday, 7 November 2015 at 00:27:02 UTC, Adam D. Ruppe wrote: On Saturday, 7 November 2015 at 00:21:57 UTC, crimaniak wrote: Inserting dummy return statement doesn't help. final switch / switch with default - no matter. Try

Re: opCmp with structs

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Friday, 6 November 2015 at 22:55:15 UTC, Alex wrote: Ok... the question is not silly any more... without 'immutable' it works. So, what am I missing? sorry, again a forum bug that stripped my answer: sort() fails because in the template constraint `hasAssignableElements` fails.

Re: opCmp with structs

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Friday, 6 November 2015 at 22:55:15 UTC, Alex wrote: Ok... the question is not silly any more... without 'immutable' it works. So, what am I missing? sort() fails because in the template constraint `hasAssignableElements

Re: Operator implicit conversion difference

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Thursday, 5 November 2015 at 13:20:26 UTC, ixid wrote: This may have been overlooked in my other thread so I wanted to ask again: This seems very inconsistent, does a += b not lower to a = a + b? I guess not based on the below: ushort a = ushort.max, b = ushort.max; a += b; //

Re: Operator implicit conversion difference

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Saturday, 7 November 2015 at 01:10:01 UTC, Ali Çehreli wrote: On 11/06/2015 04:56 PM, BBaz wrote: On Thursday, 5 November 2015 at 13:20:26 UTC, ixid wrote: [...] What's inconsistent is the integral promotion of the add expression result that stops from 4 bytes int: --- int a, b; a +=

Re: method has no return statement with switch

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Saturday, 7 November 2015 at 00:21:57 UTC, crimaniak wrote: [...] url.Cache.UrlCache.doRequest has no return statement, but is expected to return a value of type string [...] public string doRealRequest(string url, Method method) You posted the wrong code sample: your code shows

Re: Align a variable on the stack.

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Saturday, 7 November 2015 at 03:18:59 UTC, steven kladitis wrote: [...] I am still disappointed that DMD is not native 64 bit in windows yet. [...] It's because they can't make a nice distribution. DMD win32 is a nice package that works out of the box (compiler, standard C lib, standard

Re: question about using std.bitmanip.read

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Saturday, 7 November 2015 at 03:19:44 UTC, Charles wrote: Hi guys, It's me again... still having some issues pop up getting started, but I remain hopeful I'll stop needing to ask so many questions soon. I'm trying to use std.bitmanip.read; however, am having some issues using it. For

Re: std.utf.decode behaves unexpectedly - Bug?

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Friday, 6 November 2015 at 19:26:50 UTC, HeiHon wrote: Am I using std.utf.decode wrongly or is it buggy? It's obviously used wrongly, try this instead: import std.utf, std.stdio; --- dstring do_decode(string txt) { dstring result; try { size_t idx;

Re: std.utf.decode behaves unexpectedly - Bug?

2015-11-06 Thread BBaz via Digitalmars-d-learn
Sorry, the forum as stripped my answer. Here is the full version: On Friday, 6 November 2015 at 19:26:50 UTC, HeiHon wrote: Am I using std.utf.decode wrongly or is it buggy? It's obviously used wrongly, try this instead: import std.utf, std.stdio; --- dstring do_decode(string txt) {

how to skip sub functions in __traits(allMembers)

2015-06-27 Thread BBaz via Digitalmars-d-learn
I try to build a symbol table: --- module aveb; import std.stdio; import std.algorithm.searching; import std.ascii; void* [string] sig; void ana(alias mod)() { import std.traits; foreach(memb;__traits(allMembers,mod)) static if

Re: Should '@disable this()' disable 'static opCall()'?

2015-01-30 Thread BBaz via Digitalmars-d-learn
On Friday, 30 January 2015 at 22:41:35 UTC, Ali Çehreli wrote: I am thinking about opening a bug with the following code: struct S { @disable this(); static void opCall() {} } void main() {} Error: struct deneme.S static opCall is hidden by constructors and can never be called

Re: Should '@disable this()' disable 'static opCall()'?

2015-01-30 Thread BBaz via Digitalmars-d-learn
distinguish Yes, I know this a strange word. But it seems to be a valid one: http://www.collinsdictionary.com/dictionary/english/distinguish?showCookiePolicy=true distinguishable is ok as well.

Re: is it bug?

2015-01-30 Thread BBaz via Digitalmars-d-learn
On Friday, 30 January 2015 at 13:56:17 UTC, anonymous wrote: On Friday, 30 January 2015 at 13:39:05 UTC, BBaz wrote: On Friday, 30 January 2015 at 13:34:57 UTC, drug wrote: On 30.01.2015 16:31, BBaz wrote: On Friday, 30 January 2015 at 12:32:05 UTC, drug wrote: static init() { auto

Re: is it bug?

2015-01-30 Thread BBaz via Digitalmars-d-learn
On Friday, 30 January 2015 at 12:32:05 UTC, drug wrote: static init() { auto instance = new typeof(this)(); instance._cont = new Container(); return instance; } have you tried --- static typeof(this) init() { auto instance = new

Re: is it bug?

2015-01-30 Thread BBaz via Digitalmars-d-learn
On Friday, 30 January 2015 at 13:34:57 UTC, drug wrote: On 30.01.2015 16:31, BBaz wrote: On Friday, 30 January 2015 at 12:32:05 UTC, drug wrote: static init() { auto instance = new typeof(this)(); instance._cont = new Container(); return instance; } have you

Re: Getting DAllegro 5 to work in Windows

2015-01-30 Thread BBaz via Digitalmars-d-learn
On Wednesday, 24 December 2014 at 06:47:26 UTC, Joel wrote: I can't get implib.exe (http://ftp.digitalmars.com/bup.zip) to produce .lib files from dlls (https://www.allegro.cc/files/). I think it works for other people. Thanks for any help. Yep, it works for other people. I've just made the

Re: Is it possible to use an UDA to generate a struct inside a class ?

2015-01-30 Thread BBaz via Digitalmars-d-learn
On Thursday, 1 January 2015 at 22:49:40 UTC, Basile Burg wrote: On Thursday, 1 January 2015 at 21:15:27 UTC, Ali Çehreli wrote: On 01/01/2015 09:35 AM, Basile Burg wrote: On Tuesday, 30 December 2014 at 19:18:41 UTC, Basile Burg wrote: an ICE (every compiler crash is an ICE right ?), Yes,

Re: foreach - premature optimization vs cultivating good habits

2015-01-30 Thread BBaz via Digitalmars-d-learn
On Friday, 30 January 2015 at 11:55:16 UTC, Laeeth Isharc wrote: Hi. The standard advice is not to worry about memory usage and execution speed until profiling shows you where the problem is, and I respect Knuth greatly as a thinker. Still, one may learn from others' experience and