Re: Another bug in function overloading?

2014-04-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 26 Apr 2014 06:55:38 + Domain via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: module test; public interface I { void foo(); void foo(int); } public abstract class A : I { public void bar() { foo(); } public

Re: how to print ubyte*

2014-04-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 30 Apr 2014 07:27:23 + brad clawsie via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: hi, I'm back again with another openssl related question. given this program -- import std.stdio; import deimos.openssl.hmac; import

Re: Strings concatenated at compile time?

2014-05-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Thu, 01 May 2014 11:12:41 + anonymous via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 1 May 2014 at 10:42:36 UTC, Unwise wrote: In the following example from the documentation, are strings concatenated at compile time? template foo(string s) {

Re: map!(char)(string) problem

2014-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 03 May 2014 14:47:56 -0700 David Held via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: import std.algorithm; int toInt(char c) { return 1; } void main() { map!(a = toInt(a))(hello); } Can someone please explain why I get this: Bug.d(10): Error:

Re: const ref parameters and r-value references

2014-05-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Fri, 02 May 2014 08:17:06 + Mark Isaacson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I'm in the process of learning/practicing D and I noticed something that seems peculiar coming from a C++ background: If I compile and run: void fun(const ref int x) {

Re: const ref parameters and r-value references

2014-05-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Sun, 04 May 2014 19:08:27 + Mark Isaacson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Thanks for the insights! I suppose we'll get a chance to see where things stand at this year's dconf. It's quite interesting that D's concept of r-values seems less developed

Re: Implicit static-dynamic arr and modifying

2014-05-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Mon, 05 May 2014 22:16:58 -0400 Nick Sabalausky via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 5/5/2014 10:11 PM, Nick Sabalausky wrote: Is this kinds stuff a sane thing to do, or does it just work by accident?: void modify(ubyte[] dynamicArr) {

Re: [Rosettacode] D code line length limit

2014-05-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 07 May 2014 13:39:55 + Meta via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Maybe D programmers need to adopt a new convention for annotations in the long term. Instead of: void doSomething(int n) pure @safe @nogc nothrow { } We should write: pure @safe @nogc

Re: [Rosettacode] D code line length limit

2014-05-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 07 May 2014 18:51:58 + Meta via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wednesday, 7 May 2014 at 14:40:37 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: My eyes... Oh, how that hurts readibily. While I agree that pure @safe @nogc nothrow void

Re: [Rosettacode] D code line length limit

2014-05-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thu, 08 May 2014 07:29:08 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Jonathan M Davis: ultimately, this sort of thing pretty much always ends up being highly subjective. But please put the const/immutable of methods on the right: struct Foo {

Re: throws Exception in method

2014-05-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thu, 08 May 2014 09:15:13 + amehat via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hello everyone, in java, you can have exceptions on methods. Thus we can write: public static void control (String string) throws MyException {} Is that possible in D and if so how

Re: [Rosettacode] D code line length limit

2014-05-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thu, 08 May 2014 09:30:38 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Jonathan M Davis: Unfortunately, making this consistent by doing something like enforcing that all function attributes go on the right would then be inconsistent with other

Re: [Rosettacode] D code line length limit

2014-05-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thu, 08 May 2014 10:27:17 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Jonathan M Davis: I still think that allowing const on the left is simply a bad design decision. I opened a request on this, and it was closed down :-) I know. Walter doesn't

Re: [Rosettacode] D code line length limit

2014-05-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thu, 8 May 2014 07:32:52 -0700 H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thu, May 08, 2014 at 01:59:58AM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: On Thu, 08 May 2014 07:29:08 + bearophile via Digitalmars-d-learn digitalmars-d-learn

Re: question about passing associative array to a function

2014-05-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Sun, 11 May 2014 17:00:13 + Remind me again why we can't just change this to a sensible initial state? Or at least add a .initialize()? All reference types have a null init value. Arrays and classes have the exact same issue as AAs. Anything else would require not only allocating memory

Re: Templating everything? One module per function/struct/class/etc, grouped by package?

2014-05-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Mon, 12 May 2014 08:37:42 + JR via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Given that... 1. importing a module makes it compile the entirety of it, as well as whatever it may be importing in turn 2. templates are only compiled if instantiated 3. the new package.d

Re: Why std.algorithm.sort can't be applied to char[]?

2014-05-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Mon, 12 May 2014 14:49:52 + hane via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: and is there any way to sort char array with algorithm.sort? --- import std.algorithm; import std.range; void main() { int[] arr = [5, 3, 7]; sort(arr); // OK char[] arr2 =

Re: Why std.algorithm.sort can't be applied to char[]?

2014-05-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Mon, 12 May 2014 11:08:47 -0700 Charles Hixson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 05/12/2014 09:29 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Mon, 12 May 2014 14:49:52 + hane via Digitalmars-d-learn digitalmars-d-learn@puremagic.com

Re: newbie question about variables in slices..

2014-05-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Mon, 12 May 2014 20:12:41 + Kai via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi I am trying to iterate over a mmfile (ubyte[]) and convert it to uint void main(){ MmFile inn = new MmFile(mmData.dat); ubyte[] arr = cast(ubyte[])inn[]; for(ulong index = 0;

Re: Why std.algorithm.sort can't be applied to char[]?

2014-05-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 14 May 2014 08:27:45 + monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Monday, 12 May 2014 at 18:44:22 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: Sure, you can cast char[] to ubyte[] and sort that if you know that the array only

Re: Array!T and find are slow

2014-05-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 14 May 2014 20:54:19 + monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I'm usually reluctant to add extra code when the generic case works, but I feel we should make an exception for find. We should avoid it where it doesn't gain us much, but the

Re: Array!T and find are slow

2014-05-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 14 May 2014 21:20:05 + Kapps via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: That pull shows that the previous behaviour was to use enforce? Isn't this very expensive, particularly considering that enforce uses lazy non-scope arguments? Yeah, much as Andrei would

Re: Array!T and find are slow

2014-05-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thu, 15 May 2014 01:29:23 + Kapps via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wednesday, 14 May 2014 at 23:50:34 UTC, Meta wrote: On the topic of lazy, why *is* it so slow, exactly? I thought it was just shorthand for taking a function that evaluates the

Re: Array!T and find are slow

2014-05-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Thu, 15 May 2014 05:53:45 + monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: As a workaround, I'm sure we could specialize enforce without lazy for built-in types? No. I don't think that that would work. The problem is that you'd have to be able to overload

Re: Array!T and find are slow

2014-05-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Thu, 15 May 2014 08:04:59 -0300 Ary Borenszweig via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Isn't there a way in D to just expand: enforce(cond, failure); (or something with a similar syntax) to this, at compile-time: if(!cond) throw new Exception(failure); I

Re: Array!T and find are slow

2014-05-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Fri, 16 May 2014 11:51:31 -0400 Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Fri, 16 May 2014 11:36:44 -0400, Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thu, 15 May 2014 08:04:59 -0300 Ary Borenszweig

Re: Building 32bit program with MSVC?

2014-05-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Thu, 29 May 2014 20:12:52 + Remo via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 29 May 2014 at 18:25:19 UTC, Jeremy DeHaan wrote: I know that we can use MSVC to build a 64 bit program, but is it also possible to use it to build a 32 bit program as well?

Re: Building 32bit program with MSVC?

2014-05-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 31 May 2014 06:38:46 + Kagamin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: They may use different debugging formats, but just linking should be possible, especially with import libraries. _Dynamic_ linking is possible. Static linking is not. - Jonathan M Davis

Re: Building 32bit program with MSVC?

2014-05-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 31 May 2014 07:53:40 + Kagamin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: By dynamic linking do you mean LoadLibrary or linking with import library? Both will work, otherwise we couldn't use Microsoft's libraries - e.g. std.windows.registry uses advapi32.dll

Re: Indicating incompatible modules

2014-06-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 31 May 2014 18:26:53 +0200 Joseph Rushton Wakeling via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hello all, Is there a straightforward way to indicate that two modules should not be used together in the same program? Preferably one that does not require editing

Re: Forward reference to nested function not allowed?

2014-06-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 31 May 2014 16:18:33 + DLearner via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi, import std.stdio; void main() { writefln(Entered); sub1(); sub1(); sub1(); writefln(Returning); void sub1() { static int i2 = 6;

Re: Are tests interruptible/concurrent? Is use of a (thread local) global safe in tests?

2014-06-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Fri, 30 May 2014 20:13:19 + Mark Isaacson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I'm having fun running some unittests. I set up a simple homemade mock of std.net.curl's functions that essentially just consists of a global queue that I can add strings to and

Re: floating point conversion

2014-06-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Sun, 01 Jun 2014 14:42:34 + Famous via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Sunday, 1 June 2014 at 12:45:26 UTC, bearophile wrote: It's a bad question. Actually, Martin's question is a good one. Initializing a variable of type float via a literal or as

Re: On ref return in DMD

2014-06-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tue, 03 Jun 2014 10:14:21 + Nordlöw via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: The title More ref return fixes in std.datetime now that the compiler allows them of https://github.com/D-Programming-Language/phobos/pull/2227/files made me curious to what is

Re: DateTime custom string format

2014-06-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tue, 03 Jun 2014 17:07:02 +0200 Robert Schadek via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Is there a function in phobos that lets me do something like DateTime.format(MM:DD: ) with a DateTime instance? Not currently. It's on my todo list. I intend to get back

Re: DateTime custom string format

2014-06-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tue, 03 Jun 2014 19:39:14 +0200 Robert Schadek via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 06/03/2014 07:12 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tue, 03 Jun 2014 17:07:02 +0200 Robert Schadek via Digitalmars-d-learn digitalmars-d-learn

Re: DateTime custom string format

2014-06-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tue, 03 Jun 2014 22:54:11 + Brad Anderson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 3 June 2014 at 18:22:59 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: Well, I would prefer to do it myself, but I obviously can't say that I wouldn't accept

Re: override toString() for a tuple?

2014-06-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 04 Jun 2014 05:35:18 + Steve D via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Is it possible to override std tuple's toString format? so that auto a = tuple(hello,1,2,3); writeln(a); prints (hello, 1, 2, 3) and not

Re: override toString() for a tuple?

2014-06-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 04 Jun 2014 06:25:53 + Steve D via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: You would think the promise of OO and Inheritance would make it easy and free us from hacks like this ;) That would require using OO and inheritance, which has nothing to do with Tuple.

Re: Weird behaviour when using -release in dmd

2014-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Fri, 06 Jun 2014 10:10:24 + Mikko Aarnos via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hello all, I have a program which works perfectly when compiled without -release: parser a implies b equivalent not b implies not a Input: ((a implies b) equivalent ((not b)

Re: Don't Understand why Phobos Auto-Tester fails for PR #3606

2014-06-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 07 Jun 2014 08:56:37 + Nordlöw via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: My recent https://github.com/D-Programming-Language/dmd/pull/3606 fails in all the Auto-Testers but I don't understand why. Running make unittest locally in phobos using my locally

Re: array as parameter

2014-06-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 07 Jun 2014 20:56:13 + Paul via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Dynamic array is really reference. Right? But why modification of parameter in this case does not work: void some_func(string[] s) { s ~= xxx; s ~= yyy; } but this works: void

Re: Conversion string-int

2014-06-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 07 Jun 2014 20:53:02 + Paul via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I can not understand, why this code works: char s[2] = ['0', 'A']; string ss = to!string(s); writeln(parse!uint(ss, 16)); but this can deduces template: char s[2]

Re: Basic dynamic array question. Use of new versus no new.

2014-06-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 11 Jun 2014 02:30:00 + WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: In Mr. Cehreli's book it says Additionally, the length of dynamic arrays can be changed by assigning a value to this property: int[] array; // initially empty array.length = 5;

Re: Multiple alias this failed workaround...obscure error message

2014-06-11 Thread Jonathan M Davis via Digitalmars-d-learn
Sent: Wednesday, June 11, 2014 at 8:07 PM From: matovitch via Digitalmars-d-learn digitalmars-d-learn@puremagic.com To: digitalmars-d-learn@puremagic.com Subject: Multiple alias this failed workaround...obscure error message I was looking for a workaround to multiple alias this (or

Re: Multiple alias this failed workaround...obscure error message

2014-06-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 11 Jun 2014 23:01:31 + matovitch via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: About alias working with identifier but not with (runtime) expression. Alias should work with compile time expression like map!(x=2*x) right ? So a static cast should work isn't it ?

Re: Does __gshared have shared semantics?

2014-06-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 14 Jun 2014 01:24:03 + Mike Franklin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: In other words, is 'shared __gshared' redundant? Redundant? Not exactly. __gshared makes it so that the variable is treated like a C variable - it's not in TLS - but its _type_ is

Re: Subclass of Exception

2014-06-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 14 Jun 2014 11:59:52 + Paul via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: One stupid question: in Python subclassing of Exception looks like: class MyError(Exception): pass but in D, if I'm right, we should write more code: class MyError : Exception {

Re: '!' and naming conventions

2014-06-18 Thread Jonathan M Davis via Digitalmars-d-learn
Sent: Wednesday, June 18, 2014 at 11:02 PM From: Brad Anderson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com To: digitalmars-d-learn@puremagic.com Subject: Re: '!' and naming conventions There is a style guide on the website: http://dlang.org/dstyle.html Personally I just

Re: how to resolve matches more than one template declaration?

2014-06-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Fri, 20 Jun 2014 20:40:49 + Juanjo Alvarez via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi, Newbie question: void foo(S)(S oneparam){} void foo(S)(S oneparam, int anotherParam){} alias fooStr = foo!string; Gives: Error: template test.foo matches more than one

Re: How to free memory of an associative array

2014-06-24 Thread Jonathan M Davis via Digitalmars-d-learn
Sent: Tuesday, June 24, 2014 at 11:12 AM From: Mark Isaacson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com To: digitalmars-d-learn@puremagic.com Subject: How to free memory of an associative array How can I free the memory used by an associative array? I need to be able to

Re: Assosiative array pop

2014-06-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 25, 2014 09:30:48 seany via Digitalmars-d-learn wrote: Given an assosiative array : int[string] k, is there a way (either phobos or tango) to pop the first element of this array and append it to another array? I can come up with a primitive soluiton: int[string] k; //

Re: integer out of range

2014-07-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Thu, 03 Jul 2014 10:24:26 + pgtkda via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 3 July 2014 at 10:22:14 UTC, ponce wrote: On Thursday, 3 July 2014 at 10:15:25 UTC, pgtkda wrote: why is this possible? int count = 50_000_000; int is always 4

Re: Setting dates

2014-07-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 11, 2014 04:01:24 Joel via Digitalmars-d-learn wrote: I've been trying to set a date for my program (a small struct): import std.datetime; auto date = cast(DateTime)Clock.currTime(); setDate(date.day, date.month, date.year); Problem is that day month are not integers. And

Re: get number of items in DList

2014-07-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Fri, 11 Jul 2014 07:46:37 -0700 H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Fri, Jul 11, 2014 at 10:23:58AM -0300, Ary Borenszweig via Digitalmars-d-learn wrote: On 7/11/14, 4:46 AM, bearophile wrote: pgtkda: How can i get the number of items which

Re: get os thread handles

2014-07-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, 20 July 2014 at 09:34:46 UTC, Sean Campbell wrote: How do i get an os thread handle from a thread object. or are d thread not wrapped os threads. They do wrap OS threads, but they encapsulate them in a cross-platform manner, and looking over Thread, it doesn't look like anything

Re: get os thread handles

2014-07-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, 20 July 2014 at 10:03:47 UTC, Sean Campbell wrote: On Sunday, 20 July 2014 at 09:53:52 UTC, Jonathan M Davis wrote: On Sunday, 20 July 2014 at 09:34:46 UTC, Sean Campbell wrote: How do i get an os thread handle from a thread object. or are d thread not wrapped os threads. They do

Re: myrange.at(i) for myrange.dropExactly(i).front

2014-07-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, 25 July 2014 at 21:33:23 UTC, Timothee Cour via Digitalmars-d-learn wrote: Is there a function for doing this? myrange.at(i) (with meaning of myrange.dropExactly(i).front) it's a common enough operation (analog to myrange[i]; the naming is from C++'s std::vectorT::at) That would

Re: myrange.at(i) for myrange.dropExactly(i).front

2014-07-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, 26 July 2014 at 00:28:32 UTC, Ary Borenszweig wrote: On 7/25/14, 6:39 PM, Jonathan M Davis wrote: On Friday, 25 July 2014 at 21:33:23 UTC, Timothee Cour via Digitalmars-d-learn wrote: Is there a function for doing this? myrange.at(i) (with meaning of myrange.dropExactly(i).front)

Re: why does isForwardRange work like this?

2014-07-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 31 July 2014 at 20:34:42 UTC, Vlad Levenfeld wrote: What's the rationale behind stating the condition this way as opposed to, say, is (typeof(R.init.save)) == R) || is ((typeof(R.init.save()) == R) so that member fields as well as @property and non-@property methods will match

Re: why does isForwardRange work like this?

2014-07-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 31 July 2014 at 22:21:10 UTC, Vlad Levenfeld wrote: Yes, I see the problem now. I can't think of any reason why I'd want to make save anything but a function (especially since `save` is a verb) but I guess someone out there might have a good one. It's Andrei's fault. I'm not

Re: why does isForwardRange work like this?

2014-08-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, 1 August 2014 at 11:51:55 UTC, Marc Schütz wrote: On Friday, 1 August 2014 at 04:52:35 UTC, Jonathan M Davis wrote: On Thursday, 31 July 2014 at 22:21:10 UTC, Vlad Levenfeld wrote: Yes, I see the problem now. I can't think of any reason why I'd want to make save anything but a

Re: why does isForwardRange work like this?

2014-08-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, 1 August 2014 at 19:59:16 UTC, Jonathan M Davis wrote: But since dup and idup aren't being implemented by lots of different people like the range API is, changing those doesn't risk breaking code where folks made it a variable. Well, I probably shouldn't put it quite that way,

Re: unittest affects next unittest

2014-08-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Fri, 01 Aug 2014 23:09:37 + sigod via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Code: http://dpaste.dzfl.pl/51bd62138854 (It was reduced by DustMite.) Have I missed something about structs? Or this simply a bug? Don't do this with a member variable: private Node *

Re: unittest affects next unittest

2014-08-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 5 August 2014 at 17:41:06 UTC, Marc Schütz wrote: On Tuesday, 5 August 2014 at 15:39:55 UTC, sigod wrote: On Saturday, 2 August 2014 at 06:46:04 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: On Fri, 01 Aug 2014 23:09:37 + sigod via Digitalmars-d-learn digitalmars-d

Re: unittest affects next unittest

2014-08-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 02:12:16 UTC, Era Scarecrow wrote: On Tuesday, 5 August 2014 at 17:41:06 UTC, Marc Schütz wrote: It's a consequence of the fact that every type in D has a default initializer which is known at compile time. Then doesn't this mean it should pop out a warning in

Re: private selective imports

2014-08-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 18:33:23 UTC, Dicebot wrote: Most voted DMD bug : https://issues.dlang.org/show_bug.cgi?id=314 Yeah, it's why I'd suggest that folks not use selective imports right now. But people seem to really love the feature, so they use it and keep running into this

Re: private selective imports

2014-08-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 19:35:02 UTC, Dicebot wrote: On Wednesday, 6 August 2014 at 19:31:04 UTC, Jonathan M Davis wrote: On Wednesday, 6 August 2014 at 18:33:23 UTC, Dicebot wrote: Most voted DMD bug : https://issues.dlang.org/show_bug.cgi?id=314 Yeah, it's why I'd suggest that folks

Re: Removing an element from a list or array

2014-08-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 19:01:26 UTC, Patrick wrote: I feel dumb. I've been searching for how to do this, and each page or forum entry I read makes me more confused. Let's say I have a list of values (Monday, Tuesday, Wednesday, Thursday, Friday). I can store this list in an Slist,

Re: opApply outside of struct/class scope

2014-08-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, 10 August 2014 at 18:45:00 UTC, Freddy wrote: Is there any why i can put a opApply outside of a struct scope No overloaded operators in D can be put outside of a struct or class. They have to be member functions. - Jonathan M Davis

Re: opApply outside of struct/class scope

2014-08-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, 10 August 2014 at 19:01:18 UTC, Era Scarecrow wrote: On Sunday, 10 August 2014 at 18:58:50 UTC, Jonathan M Davis wrote: No overloaded operators in D can be put outside of a struct or class. They have to be member functions. If I remember right, opApply was somewhat broken and only

Re: opApply outside of struct/class scope

2014-08-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, 10 August 2014 at 22:03:28 UTC, Era Scarecrow wrote: On Sunday, 10 August 2014 at 21:57:29 UTC, Jonathan M Davis wrote: I'm not aware of opApply being broken, but I never use it, I remember very specifically it was brought up, that opApply was not working correctly and you could

Re: implicit conversion

2014-08-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Tue, 12 Aug 2014 06:21:17 + uri via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi, I'm trying to allow implicit conversions for my own type happening. I have the following: import std.math; import std.traits; struct S(T) if(isFloatingPoint!T) { T

Re: implicit conversion

2014-08-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Tue, 12 Aug 2014 13:17:37 + Meta via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 12 August 2014 at 06:37:45 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: The problem is that isNaN is now templatized, and its constraint uses isFloatingPoint, which

Re: implicit conversion

2014-08-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 12 August 2014 at 15:39:09 UTC, Meta wrote: What I mean is that this breaks the Liskov Substitution Principle, which alias this should obey, as it denotes a subtype. Since S!float has an alias this to float, it should behave as a float in all circumstances where a float is

Re: implicit conversion

2014-08-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 12 August 2014 at 19:03:58 UTC, H. S. Teoh via Digitalmars-d-learn wrote: tl;dr: there are so many ways template code can go wrong, that I don't it justifies blaming alias this for problems. Allowing implicit conversions makes the problem much worse IMHO. It makes it far too easy

Re: drop* and take* only for specific element values

2014-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 13 Aug 2014 14:28:29 + Meta via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wednesday, 13 August 2014 at 12:37:34 UTC, Nordlöw wrote: Are there variants of drop* and take* that only drop element if its equal to a value kind of like strip does? If not I

Re: drop* and take* only for specific element values

2014-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 13 Aug 2014 07:45:17 -0700 Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wed, 13 Aug 2014 14:28:29 + Meta via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wednesday, 13 August 2014 at 12:37:34 UTC, Nordlöw wrote

Re: String Prefix Predicate

2014-08-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 14 August 2014 at 17:41:08 UTC, Nordlöw wrote: On Thursday, 14 August 2014 at 17:33:41 UTC, Justin Whear wrote: std.algorithm.startsWith? Should auto-decode, so it'll do a What about https://github.com/D-Programming-Language/phobos/pull/2043 Auto-decoding should be avoided

Re: Appender is ... slow

2014-08-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 14 August 2014 at 17:16:42 UTC, Philippe Sigaud wrote: From time to time, I try to speed up some array-heavy code by using std.array.Appender, reserving some capacity and so on. It never works. Never. It gives me executables that are maybe 30-50% slower than bog-standard array

Re: Appender is ... slow

2014-08-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 14 August 2014 at 19:29:28 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: It sounds like you're trying to use it as a way to manage reusing the array, and I have no idea how it works for that. There is a misunderstanding there: I'm using clear only to flush the state at the

Re: Appender is ... slow

2014-08-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 14 August 2014 at 19:47:33 UTC, Brad Anderson wrote: On Thursday, 14 August 2014 at 19:10:18 UTC, Jonathan M Davis wrote: I've never really tried to benchmark it, but it was my understanding that the idea behind Appender was to use it to create the array when you do that via a lot

Re: Appender is ... slow

2014-08-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 14 August 2014 at 21:00:55 UTC, Jonathan M Davis wrote: On Thursday, 14 August 2014 at 19:47:33 UTC, Brad Anderson wrote: On Thursday, 14 August 2014 at 19:10:18 UTC, Jonathan M Davis wrote: I've never really tried to benchmark it, but it was my understanding that the idea behind

Re: Appender is ... slow

2014-08-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 14 August 2014 at 21:11:51 UTC, safety0ff wrote: IIRC it manages the capacity information manually instead of calling the runtime which reduces appending overhead. That would make some sense, though it must be completely avoiding ~= then and probably is even GC-mallocing the

Re: Appender is ... slow

2014-08-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 14 August 2014 at 21:34:04 UTC, Jonathan M Davis wrote: On Thursday, 14 August 2014 at 21:11:51 UTC, safety0ff wrote: IIRC it manages the capacity information manually instead of calling the runtime which reduces appending overhead. That would make some sense, though it must be

Re: Appender is ... slow

2014-08-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 14 August 2014 at 17:16:42 UTC, Philippe Sigaud wrote: From time to time, I try to speed up some array-heavy code by using std.array.Appender, reserving some capacity and so on. It never works. Never. It gives me executables that are maybe 30-50% slower than bog-standard array

Re: @safe, pure and nothrow at the beginning of a module

2014-08-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, 15 August 2014 at 16:54:54 UTC, Philippe Sigaud wrote: So I'm trying to use @safe, pure and nothrow. If I understand correctly Adam Ruppe's Cookbook, by putting @safe: pure: nothrow: at the beginning of a module, I distribute it on all definitions, right? Even methods, inner

Re: Appender is ... slow

2014-08-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, 15 August 2014 at 16:48:10 UTC, monarch_dodra wrote: If you are using raw GC arrays, then the raw append operation will, outweigh the relocation cost on extension. So pre-allocation wouldn't really help in this situation (though the use of Appender *should*) Is that because it's

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 16 Aug 2014 14:39:00 +0200 Artur Skawina via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 08/16/14 13:58, Philippe Sigaud via Digitalmars-d-learn wrote: On Sat, Aug 16, 2014 at 1:30 PM, Artur Skawina via Digitalmars-d-learn

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, 16 August 2014 at 20:48:25 UTC, monarch_dodra wrote: On Saturday, 16 August 2014 at 19:30:16 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: On Sat, 16 Aug 2014 14:39:00 +0200 Artur Skawina via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: @safe, @trusted

Re: Static function at module level

2014-08-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Mon, 18 Aug 2014 01:32:40 + Phil Lavoie via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Ok, so after years of D usage I just noticed that this is valid D (compiles anyways): static void myFunc() {} What is a static function at module level exactly? In C, that means

Re: In the new D release why use free functions instead of properties?

2014-08-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, 18 August 2014 at 21:02:09 UTC, Gary Willoughby wrote: In the new D release there have been some changes regarding built-in types. http://dlang.org/changelog.html?2.066#array_and_aa_changes I would like to learn why this has been done like this and why it is desired to be free

Re: In the new D release why use free functions instead of properties?

2014-08-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 19 August 2014 at 16:28:54 UTC, monarch_dodra wrote: Actually, the new free functions *are* properties. All that you just declared is valid, but we never got around to doing it. Walter (If I remember correctly) was opposed. So right now, even if dup is a free function,

Re: shared and idup

2014-08-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 19 August 2014 at 19:00:49 UTC, Marc Schütz wrote: On Tuesday, 19 August 2014 at 17:56:31 UTC, Low Functioning wrote: shared int[] foo; auto bar() { foo ~= 42; return foo.idup; } Error: cannot implicitly convert element type shared(int) to immutable in foo.idup Is

Re: Auto attributes for functions

2014-08-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 20 Aug 2014 01:38:52 + uri via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi all, Bit new to D so this might be a very naive question... Can the compiler auto infer function attributes? I am often adding as many attributes as possible and use the compiler to

Re: Can you explain this?

2014-08-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 20:12:58 UTC, Justin Whear wrote: On Wed, 20 Aug 2014 20:01:03 +, Colin wrote: It looks veryhacky. I see 3 distinct parts playing a role in my confusion: A) The 'is' keyword. What does it do when you have is(expression); B) typeof( expression ); whats

Re: Can you explain this?

2014-08-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 21:06:49 UTC, monarch_dodra wrote: On Wednesday, 20 August 2014 at 20:39:42 UTC, Jonathan M Davis wrote: is(typeof(foo)) and __traits(compiles, foo) are not the same. The first tests for the existence of the symbol, whereas the second checks whether the code

Re: RAII limitations in D?

2014-08-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, 22 August 2014 at 03:00:01 UTC, Timothee Cour via Digitalmars-d-learn wrote: On Thu, Aug 21, 2014 at 7:26 PM, Dicebot via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: http://dlang.org/phobos/std_typecons.html#.RefCounted That doesn't work with classes though; is

Re: Why no multiple-dispatch?

2014-08-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, 24 August 2014 at 23:42:51 UTC, Aerolite wrote: Hey all, I was surprised to learn yesterday that D does not actually support Multiple-Dispatch, also known as Multimethods. Why is this? Support for this feature is already present in Scala, C# 4.0, Groovy, Clojure, etc... Would it not

Re: Error with constraints on a templated fuction

2014-08-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Mon, 25 Aug 2014 15:48:10 + Jeremy DeHaan via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I've done things like this before with traits and I figured that this way should work as well, but it gives me errors instead. Perhaps someone can point out my flaws.

  1   2   3   4   5   6   7   8   9   10   >