Re: Parse d source file by using compiler

2015-11-08 Thread BBasile via Digitalmars-d-learn
On Monday, 9 November 2015 at 05:49:25 UTC, tcak wrote: I checked for a flag in this page http://dlang.org/dmd-linux.html , but couldn't have found any for this purpose. Is there a way to parse a d source file so it generates a tree in JSON, XML, or something-that-can-be-processed-easily file

Re: Parse d source file by using compiler

2015-11-08 Thread Rikki Cattermole via Digitalmars-d-learn
On 09/11/15 6:49 PM, tcak wrote: I checked for a flag in this page http://dlang.org/dmd-linux.html , but couldn't have found any for this purpose. Is there a way to parse a d source file so it generates a tree in JSON, XML, or something-that-can-be-processed-easily file format? --- My real pur

Parse d source file by using compiler

2015-11-08 Thread tcak via Digitalmars-d-learn
I checked for a flag in this page http://dlang.org/dmd-linux.html , but couldn't have found any for this purpose. Is there a way to parse a d source file so it generates a tree in JSON, XML, or something-that-can-be-processed-easily file format? --- My real purpose: I need to generate hash

Re: Preferred behavior of take() with ranges (value vs reference range)

2015-11-08 Thread Jon D via Digitalmars-d-learn
On Monday, 9 November 2015 at 02:44:48 UTC, TheFlyingFiddle wrote: On Monday, 9 November 2015 at 02:14:58 UTC, Jon D wrote: Here's an example of the behavior differences below. It uses refRange, but same behavior occurs if the range is created as a class rather than a struct. --Jon This is a

Re: Associative arrays

2015-11-08 Thread rsw0x via Digitalmars-d-learn
On Monday, 9 November 2015 at 04:29:30 UTC, Rikki Cattermole wrote: On 09/11/15 4:57 PM, TheFlyingFiddle wrote: [...] Nope. [...] As far as I'm aware, you are stuck using e.g. structs to emulate AA behavior. I have a VERY basic implementation here: https://github.com/rikkimax/alphaPhobos

Re: Associative arrays

2015-11-08 Thread Rikki Cattermole via Digitalmars-d-learn
On 09/11/15 4:57 PM, TheFlyingFiddle wrote: I have a few questions about the pseudo built in associative arrays. 1. Is it possible to have the built in associative array use a custom allocator from std.experimental.allocator to service it's allocation needs? Nope. 2. A while ago I read on th

Associative arrays

2015-11-08 Thread TheFlyingFiddle via Digitalmars-d-learn
I have a few questions about the pseudo built in associative arrays. 1. Is it possible to have the built in associative array use a custom allocator from std.experimental.allocator to service it's allocation needs? 2. A while ago I read on the newsgroup a while back that there was a plan to

Re: Preferred behavior of take() with ranges (value vs reference range)

2015-11-08 Thread TheFlyingFiddle via Digitalmars-d-learn
On Monday, 9 November 2015 at 02:14:58 UTC, Jon D wrote: Here's an example of the behavior differences below. It uses refRange, but same behavior occurs if the range is created as a class rather than a struct. --Jon This is an artifact of struct based ranges being value types. When you use t

Preferred behavior of take() with ranges (value vs reference range)

2015-11-08 Thread Jon D via Digitalmars-d-learn
Just started looking at D, very promising! One of the first programs I constructed involved infinite sequences. A design question that showed up is whether to construct the range as a struct/value, or class/reference. It appears that structs/values are more the norm, but there are exceptions

Re: phobos: What type to use instead of File when doing I/O on streams?

2015-11-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 8 November 2015 at 20:47:08 UTC, J.Frank wrote: So, assuming my program reads from stdin and is supposed to work on a file as well as on a pipe (which is not seekable) - how can I make the compiler bark when I accidently use stdin.seek()? You don't, in general. stdin is sometimes s

Re: Confusion about dynamically and lexically scoped closures

2015-11-08 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 8 November 2015 at 23:17:06 UTC, Jakob Ovrum wrote: The closures for delegates in D1 are never automatically copied to the heap, while in D2 this is done when it's determined that the delegate might outlive one of its upvalues. So, I think it's safe to say we have lexical closures i

Re: Confusion about dynamically and lexically scoped closures

2015-11-08 Thread Jakob Ovrum via Digitalmars-d-learn
On Sunday, 8 November 2015 at 23:08:05 UTC, ParticlePeter wrote: Hi, the confusion starts here: http://dlang.org/function.html#closures End of paragraph bellow the last delegate example: "This combining of the environment and the function is called a dynamic closure." While according to htt

Confusion about dynamically and lexically scoped closures

2015-11-08 Thread ParticlePeter via Digitalmars-d-learn
Hi, the confusion starts here: http://dlang.org/function.html#closures End of paragraph bellow the last delegate example: "This combining of the environment and the function is called a dynamic closure." While according to https://en.wikipedia.org/wiki/Scope_%28computer_science%29 "Lexical sco

Re: phobos: What type to use instead of File when doing I/O on streams?

2015-11-08 Thread J.Frank via Digitalmars-d-learn
On Sunday, 8 November 2015 at 21:57:55 UTC, Alex Parrill wrote: Post what you're trying to do if you want an example. $ cat test.d import std.stdio; //void foo(Stream in_stream, Stream out_stream) // I want something like this void foo(File in_stream, File out_stream) { in_stream.see

Re: phobos: What type to use instead of File when doing I/O on streams?

2015-11-08 Thread Alex Parrill via Digitalmars-d-learn
On Sunday, 8 November 2015 at 20:47:08 UTC, J.Frank wrote: Hello again, I'm a bit puzzled by the "File" type. Looking at the implementation, it seems that all I/O functions were stuffed into a single class^H^H^H^H^Hstruct. What I expected to find is some kind of "Stream" class (with read(), w

phobos: What type to use instead of File when doing I/O on streams?

2015-11-08 Thread J.Frank via Digitalmars-d-learn
Hello again, I'm a bit puzzled by the "File" type. Looking at the implementation, it seems that all I/O functions were stuffed into a single class^H^H^H^H^Hstruct. What I expected to find is some kind of "Stream" class (with read(), write(), eof()), which is extended by a "File" class (with s

Re: std.range.only with different range types

2015-11-08 Thread Jakob Ovrum via Digitalmars-d-learn
On Sunday, 8 November 2015 at 19:57:34 UTC, Freddy wrote: --- import std.algorithm; import std.range; import std.stdio; void main(){ only(iota(0,4),[1,4,5]).writeln; } --- How can I call std.range.only with different range types? `only` is for creating a range from a list of values. io

std.range.only with different range types

2015-11-08 Thread Freddy via Digitalmars-d-learn
--- import std.algorithm; import std.range; import std.stdio; void main(){ only(iota(0,4),[1,4,5]).writeln; } --- How can I call std.range.only with different range types?

Re: foreach statement: Are there no Iterators in D?

2015-11-08 Thread rsw0x via Digitalmars-d-learn
On Sunday, 8 November 2015 at 11:57:16 UTC, J.Frank wrote: On Sunday, 8 November 2015 at 11:47:41 UTC, Rikki Cattermole wrote: opApply if you want 0 .. N iterations during for a foreach statement and having it reset each time. No, that won't help. I want to be able to iterate over a data set

Re: Cannot use local 'i' as parameter to non-global template

2015-11-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 7 November 2015 at 15:04:41 UTC, maik klein wrote: template IsSame(T){ template As(alias t){ enum As = is(T : typeof(t)); } } void main() { int i; enum b = IsSame!int.As!(i); } Err: Error: template instance As!(i) cannot use local 'i' as parameter to non-global templat

Re: Deprecation: module std.stream is deprecated

2015-11-08 Thread BBasile via Digitalmars-d-learn
On Sunday, 8 November 2015 at 14:41:11 UTC, Spacen Jasset wrote: But it doesn't seem efficient and strays off the conceptual path. In other words, why chunk things up, join them back, to get a stream? `.byChunk` caches and `.joiner` hides this caching mechanism. Both operations happen under t

Re: Deprecation: module std.stream is deprecated

2015-11-08 Thread Spacen Jasset via Digitalmars-d-learn
On Sunday, 8 November 2015 at 08:29:30 UTC, BBaz wrote: 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 wo

Re: std.variant.Algebraic, self referential types and delegate members

2015-11-08 Thread Meta via Digitalmars-d-learn
On Sunday, 8 November 2015 at 10:31:13 UTC, Panke wrote: import std.variant, std.stdio; --- struct NodeTypeA(T) { T[] children; } struct NodeTypeB(T) { Tree children; } struct Leaf(T) { T delegate() dg; } alias Tree = Algebraic!(Leaf, NodeTypeA!This, NodeTypeB!This); void main() { Tree t; }

Re: Error not callable with argument types but types matches

2015-11-08 Thread anonymous via Digitalmars-d-learn
On 08.11.2015 08:17, Sliya wrote: I am on Mac OS, but I still don't get it. If the import was not case-sensitive, I would not have any error since the good file would have been loaded... Here I have no error saying file not found yet the file is not loaded. I'd love to know what really happens.

Re: foreach statement: Are there no Iterators in D?

2015-11-08 Thread J.Frank via Digitalmars-d-learn
On Sunday, 8 November 2015 at 11:47:41 UTC, Rikki Cattermole wrote: opApply if you want 0 .. N iterations during for a foreach statement and having it reset each time. No, that won't help. I want to be able to iterate over a data set of infinite size. Otherwise you want ranges :) An input

Re: foreach statement: Are there no Iterators in D?

2015-11-08 Thread Rikki Cattermole via Digitalmars-d-learn
On 09/11/15 12:40 AM, J.Frank wrote: Hello, I am looking for something like the "Iterator" Interface in Java or PHP. Is there something comparable in D that can be used with foreach? Thanks, J.Frank opApply if you want 0 .. N iterations during for a foreach statement and having it reset eac

foreach statement: Are there no Iterators in D?

2015-11-08 Thread J.Frank via Digitalmars-d-learn
Hello, I am looking for something like the "Iterator" Interface in Java or PHP. Is there something comparable in D that can be used with foreach? Thanks, J.Frank

Re: std.variant.Algebraic, self referential types and delegate members

2015-11-08 Thread Panke via Digitalmars-d-learn
On Sunday, 8 November 2015 at 11:28:05 UTC, Jonathan M Davis wrote: On Sunday, November 08, 2015 10:31:11 Panke via Digitalmars-d-learn wrote: import std.variant, std.stdio; --- struct NodeTypeA(T) { T[] children; } struct NodeTypeB(T) { Tree children; } struct Leaf(T) { T delegate() dg; } ali

Re: std.variant.Algebraic, self referential types and delegate members

2015-11-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 08, 2015 10:31:11 Panke via Digitalmars-d-learn wrote: > import std.variant, std.stdio; > > --- > struct NodeTypeA(T) { T[] children; } > struct NodeTypeB(T) { Tree children; } > struct Leaf(T) { T delegate() dg; } > > alias Tree = Algebraic!(Leaf, NodeTypeA!This, NodeTypeB!This

std.variant.Algebraic, self referential types and delegate members

2015-11-08 Thread Panke via Digitalmars-d-learn
import std.variant, std.stdio; --- struct NodeTypeA(T) { T[] children; } struct NodeTypeB(T) { Tree children; } struct Leaf(T) { T delegate() dg; } alias Tree = Algebraic!(Leaf, NodeTypeA!This, NodeTypeB!This); void main() { Tree t; } --- yields tmp.d(6): Error: functions cannot return opaq

Re: Why my app require MSVCR120.dll?

2015-11-08 Thread thedeemon via Digitalmars-d-learn
On Sunday, 8 November 2015 at 05:11:50 UTC, suliman wrote: On Sunday, 8 November 2015 at 04:50:49 UTC, thedeemon wrote: On Saturday, 7 November 2015 at 10:03:58 UTC, Suliman wrote: I am using DMD. -m64 or -m32mscoff ? Without any keys. I use dub for building I suspect your issue is cause

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: 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 ca

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 s

dbgVerifySorted is not nothrow

2015-11-08 Thread Panke via Digitalmars-d-learn
I've updated my compiler and ran into this regression: https://issues.dlang.org/show_bug.cgi?id=14981 Code: --- import std.algorithm, std.container; void main() { static bool compare(P a, P b) { return a.curColumn < b.curColumn; } Array!P a = mak