Re: Dynamically Sized Structs

2014-04-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thu, 17 Apr 2014 14:40:25 -0400, Kagamin s...@here.lot wrote: So you assert that variable length structs can't be allocated on heap and sokoban example is a wrong example of variable length struct usage? And how heap indirection is different from stack indirection? It's still

Re: std.file.read returns void[] why?

2014-04-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thu, 17 Apr 2014 17:04:25 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Thursday, 17 April 2014 at 12:59:20 UTC, Steven Schveighoffer wrote: It was never possible. You must explicitly cast to void[]. void[] makes actually little sense as the result of whole-file read that

Re: std.file.read returns void[] why?

2014-04-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 18 Apr 2014 02:04:16 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Thursday, 17 April 2014 at 21:27:44 UTC, Steven Schveighoffer wrote: On Thu, 17 Apr 2014 17:04:25 -0400, monarch_dodra monarchdo...@gmail.com wrote: void[] will only make sense once you've accepted that

Re: Dynamically Sized Structs

2014-04-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 18 Apr 2014 00:05:03 -0400, Kagamin s...@here.lot wrote: Well, it's proof of concept of bound checked variable-size struct, I wrote it in a minute. It even compiles and runs. Please take no offense :) I just was pointing out a difference between a hand-managed and hand-written

Re: Dynamically Sized Structs

2014-04-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 18 Apr 2014 12:59:35 -0400, Kagamin s...@here.lot wrote: Oh, and I don't believe, that a variable-size struct can be emplaced inside fixed-size struct or class. Only as a smart pointer from the example. It goes at the end. Then you need to allocate the whole thing with that in

Re: Reducing an array

2014-04-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thu, 17 Apr 2014 09:46:25 -0400, Tim Holzschuh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi there, I try to remove all equal elements of an array, thus [2,2] -- [2]. I thought this maybe would be possible with std.algorithm.reduce, but at least the way I tried it

Re: toString() through interface

2014-04-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sat, 19 Apr 2014 20:45:50 -0400, Adam D. Ruppe destructiona...@gmail.com wrote: On Sunday, 20 April 2014 at 00:35:30 UTC, David Held wrote: Since all implementations of an interface must derive from Object That's not true. They can also come from IUnknown or a C++ interface. This is

Re: toString() through interface

2014-04-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sat, 19 Apr 2014 20:51:49 -0400, David Held d...@wyntrmute.com wrote: On 4/19/2014 5:35 PM, David Held wrote: interface Foo { } class Bar : Foo { override string toString() pure const { return Bar; } } void main() { Foo foo = new Bar; foo.toString(); } To make things more

Re: Regarding foreach loop index ranges

2014-04-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 21 Apr 2014 07:49:03 -0400, bearophile bearophileh...@lycos.com wrote: In this case I am not sure about bug reports, so I ask here. In this program the first loop doesn't compile, giving a nice error: test.d(3,5): Error: index type 'ubyte' cannot cover index range 0..300 If you

Re: Best way to check for an element in an array?

2014-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 21 Apr 2014 23:25:39 -0400, Taylor Hillegeist taylorh...@gmail.com wrote: So I find myself Doing this kind of thing very frequently. I have a Array of Somethings and i want to see if something specific is inside the array. I wrote a template for it. but is this the best way to do

Re: Named template constraints

2014-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 22 Apr 2014 10:58:41 -0400, Andrej Mitrovic via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 4/22/14, Tim Holzschuh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: What does (inout int = 0) mean/affect here? This was asked recently, see my

Re: Named template constraints

2014-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 22 Apr 2014 11:15:14 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Tuesday, 22 April 2014 at 15:06:34 UTC, Steven Schveighoffer wrote: Note, is the r2 = R.init needed? Not sure. Yes: It R2 has no default init, or is an immutable, then that line will fail to compile. I

Re: Array of interface only with cast()?

2014-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 22 Apr 2014 11:19:57 -0400, Andre an...@s-e-a-p.de wrote: Hi, I just stumbled about this issue with array of interface. I want to pass several objects (C and D) which shares the same interface A. It seems somehow cumbersome that it only works if there is a cast on the first element of

Re: The lifetime of reduce's internal seed

2014-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 22 Apr 2014 14:17:57 -0400, Ali Çehreli acehr...@yahoo.com wrote: I don't think there is slicing an rvalue though. (?) reduce() is taking a copy of the seed and then returning a slice to it because the user slices it in their lambda. It effectively does the following, which

Re: Named template constraints

2014-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 22 Apr 2014 11:36:07 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Tuesday, 22 April 2014 at 15:30:36 UTC, Steven Schveighoffer wrote: Also, an immutable can be initialized that way: immutable int[] = int[].init; Isn't that exactly R.init ? Yes, you said if it's an

Re: The lifetime of reduce's internal seed

2014-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 22 Apr 2014 14:47:19 -0400, monarch_dodra monarchdo...@gmail.com wrote: In this case no, but; // int[1] foo(); int[] a = foo(); // *is* slicing an rvalue, and it *does* compile. I don't think there needs to be escape analysis to catch this. Oh yeah, that's bad. -Steve

Re: Named template constraints

2014-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 22 Apr 2014 14:50:44 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Tuesday, 22 April 2014 at 18:35:58 UTC, Steven Schveighoffer wrote: On Tue, 22 Apr 2014 11:36:07 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Tuesday, 22 April 2014 at 15:30:36 UTC, Steven

Re: Variable Naming Issue (Conflicts?)

2014-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 22 Apr 2014 15:35:33 -0400, Casey sybra...@gmail.com wrote: If I prefix all of the generated variables with an underscore, it works fine. It looks like the variable delete is the issue. To me, it looks like it's expecting some sort of delete method. delete is a keyword, it cannot

Re: Undefined symbol ModuleInfoZ when including a SWIG generated module

2014-04-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wed, 23 Apr 2014 20:34:11 -0400, Walter Gray walter.r.g...@gmail.com wrote: Hi there, I'm currently trying to set up a small demo project using the Leap Motion API in D. I've run SWIG with -d -d2, and created the intermediate C++ DLL along with a pair of .d files, leap.d and

Re: Is this a bug?

2014-04-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 28 Apr 2014 06:04:53 -0400, John Colvin john.loughran.col...@gmail.com wrote: On Monday, 28 April 2014 at 09:36:08 UTC, Andrey wrote: not a bug. b.f[10] is indexing the pointer to the array, not the array itself. b.f[0][10] is indexing the array (with the 10), but I would argue it

Re: Is this a bug?

2014-04-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 29 Apr 2014 03:43:54 -0400, Andrey n...@none.no wrote: btw, short a,b,c; a = b + c; //error: cannot implicitly convert expression of type 'int' to 'short' Guys!! Tell me that I have an old slutty version of the compiler... No. It's due to integer promotion. All operations are

Re: why arithmetic for bytes different than for ints?

2014-05-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 02 May 2014 16:32:54 -0400, Vlad Levenfeld vlevenf...@gmail.com wrote: Dunno why I didn't try it earlier, but splitting it across lines like y += 1; y %= 2; assert (y == 1); works. So, bug, then? Yes. -Steve

Re: Any chance to avoid monitor field in my class?

2014-05-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wed, 07 May 2014 10:44:55 -0400, Yuriy yuriy.gluk...@gmail.com wrote: Hello, is there a way of reducing size of an empty class to just vtbl? I tried to declare it as extern(C++) which works, but has a nasty side effect of limited mangling. The de-facto minimum size of a class is 16

Re: Any chance to avoid monitor field in my class?

2014-05-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thu, 08 May 2014 13:21:07 -0400, Yuriy yuriy.gluk...@gmail.com wrote: On Thursday, 8 May 2014 at 14:57:37 UTC, Steven Schveighoffer wrote: The de-facto minimum size of a class is 16 bytes, due to the minimum block size of the heap. 8 bytes vtbl pointer on 64-bit systems would still

Re: Any chance to avoid monitor field in my class?

2014-05-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thu, 08 May 2014 14:17:42 -0400, Yuriy yuriy.gluk...@gmail.com wrote: On Thursday, 8 May 2014 at 17:49:01 UTC, Steven Schveighoffer wrote: To what end? What are you trying to save? I'm trying to reimplement std.variant in a nice OOP way, that supports CTFE, zero-size and a minimal amount

Re: Any chance to avoid monitor field in my class?

2014-05-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thu, 08 May 2014 15:47:46 -0400, Yuriy yuriy.gluk...@gmail.com wrote: But my question more was about where do you plan to put so many of these objects that you will save a significant amount of bytes, aside from the heap (which already uses 16-byte blocks). Hm.. Stack/emplace, How many

Re: Any chance to avoid monitor field in my class?

2014-05-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thu, 08 May 2014 17:05:56 -0400, Yuriy yuriy.gluk...@gmail.com wrote: How many of these? In order to justify saving 8 bytes per instance, you have have a lot. I don't see emplacing thousands or tens of thousands of objects on the stack. Ok, i guess i have to agree with you. But. Why are

Re: why can't I call const methods on shared objects?

2014-05-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 09 May 2014 17:37:35 -0400, Vlad Levenfeld vlevenf...@gmail.com wrote: Error: non-shared const method is not callable using a shared mutable object Why not? If the method is const, it can't modify the object anyway. Non-shared methods cannot be called on shared objects.

Re: why can't I call const methods on shared objects?

2014-05-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 09 May 2014 17:45:37 -0400, Vlad Levenfeld vlevenf...@gmail.com wrote: Is there any way to declare a method as safe regardless of shared/mutability/etc (or some other way to avoid cast(Type)object.property every time I want to check a property which won't affect any state)? Not

Re: Array!T and find are slow

2014-05-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wed, 14 May 2014 19:50:33 -0400, Meta jared...@gmail.com wrote: On Wednesday, 14 May 2014 at 22:32:01 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: Yeah, much as Andrei would hate to hear it (enforce was his idea, and he quite likes the idiom), the fact that lazy is so inefficient

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

2014-05-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wed, 14 May 2014 05:13:42 -0400, Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: 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

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

2014-05-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thu, 15 May 2014 11:37:07 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Thursday, 15 May 2014 at 13:26:45 UTC, Steven Schveighoffer wrote: On Wed, 14 May 2014 05:13:42 -0400, Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wed, 14 May 2014

Re: Objects(from classes) at Compile time? no gc

2014-05-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 16 May 2014 02:31:18 -0400, Jacob Carlborg d...@me.com wrote: On 16/05/14 06:59, Taylor Hillegeist wrote: The subject says it all really. i have this example: import core.memory; class fruit{ int value=5; public int getvalue(){ return value; } } int main(string[] args)

Re: Array!T and find are slow

2014-05-16 Thread Steven Schveighoffer via Digitalmars-d-learn
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 via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Isn't there a way in D to just expand: enforce(cond,

Re: idup class

2014-05-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 16 May 2014 16:28:41 -0400, Joshua Niehus jm.nie...@gmail.com wrote: trying to follow: http://ddili.org/ders/d.en/class.html //--- OSX 10.9 DMD 2.065 module test; class Foo { int num; this(int num) { this.num = num; } Foo dup() const {

Re: idup class

2014-05-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 16 May 2014 16:36:36 -0400, Ali Çehreli acehr...@yahoo.com wrote: Beat you by 8 seconds :) -Steve

Re: string-ish range/stream from curl ubyte[] chunks?

2014-05-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 16 May 2014 16:57:41 -0400, Vlad b100d...@gmail.com wrote: Hello D programmers, I am toying with writing my own HTML parser as a pet project, and I strive to have a range API for the tokenizer and the parser output itself. However it occurs to me that in real-life browsers the

Re: string-ish range/stream from curl ubyte[] chunks?

2014-05-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 16 May 2014 18:36:02 -0400, Vlad b100d...@gmail.com wrote: On Friday, 16 May 2014 at 21:35:04 UTC, Steven Schveighoffer wrote: On Fri, 16 May 2014 16:57:41 -0400, Vlad b100d...@gmail.com wrote: Q: Is anything like this already in use somewhere in the standard library or a project

Re: Is it possible to assumeSafeAppend malloced memory?

2014-05-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 19 May 2014 09:44:44 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Monday, 19 May 2014 at 06:08:18 UTC, Ali Çehreli wrote: We know that most of the time memory is allocated more than the requested amount. Is there a way to take advantage of that extra trailing space? (And

Re: Is it possible to assumeSafeAppend malloced memory?

2014-05-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 19 May 2014 14:46:59 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Monday, 19 May 2014 at 13:55:00 UTC, Steven Schveighoffer wrote: On Monday, 19 May 2014 at 06:08:18 UTC, Ali Çehreli wrote: This issue puts std.array.array to a disadvantage compared to proper slices

Re: Is there any way to differentiate between a type and an alias?

2014-05-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sun, 25 May 2014 04:04:09 -0700, Rene Zwanenburg renezwanenb...@gmail.com wrote: Given alias GLenum = uint; void glSomeFunction(GLenum, uint); Now, is there some way to differentiate between GLenum and uint when using ParameterTypeTuple!glSomeFunction? I'm writing a function which

Re: Is this a bug or illegal code?

2014-05-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thu, 29 May 2014 10:45:28 -0400, safety0ff safety0ff@gmail.com wrote: //*** CODE ** mixin(version = foo;); version(foo) { void main(){} } //** END CODE *** If it's illegal in D, what is the reason where is documented? The reason I was considering such a

Re: enums

2014-05-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 30 May 2014 13:34:38 -0400, Philippe Sigaud via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Fri, May 30, 2014 at 7:28 PM, Ali Çehreli digitalmars-d-learn@puremagic.com wrote: On 05/30/2014 08:30 AM, Russel Winder via Digitalmars-d-learn wrote: enum

Re: Hiding types

2014-05-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 30 May 2014 15:50:41 -0400, Philippe Sigaud philippe.sig...@gmail.com wrote: I'm trying to 'hide' a type, so as not to see it outside its module. I want to control the way it's created and used. I know of Voldemort types and '@disable this', but for now I'm just trying to use

Re: Hiding types

2014-05-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 30 May 2014 16:09:59 -0400, Philippe Sigaud philippe.sig...@gmail.com wrote: On Friday, 30 May 2014 at 20:02:40 UTC, Steven Schveighoffer wrote: If you want an opaque struct, you need to return it by pointer. What do you mean? Like this? Hidden* foo() { return new Hidden();} ?

Re: delegate issue

2014-06-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 02 Jun 2014 10:37:07 -0400, captaindet 2k...@gmx.net wrote: On 2014-06-02 08:03, MrSmith wrote: On Monday, 2 June 2014 at 06:56:54 UTC, captaindet wrote: hi, i stumbled upon something weird - it looks like a bug to me but maybe it is a feature that is unclear to me. so i know i

Re: for, foreach identifier allowed in c throws error in d

2014-06-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 02 Jun 2014 15:21:06 -0400, Logesh Pillay lp.court.jes...@gmail.com wrote: It is common in a recursive function to amend a global array using the function parameter to refer to the element eg int[10]; void foo (int i) { foreach (x; 0 .. 9) { t[i] = x; foo (); C in

Re: for, foreach identifier allowed in c throws error in d

2014-06-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 02 Jun 2014 15:47:02 -0400, Logesh Pillay lp.court.jes...@gmail.com wrote: Issue has nothing to do with recursion. That's only where I keep seeing it. eg a function to generate combinations. import std.stdio; int[3] t; void foo (int i) { if (i == 3) writef(%s\n, t);

Re: for, foreach identifier allowed in c throws error in d

2014-06-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 02 Jun 2014 15:58:01 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: I'm trying to think of a way to do this without loops, but not sure. I'm surprised, I looked for some kind of apply function like map, but just calls some function with each element in the range.

Re: for, foreach identifier allowed in c throws error in d

2014-06-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 02 Jun 2014 17:25:24 -0400, John Colvin john.loughran.col...@gmail.com wrote: On Monday, 2 June 2014 at 20:23:12 UTC, Steven Schveighoffer wrote: On Mon, 02 Jun 2014 15:58:01 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: I'm trying to think of a way to do this without

Re: Delegate, scope and associative array

2014-06-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 02 Jun 2014 19:43:58 -0400, Rene Zwanenburg renezwanenb...@gmail.com wrote: On Monday, 2 June 2014 at 20:09:12 UTC, Edwin van Leeuwen wrote: I'm probably missing something basic, but I am confused by what is going on in the following code. unittest { size_t delegate()[size_t]

Re: When is a slice not a slice?

2014-06-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thu, 05 Jun 2014 15:56:00 -0400, Philippe Sigaud via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: enum b = DataAndView(1); assert (!sameTail(b.data, b.view)); I suppose it's because enums are manifest constants: the value they represent is 'copy-pasted'

Re: When is a slice not a slice?

2014-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 06 Jun 2014 06:14:30 -0400, Rene Zwanenburg renezwanenb...@gmail.com wrote: On Friday, 6 June 2014 at 08:17:43 UTC, Alix Pexton wrote: On 05/06/2014 8:58 PM, Steven Schveighoffer wrote: Yes, this should work (and execute the initializer at compile time): static b = ... Ah, the

Re: splitter for strings

2014-06-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 09 Jun 2014 07:04:11 -0400, Chris wend...@tcd.ie wrote: On Monday, 9 June 2014 at 10:54:09 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 10:23:16 UTC, Chris wrote: Ok, thanks. I'll keep that in mind for the next version. Seems to me to also work with 2.065 and 2.064. From

Re: splitter for strings

2014-06-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 09 Jun 2014 10:39:39 -0400, Chris wend...@tcd.ie wrote: Atm, I have auto parts = appender!(string[]); w.splitter('-').filter!(a = !a.empty).copy(parts); Which looks more elegant and gives me what I want. IMO, the module that handles the splitting of hyphenated words should be able

Re: splitter for strings

2014-06-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 09 Jun 2014 12:06:13 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Monday, 9 June 2014 at 15:54:29 UTC, Steven Schveighoffer wrote: On Mon, 09 Jun 2014 11:49:29 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Monday, 9 June 2014 at 14:21:21 UTC, Steven Schveighoffer

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

2014-06-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 10 Jun 2014 23:28:16 -0400, Kapps opantm2+s...@gmail.com wrote: On Wednesday, 11 June 2014 at 02:30:01 UTC, WhatMeWorry 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

Re: Cannot understand deprecation message recently added to Phobos

2014-06-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wed, 11 Jun 2014 16:59:24 -0400, Nordlöw per.nord...@gmail.com wrote: Can somebody explain the meaning of split in the error message Deprecation: function core.time.Duration.weeks is deprecated - Please use split instead. weeks was too frequently confused for total!weeks. given by

Re: Cannot understand deprecation message recently added to Phobos

2014-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wed, 11 Jun 2014 17:06:41 -0400, Kapps opantm2+s...@gmail.com wrote: On Wednesday, 11 June 2014 at 20:59:25 UTC, Nordlöw wrote: Can somebody explain the meaning of split in the error message Deprecation: function core.time.Duration.weeks is deprecated - Please use split instead. weeks

Re: Is it normal that unittests of phobos are executed with my project build?

2014-06-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sat, 14 Jun 2014 10:32:04 -0400, Xavier Bigand flamaros.xav...@gmail.com wrote: I get a failure on a test in format.d when I build my own project with unittest. I though importing phobos header would not regenerate their unittest modules. Any idea of what can cause this issue? I

Re: interface is interface

2014-06-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 17 Jun 2014 15:02:33 -0400, Pavel phond...@gmail.com wrote: Hello! import std.stdio; interface I { } interface B : I { void test(); } interface C : I { void test1(); } class A : B, C { override void test() {} override void test1() {} } void main() {

Re: Run child process with null stdin/stdout

2014-06-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wed, 18 Jun 2014 16:15:40 -0400, David Nadlinger c...@klickverbot.at wrote: On Wednesday, 18 June 2014 at 20:00:43 UTC, Justin Whear wrote: For POSIX, seems like you could pass `File(/dev/null, r)` for stdin and `File(/dev/null, w)`. On Windows I believe you can use `File (nul)` for the

Re: Question about iteger literals

2014-06-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sun, 22 Jun 2014 08:23:45 -0400, Uranuz neura...@gmail.com wrote: If these rules are not so clear and have some exceptions (but I don't understand why they are needed) then some documentation needed about this. See integer promotion rules:

Re: Passing around a list of differently typed functions

2014-06-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 23 Jun 2014 14:30:12 -0400, Ali Çehreli acehr...@yahoo.com wrote: On 06/22/2014 11:32 PM, FreeSlave wrote: On Monday, 23 June 2014 at 01:16:49 UTC, Evan Davis wrote: As the subject says, I would like to pass around an array of functions. The trick is, that the functions have

Re: Converting from C const(dchar*) to dstring

2014-06-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 24 Jun 2014 13:37:41 -0400, Danyal Zia catofdan...@yahoo.com wrote: Hi, I like to print the strings from a C function that returns const(dchar*), but I can't make the conversion to dstring. I can convert vice versa by: dstring text = Hello; const(dchar)* str =

Re: Converting from C const(dchar*) to dstring

2014-06-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 24 Jun 2014 14:28:58 -0400, Chris Cain zsh...@gmail.com wrote: On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer wrote: // assuming 0 terminated dstring text = x[0..x.strlen].idup; strlen is only defined for char, not dchar:

Re: Is their a way for a Child process to modify its Parent's environment?

2014-06-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 24 Jun 2014 21:53:51 -0400, WhatMeWorry kc_hea...@yahoo.com wrote: I open a command line window, and run the following 6 line program void main() { string envPath = environment[PATH]; writeln(PATH is: , envPath); envPath ~= r;F:\dmd2\windows\bin; environment[PATH]

Re: Redirect to different overloads at compile time?

2014-06-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sun, 29 Jun 2014 22:24:09 -0400, David Bregman d...@sfu.ca wrote: Suppose I have a C library which implements a function for several types. C doesn't have overloading, so their names will be distinct. extern(C): double foo_double(double); float foo_float(float); Now I want to build a D

Re: linux ipv4 multicast

2014-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/14 10:55 PM, james wrote: I just started doing D networking today, so I may just be doing something wrong / stupid but I can not find the ip_mreq struct anywhere. I ended up just making my own in my module struct ip_mreq { in_addr imr_multiaddr; in_addr

Re: How does GC.addRange work?

2014-09-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/21/14 3:00 PM, Gary Willoughby wrote: On Saturday, 20 September 2014 at 23:08:08 UTC, ketmar via Digitalmars-d-learn wrote: On Sat, 20 Sep 2014 22:21:13 + Gary Willoughby via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: So zeroing values will inform the GC the

Re: can't understand why code do not working

2014-09-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/22/14 4:37 PM, Cliff wrote: Is stdout threadsafe? Yes, stdout is thread safe, it's based on C's stdout which is thread safe. -Steve

Re: Does remove immutability using cast to pass in a function make sense?

2014-09-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/22/14 10:07 PM, AsmMan wrote: I have this array: static immutable string[] months = [jan, fev, ...]; I need to pass it into canFind(). But it doesn't works with immutables so I need to cast it like in canFind(cast(string[]) months, month) to work. There's a reason related to design why it

Re: How to export a deduced template type to the enclosing scope?

2014-09-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/23/14 7:12 PM, Ali Çehreli wrote: Can we get rid of the ResultT template parameter? Tricks with variadic templates, the with statement, etc. come to mind but I could not manage it. I don't think so. yield just returns control back to another fiber. It's not an entry point. What you

Re: Does D has C#'s string.Empty?

2014-09-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/25/14 2:41 AM, SlomoTheBrave wrote: On Thursday, 25 September 2014 at 05:29:37 UTC, AsmMan wrote: Does D has C#'s string.Empty? string.init ? string a; a = string.init; assert( a == ); does the job for the type string at least. null also works. In fact, in the

Re: immutable T.init, and pointers to mutable data

2014-09-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/25/14 5:47 AM, monarch_dodra wrote: I was playing around with how T.init works. And I think I may have found a type loophole. Given that you may initialize a pointer member to the address to a static global: // __gshared int a = 0; struct S { int* p = a; } // Then, in

Re: immutable T.init, and pointers to mutable data

2014-09-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/25/14 9:00 AM, monarch_dodra wrote: On Thursday, 25 September 2014 at 12:46:01 UTC, Steven Schveighoffer wrote: On 9/25/14 5:47 AM, monarch_dodra wrote: I was playing around with how T.init works. And I think I may have found a type loophole. Given that you may initialize a pointer

Re: immutable T.init, and pointers to mutable data

2014-09-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/25/14 10:56 AM, monarch_dodra wrote: On Thursday, 25 September 2014 at 13:37:52 UTC, Steven Schveighoffer wrote: But clearly, any code that results in an immutable pointer to mutable data without casts is incorrect. We should start by outlawing such code, and if there are ways we can

Re: Does D has C#'s string.Empty?

2014-09-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/25/14 8:24 PM, AsmMan wrote: On Thursday, 25 September 2014 at 12:43:57 UTC, Steven Schveighoffer wrote: On 9/25/14 2:41 AM, SlomoTheBrave wrote: On Thursday, 25 September 2014 at 05:29:37 UTC, AsmMan wrote: Does D has C#'s string.Empty? string.init ? string a; a =

Re: A few questions regarding GC.malloc

2014-09-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/25/14 6:03 PM, Sean Kelly wrote: On Thursday, 25 September 2014 at 21:43:53 UTC, monarch_dodra wrote: On Thursday, 25 September 2014 at 20:58:29 UTC, Gary Willoughby wrote: What does BlkAttr.FINALIZE do when used in the GC.malloc call? I have no idea. I think its for classes though,

Re: Can I make a variable public and readonly (outside where was declared) at same time?

2014-09-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/26/14 1:36 PM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: Alternatively, you could create a union with a private and a public member with the same types, but I wouldn't recommend it. Besides, the members would need to have different names: class Foo { union {

Re: A few questions regarding GC.malloc

2014-09-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/26/14 3:24 PM, monarch_dodra wrote: On Friday, 26 September 2014 at 18:03:40 UTC, Steven Schveighoffer wrote: On 9/25/14 6:03 PM, Sean Kelly wrote: On Thursday, 25 September 2014 at 21:43:53 UTC, monarch_dodra wrote: On Thursday, 25 September 2014 at 20:58:29 UTC, Gary Willoughby wrote:

Re: Can I make a variable public and readonly (outside where was declared) at same time?

2014-09-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/27/14 5:48 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net Yes, that's what I originally intended. Just forgot the const, and didn't even notice it after I reread it :-P I wondered... ;) -Steve

Re: Initialising multidimensional dynamic arrays

2014-09-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/30/14 12:40 PM, Mike James wrote: On Tuesday, 30 September 2014 at 16:07:28 UTC, ketmar via Digitalmars-d-learn wrote: auto a = new int[][](42, 69); ... You'll notice that it's actually a dynamic array of structs containing dynamic arrays - does this change your initializing?

Re: What is a sink delegate?

2014-09-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/30/14 1:22 PM, Gary Willoughby wrote: What is a sink delegate? Discussed here: http://forum.dlang.org/thread/m0bdgg$1t7j$1...@digitalmars.com?page=6#post-m0emvc:242av5:241:40digitalmars.com Aside from Adam's answer, the term 'sink' means to draw out something, as in 'heat sink'. So

Re: is there any reason UFCS can't be used with 'new'?

2014-09-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/30/14 2:07 PM, Ali Çehreli wrote: Apparently, a class definition even inside a unittest blocks are considered to be nested classes. Normally, objects of nested classes are created by the 'this.new' syntax, 'this' meaning the object that wraps the nested class. I think unit test blocks

Re: Initialising multidimensional dynamic arrays

2014-10-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/1/14 3:13 AM, Mike James wrote: Hi Steve, It's true that his code initialises an array of arrays - but my array is an array of structs containing a dynamic array. Regards, -=mike=- Ah, ok. There is no trivial way to do it. Unlike C++, struct default ctors cannot be overridden. I

Re: array append result type

2014-10-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/6/14 7:28 AM, John Colvin wrote: string a; char[] b; pragma(msg, typeof(a ~ b)); // char[] why not string? It really should be whatever you want. a ~ b is going to generate a completely unique independent copy of a and b. What are the rules that determine this? Not sure. I would

Re: array append result type

2014-10-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/6/14 1:01 PM, monarch_dodra wrote: On Monday, 6 October 2014 at 16:38:37 UTC, Steven Schveighoffer wrote: I filed this ER ages ago: https://issues.dlang.org/show_bug.cgi?id=1654 Not sure if anyone has it on their radar at this point. -Steve I didn't read the whole thing, but wouldn't

Re: function not callable using argument types - i disagree

2014-10-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/7/14 3:15 PM, Vlad Levenfeld wrote: Update: I just did a manual cast. Still getting there error. Here's the new argument lists: (void**, const(PaStreamParameters*), const(PaStreamParameters*), double, uint, uint, extern (C) int function(const(void)*, void*, uint,

Re: Simple import question

2014-10-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/9/14 3:30 PM, Adam D. Ruppe wrote: On Thursday, 9 October 2014 at 18:21:32 UTC, WhatMeWorry wrote: To import one module from another, specify the name of the module in an import declaration. The name must include the relative path computed from the directory where compilation takes place

Re: What is a sink delegate?

2014-10-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/10/14 1:00 AM, Ali Çehreli wrote: On 10/09/2014 08:06 PM, Joel wrote: On Tuesday, 30 September 2014 at 17:27:09 UTC, Adam D. Ruppe wrote: On Tuesday, 30 September 2014 at 17:22:44 UTC, Gary Willoughby wrote: What is a sink delegate? Instead of string toString() { return foo; } for

Re: What is a sink delegate?

2014-10-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/10/14 11:20 AM, Ali Çehreli wrote: On 10/10/2014 06:30 AM, Steven Schveighoffer wrote: The const outside is irrelevant to whether it will accept it or not, that is a contract between the toString function and your object. If you want a non-const toString, I think that should work.

Re: how to call class' template constructor

2014-10-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/12/14 3:46 PM, ketmar via Digitalmars-d-learn wrote: Hello. please, how to call template constructor of a class? it's completely escaped my mind. i.e. i have this class: class A { this(alias ent) (string name) { ... } } and i want to do: void foo () { ... }

Re: dsource and WinAPI

2014-10-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/13/14 8:17 PM, dcrepid wrote: I've tried to create an account on dsource.org without success, and am wondering if anyone here knows if they are no longer accepting new users or whatnot? dsource is no longer actively maintained. I don't think anyone knows how to contact the admin. Most D

Re: dsource and WinAPI

2014-10-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/14/14 5:03 AM, dcrepid wrote: Which project are you looking at? Bindings for the Windows API: http://www.dsource.org/projects/bindings/wiki/WindowsApi This is a pretty important project, especially for getting more Windows programmers on board.. thanks for your help Looks like they

Re: Simple import question

2014-10-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/15/14 4:59 AM, Rei Roldan wrote: I don't see how passing all required files to the compiler could possible raise an issue with module discoverability. Unless I'm missing something? In regards to pains if folder|file names / package|module names don't match, imho, physical organization of

Re: Simple import question

2014-10-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/16/14 6:59 AM, Rei Roldan wrote: On Wednesday, 15 October 2014 at 16:11:22 UTC, Steven Schveighoffer wrote: *snip* You might of missed Adam's response up there: But the best way is to explicitly pass all the file names to the compiler: dmd yourfile.d file2.d folder/file3.d and so

Re: Constructor params with same name as members

2014-10-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/23/14 1:03 AM, Shriramana Sharma via Digitalmars-d-learn wrote: Hello. Please see the following code: import std.stdio ; struct Pair { int x, y ; this (int x, int y) { x = x ; y = y ; } } void main() { auto P = Pair(1, 2) ; writeln(P.x, ' ', P.y) ; } This

Re: Bug?

2014-10-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/23/14 1:08 PM, deed wrote: // DMD v2.066.0 // All asserts pass (!) Using equality is not a good idea with floating point. The compiler will on a whim, or depending on whether it can inline or not, use higher precision floats, changing the outcome slightly. I cannot say for certain

Re: Bug?

2014-10-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/23/14 2:18 PM, deed wrote: Using equality is not a good idea with floating point. The compiler will on a whim, or depending on whether it can inline or not, use higher precision floats, changing the outcome slightly. I cannot say for certain whether this explains all the issues you have,

  1   2   3   4   5   6   7   8   9   10   >