Re: [challenge] Lazy flatten/avoiding type forward reference with map

2013-11-01 Thread Andrej Mitrovic
On 11/1/13, David Nadlinger wrote: > I just thought I'd be interested to see what the best solution we > can find in terms of conciseness is. Note that I've already asked this in D.learn: http://forum.dlang.org/thread/mailman.43.1383090512.9546.digitalmars-d-le...@puremagic.com

[OT] Generating ddili.org with ddoc (was: Re: How to iterate using foreach on a class?)

2013-11-01 Thread Ali Çehreli
On 11/01/2013 03:51 PM, Philippe Sigaud wrote: > What did you use to generate your website, btw? It is a completely static web site (except the Google translate widget) that is produced by ddoc and a couple of Makefiles. The following is the Turkish readme file: https://code.google.com/p/d

Re: How to iterate using foreach on a class?

2013-11-01 Thread Philippe Sigaud
On Fri, Nov 1, 2013 at 11:15 PM, Ali Çehreli wrote: > >> You made my day! :) I can't believe that the king of D templates learned > something from my little chapter: > > > https://github.com/**PhilippeSigaud/D-templates-**tutorial > > ;-)

Re: How to iterate using foreach on a class?

2013-11-01 Thread Ali Çehreli
On 11/01/2013 02:28 PM, Philippe Sigaud wrote: Ali: As another shameless plug, those foreach methods are included in this chapter: http://ddili.org/ders/d.en/foreach_opapply.htm OMG. I just grokked opApply. *epiphany moment* Thanks a lot, A

Re: [challenge] Lazy flatten/avoiding type forward reference with map

2013-11-01 Thread David Nadlinger
On Friday, 1 November 2013 at 09:34:20 UTC, Philippe Sigaud wrote: But can you think of a more simple/elegant workaround? Is a standard lazy struct range authorized? Sure. This wasn't intended as an actual challenge, as I don't have a "right" answer myself (or a prize, for that matter). ;)

Re: How to iterate using foreach on a class?

2013-11-01 Thread Philippe Sigaud
Ali: > As another shameless plug, those foreach methods are included in this chapter: > http://ddili.org/ders/d.en/foreach_opapply.htm OMG. I just grokked opApply. *epiphany moment* Thanks a lot, Ali! I tried to get it for *years*!

Re: fieldPostBlit - what is wrong with this and workarounds

2013-11-01 Thread Jonathan M Davis
On Friday, November 01, 2013 14:28:55 Daniel Davidson wrote: > On Thursday, 31 October 2013 at 19:39:44 UTC, Jonathan M Davis > > wrote: > > const and postblit fundamentally don't mix, because for it to > > work, you have > > to violate the type system. With postblits, the struct gets > > memcpied

Re: How to iterate using foreach on a class?

2013-11-01 Thread Jonathan M Davis
On Friday, November 01, 2013 19:32:35 Dmitry Olshansky wrote: > 01-Nov-2013 16:43, John Colvin пишет: > > On Friday, 1 November 2013 at 12:37:20 UTC, simendsjo wrote: > >> 2) opSlice > >> 3) alias this > > > > arguably these are the same in the context of the foreach loop. Both > > just provide di

Re: Using reduce() with tuples created by zip()

2013-11-01 Thread Philippe Sigaud
What I'm trying to explain is that reduce takes two arguments: the growing value and the current front. In your case, the current front is indeed a 2-tuple, but that's an unrelated issue. You're trying to get: reduce!( (firstElemOfPair, secondElemOfPair) => ...) (range) to work, whereas reduce s

Re: Using reduce() with tuples created by zip()

2013-11-01 Thread Craig Dillabaugh
On Friday, 1 November 2013 at 18:44:23 UTC, Philippe Sigaud wrote: reduce!( (result, elem) => result + (elem[0]-elem[1])^^2 )(zippedRange, 0) This is really where my problem arose. I understood everything up to here, but I sort of had this idea, "hey zip returns a tuple so that somehow the

Re: Using reduce() with tuples created by zip()

2013-11-01 Thread Philippe Sigaud
reduce!( (result, elem) => result + (elem[0]-elem[1])^^2 )(zippedRange, 0) > > This is really where my problem arose. I understood everything up > to here, but I sort of had this idea, "hey zip returns a tuple so > that somehow the compiler > was going to figure out for me that function(e) has two

Re: Shipping the DMD compiler with code

2013-11-01 Thread Colin Grogan
On Friday, 1 November 2013 at 17:07:48 UTC, John Colvin wrote: On Friday, 1 November 2013 at 15:47:56 UTC, Colin Grogan wrote: I have a project I may need to write that is pretty performance intensive, but also needs to be quite customiseable. We previously had this done with Perl, and the cu

Re: Shipping the DMD compiler with code

2013-11-01 Thread Colin Grogan
On Friday, 1 November 2013 at 16:12:10 UTC, Joseph Rushton Wakeling wrote: On 01/11/13 17:01, bearophile wrote: I think you are not allowed to redistribute the DMD compiler. So you have to use GDC or LDC (where LDC = LDC2). Many things are possible if you get permission from the right person

Re: Shipping the DMD compiler with code

2013-11-01 Thread John Colvin
On Friday, 1 November 2013 at 15:47:56 UTC, Colin Grogan wrote: I have a project I may need to write that is pretty performance intensive, but also needs to be quite customiseable. We previously had this done with Perl, and the customising came from adding functions to a file and the main scri

Re: Intelligent Scope Hierarchy

2013-11-01 Thread Stretto
On Friday, 1 November 2013 at 08:59:36 UTC, Namespace wrote: On Friday, 1 November 2013 at 05:49:04 UTC, Stretto wrote: On Thursday, 31 October 2013 at 22:03:18 UTC, Namespace wrote: The 'it' property is only some 'singleton' approach. You can write: void foo() { auto buffer = Mallocator.all

Re: Linker error regarding importing and unit tests. Is this a bug?

2013-11-01 Thread Gary Willoughby
On Friday, 1 November 2013 at 15:32:54 UTC, Daniel Davidson wrote: An alternative is to move the import statements in test1.d out of the unittest block, which becomes a function, to file scope. Then if you have multiple unittests in test1.d all are covered and the symbols are available. ... v

Re: Shipping the DMD compiler with code

2013-11-01 Thread Joseph Rushton Wakeling
On 01/11/13 17:01, bearophile wrote: I think you are not allowed to redistribute the DMD compiler. So you have to use GDC or LDC (where LDC = LDC2). Many things are possible if you get permission from the right person ... :-) Depending on the use-case it may be preferable to ship GDC or LDC an

Re: Shipping the DMD compiler with code

2013-11-01 Thread bearophile
Colin Grogan: Is it possible to ship the D compiler with the code, and not have to worry about any libs and config files being missing? I think you are not allowed to redistribute the DMD compiler. So you have to use GDC or LDC (where LDC = LDC2). Bye, bearophile

Re: How to iterate using foreach on a class?

2013-11-01 Thread Ali Çehreli
On 11/01/2013 08:32 AM, Dmitry Olshansky wrote: In short we have 2 ways: 1) Ranges 2) opApply As another shameless plug, those foreach methods are included in this chapter: http://ddili.org/ders/d.en/foreach_opapply.html Ali

Shipping the DMD compiler with code

2013-11-01 Thread Colin Grogan
I have a project I may need to write that is pretty performance intensive, but also needs to be quite customiseable. We previously had this done with Perl, and the customising came from adding functions to a file and the main script would call those functions as required. Problem is, the Perl

Re: Linker error regarding importing and unit tests. Is this a bug?

2013-11-01 Thread Daniel Davidson
On Friday, 1 November 2013 at 12:59:24 UTC, Gary Willoughby wrote: I have a small test case that displays a linker error. I wondered if this is an issue with the tool chain or whether i'm doing something wrong. I have a simple directory structure like this: test/methods.d test/test1.d test/te

Re: How to iterate using foreach on a class?

2013-11-01 Thread Dmitry Olshansky
01-Nov-2013 16:43, John Colvin пишет: On Friday, 1 November 2013 at 12:37:20 UTC, simendsjo wrote: 2) opSlice 3) alias this arguably these are the same in the context of the foreach loop. Both just provide direct access to the underlying array. No quite. I'd say alias this is frankly a bad i

Re: Using reduce() with tuples created by zip()

2013-11-01 Thread Craig Dillabaugh
On Friday, 1 November 2013 at 09:31:41 UTC, Philippe Sigaud wrote: On Thu, Oct 31, 2013 at 8:59 PM, Craig Dillabaugh < cdill...@cg.scs.carleton.ca> wrote: Thanks, I will try both your, and Bearophile's ideas and see if I can figure out how they work. reduce takes a range and eagerly (t

Re: Using reduce() with tuples created by zip()

2013-11-01 Thread bearophile
Philippe Sigaud: We could also have a slightly different version that lazily produces the intermediate results as a range. IIRC, it's called 'scan' in Haskell. It's already in Bugzilla: http://d.puremagic.com/issues/show_bug.cgi?id=11084 Bye, bearophile

Re: fieldPostBlit - what is wrong with this and workarounds

2013-11-01 Thread Daniel Davidson
On Thursday, 31 October 2013 at 19:39:44 UTC, Jonathan M Davis wrote: const and postblit fundamentally don't mix, because for it to work, you have to violate the type system. With postblits, the struct gets memcpied and then the postblit constructor has the chance to mutate the resulting object

Linker error regarding importing and unit tests. Is this a bug?

2013-11-01 Thread Gary Willoughby
I have a small test case that displays a linker error. I wondered if this is an issue with the tool chain or whether i'm doing something wrong. I have a simple directory structure like this: test/methods.d test/test1.d test/test2.d Here is the source code for the above modules: methods.d:

Re: How to iterate using foreach on a class?

2013-11-01 Thread John Colvin
On Friday, 1 November 2013 at 12:37:20 UTC, simendsjo wrote: 2) opSlice 3) alias this arguably these are the same in the context of the foreach loop. Both just provide direct access to the underlying array.

Re: How to iterate using foreach on a class?

2013-11-01 Thread simendsjo
On Friday, 1 November 2013 at 11:41:52 UTC, Jonathan M Davis wrote: On Friday, November 01, 2013 12:30:10 Gary Willoughby wrote: I have a class which contains an array as a core collection of data. I want to pass an instance of this class to a foreach loop and iterate through the enclosed arra

Re: How to iterate using foreach on a class?

2013-11-01 Thread evilrat
On Friday, 1 November 2013 at 11:39:15 UTC, Gary Willoughby wrote: On Friday, 1 November 2013 at 11:35:03 UTC, simendsjo wrote: On Friday, 1 November 2013 at 11:30:12 UTC, Gary Willoughby wrote: I have a class which contains an array as a core collection of data. I want to pass an instance of t

Re: is this invalid code

2013-11-01 Thread Daniel Davidson
On Friday, 1 November 2013 at 04:26:25 UTC, Ali Çehreli wrote: You are not going to like my answer but this may be the 16-byte struct bug. Add something to RateCurve and your code works fine... :-/ struct RateCurve { private immutable(DateRate)[] _data; ubyte b; // <-- ADDED } I ap

Re: How to iterate using foreach on a class?

2013-11-01 Thread Gary Willoughby
On Friday, 1 November 2013 at 11:41:52 UTC, Jonathan M Davis wrote: On Friday, November 01, 2013 12:30:10 Gary Willoughby wrote: I have a class which contains an array as a core collection of data. I want to pass an instance of this class to a foreach loop and iterate through the enclosed arra

Re: How to iterate using foreach on a class?

2013-11-01 Thread Jonathan M Davis
On Friday, November 01, 2013 12:30:10 Gary Willoughby wrote: > I have a class which contains an array as a core collection of > data. I want to pass an instance of this class to a foreach loop > and iterate through the enclosed array. How do i do this? I've > asked this before and got an answer but

Re: How to iterate using foreach on a class?

2013-11-01 Thread Gary Willoughby
On Friday, 1 November 2013 at 11:35:03 UTC, simendsjo wrote: On Friday, 1 November 2013 at 11:30:12 UTC, Gary Willoughby wrote: I have a class which contains an array as a core collection of data. I want to pass an instance of this class to a foreach loop and iterate through the enclosed array.

Re: How to iterate using foreach on a class?

2013-11-01 Thread Gary Willoughby
On Friday, 1 November 2013 at 11:35:03 UTC, simendsjo wrote: On Friday, 1 November 2013 at 11:30:12 UTC, Gary Willoughby wrote: I have a class which contains an array as a core collection of data. I want to pass an instance of this class to a foreach loop and iterate through the enclosed array.

Re: How to iterate using foreach on a class?

2013-11-01 Thread simendsjo
On Friday, 1 November 2013 at 11:30:12 UTC, Gary Willoughby wrote: I have a class which contains an array as a core collection of data. I want to pass an instance of this class to a foreach loop and iterate through the enclosed array. How do i do this? I've asked this before and got an answer b

How to iterate using foreach on a class?

2013-11-01 Thread Gary Willoughby
I have a class which contains an array as a core collection of data. I want to pass an instance of this class to a foreach loop and iterate through the enclosed array. How do i do this? I've asked this before and got an answer but i can't find anything now.

Re: [challenge] Lazy flatten/avoiding type forward reference with map

2013-11-01 Thread Philippe Sigaud
> But can you think of a more simple/elegant workaround? > > Is a standard lazy struct range authorized?

Re: Using reduce() with tuples created by zip()

2013-11-01 Thread Philippe Sigaud
On Thu, Oct 31, 2013 at 8:59 PM, Craig Dillabaugh < cdill...@cg.scs.carleton.ca> wrote: > >>> > Thanks, I will try both your, and Bearophile's ideas and see if I > can figure out how they work. reduce takes a range and eagerly (that is, not lazily) builds a value from it. In your case, it build

Re: new Type[count] takes too much?

2013-11-01 Thread Namespace
It is. I don't know if it is fixed already, and I don't have the time to search for the thread. But afaik monarch filled the bug.

Re: new Type[count] takes too much?

2013-11-01 Thread John Colvin
On Friday, 1 November 2013 at 00:16:55 UTC, Namespace wrote: On Thursday, 31 October 2013 at 23:48:19 UTC, Jonathan M Davis wrote: On Thursday, October 31, 2013 23:06:22 Namespace wrote: On Thursday, 31 October 2013 at 09:53:39 UTC, Jonathan M Davis wrote: > On Thursday, October 31, 2013 10:15

Re: new Type[count] takes too much?

2013-11-01 Thread Jonathan M Davis
On Friday, November 01, 2013 01:16:53 Namespace wrote: > Currently Appender isn't more performant than built-in arrays. ;) If Appender is not more performant for appending than just appending to a naked array, then something is very wrong with Appender, because it's whole job is to make sure tha

Re: Intelligent Scope Hierarchy

2013-11-01 Thread Namespace
On Friday, 1 November 2013 at 05:49:04 UTC, Stretto wrote: On Thursday, 31 October 2013 at 22:03:18 UTC, Namespace wrote: The 'it' property is only some 'singleton' approach. You can write: void foo() { auto buffer = Mallocator.allocate(42); /// ... many code } And at the end of the scop