Re: Python's features, which requires D

2015-05-23 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 23 May 2015 at 21:09:45 UTC, weaselcat wrote: After another review, I think some of these conversions to D could be expressed much easier if the built-in slice had multidimensional slicing It was added in 2.066* but I don't think there's any plans to add support for it to

Re: Python's features, which requires D

2015-05-23 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 23 May 2015 at 20:44:37 UTC, cym13 wrote: Not sure what kind of meat you mean, but I really don't see much meat in ranges. Of course, this is 10 times better and easier to use than STL iterators C++. For me the most important feature D are mixins, which I, unfortunately, rarely

Re: Python's features, which requires D

2015-05-23 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 23 May 2015 at 21:32:51 UTC, anonymous wrote: On Saturday, 23 May 2015 at 21:08:19 UTC, Dennis Ritchie wrote: Perhaps that's not the site, and in Windows. That's what gives me in CMD: 456 4 4 8 99 456 [[456, 4, 4, 8, 99, 456]13 546

Re: Python's features, which requires D

2015-05-23 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 23 May 2015 at 19:22:40 UTC, Alex Parrill wrote: import std.algorithm; import std.range; import std.stdio; import std.conv; void main() { enum n1 = 5; writeln(stdin.byLine .map!(line = line.split( ).map!(x = to!int(x))) );

Re: Python's features, which requires D

2015-05-23 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 23 May 2015 at 19:22:40 UTC, Alex Parrill wrote: You seem to be focusing on D's arrays only, but the real meat is in ranges, which are more generic. Also note that the above solution doesn't allocate any of the ranges in the heap; they're all on the stack (as opposed to Python,

Re: Python's features, which requires D

2015-05-23 Thread cym13 via Digitalmars-d-learn
Not sure what kind of meat you mean, but I really don't see much meat in ranges. Of course, this is 10 times better and easier to use than STL iterators C++. For me the most important feature D are mixins, which I, unfortunately, rarely use. I'm waiting for new features from D: for new

Re: Python's features, which requires D

2015-05-23 Thread cym13 via Digitalmars-d-learn
(just noticed a weird typo trend with know/now %s/know/now/g)

Re: Python's features, which requires D

2015-05-23 Thread anonymous via Digitalmars-d-learn
On Saturday, 23 May 2015 at 20:25:18 UTC, Dennis Ritchie wrote: This does not work! enum n1 = 5; writeln(stdin.byLine .map!(line = line.split( ).map!(x = to!int(x))) ); - http://rextester.com/VGHZF81178 The code itself is ok. That site has broken newlines. You can see here that

Re: Python's features, which requires D

2015-05-23 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 23 May 2015 at 20:57:10 UTC, anonymous wrote: On Saturday, 23 May 2015 at 20:25:18 UTC, Dennis Ritchie wrote: This does not work! enum n1 = 5; writeln(stdin.byLine .map!(line = line.split( ).map!(x = to!int(x))) ); - http://rextester.com/VGHZF81178 The code itself is

Re: Python's features, which requires D

2015-05-23 Thread weaselcat via Digitalmars-d-learn
On Friday, 22 May 2015 at 00:23:30 UTC, Dennis Ritchie wrote: Hi, I've collected some of Python's features. It seems to me that they are not in the D! Surely all this is in the D? :) http://rextester.com/CNQQR After another review, I think some of these conversions to D could be

Re: Python's features, which requires D

2015-05-23 Thread anonymous via Digitalmars-d-learn
On Saturday, 23 May 2015 at 21:08:19 UTC, Dennis Ritchie wrote: Perhaps that's not the site, and in Windows. That's what gives me in CMD: 456 4 4 8 99 456 [[456, 4, 4, 8, 99, 456]13 546 std.conv.ConvException@C:\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(2013): Unexpected end of input

Re: Python's features, which requires D

2015-05-23 Thread Idan Arye via Digitalmars-d-learn
On Saturday, 23 May 2015 at 22:01:42 UTC, Dennis Ritchie wrote: You may find it nonsense, but Paul Graham says that each language has its own power. He believes that Lisp is the most powerful language, and programmers who write in other languages, he said Blub programmers. Learn more about The

How to append range to array?

2015-05-23 Thread Vladimir Panteleev via Digitalmars-d-learn
int[] arr = [1, 2, 3]; auto r = iota(4, 10); // ??? assert(equal(arr, iota(1, 10))); Hopefully in one GC allocation (assuming we know the range's length). I tried std.range.primitives.put but its behavior seems a little mysterious: This compiles but asserts at runtime: int[] arr = [1, 2,

Re: What happens when you launch a D application ?

2015-05-23 Thread Mike via Digitalmars-d-learn
FYI, I didn't realize this (but just figured it out), C main *used* to be in druntime, but it's now generated by the compiler. See here: https://github.com/D-Programming-Language/dmd/blob/master/src/mars.c#L236 True. But it is compiler-dependent. GDC actually still defines C main in the

Re: Necessity of D Library (and/or Core Library)

2015-05-23 Thread Rikki Cattermole via Digitalmars-d-learn
On 23/05/2015 6:35 p.m., Anthony Monterrosa wrote: Does D require the standard library to function? Or to be more direct, does D as a language need its library, or core library, to function correctly? I have become very interested in how programming languages do their magic; how they

Re: How to append range to array?

2015-05-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 23, 2015 07:03:33 Vladimir Panteleev via Digitalmars-d-learn wrote: int[] arr = [1, 2, 3]; auto r = iota(4, 10); // ??? assert(equal(arr, iota(1, 10))); Hopefully in one GC allocation (assuming we know the range's length). I tried std.range.primitives.put but its

Necessity of D Library (and/or Core Library)

2015-05-23 Thread Anthony Monterrosa via Digitalmars-d-learn
Does D require the standard library to function? Or to be more direct, does D as a language need its library, or core library, to function correctly? I have become very interested in how programming languages do their magic; how they interact with the computer itself, and their inner

Re: How to append range to array?

2015-05-23 Thread Atila Neves via Digitalmars-d-learn
std.range.chain? Atila On Saturday, 23 May 2015 at 07:03:35 UTC, Vladimir Panteleev wrote: int[] arr = [1, 2, 3]; auto r = iota(4, 10); // ??? assert(equal(arr, iota(1, 10))); Hopefully in one GC allocation (assuming we know the range's length). I tried std.range.primitives.put but its

Re: What happens when you launch a D application ?

2015-05-23 Thread Mike Parker via Digitalmars-d-learn
On 5/22/2015 10:26 PM, Suliman wrote: Really hard to understand... So what what would call at first ? extern(C) int main() or int _Dmain() Your D programs have multiple layers. There is the C runtime, DRuntime, and your program code. The C runtime is at the bottom. When the program

Re: Serialization library with support for circular references?

2015-05-23 Thread timotheecour via Digitalmars-d-learn
On Saturday, 10 November 2012 at 22:09:07 UTC, Andrej Mitrovic wrote: On 11/10/12, nixda b...@or.de wrote: You can try vibe.d bson serialization. http://vibed.org/api/vibe.data.bson/serializeToBson It doesn't handle them either. Anyway I've implemented it for msgpack (took a whole of 30

Re: Serialization library with support for circular references?

2015-05-23 Thread timotheecour via Digitalmars-d-learn
On Saturday, 23 May 2015 at 08:01:28 UTC, timotheecour wrote: On Saturday, 10 November 2012 at 22:09:07 UTC, Andrej Mitrovic wrote: On 11/10/12, nixda b...@or.de wrote: You can try vibe.d bson serialization. http://vibed.org/api/vibe.data.bson/serializeToBson It doesn't handle them either.

Re: How to append range to array?

2015-05-23 Thread weaselcat via Digitalmars-d-learn
On Saturday, 23 May 2015 at 07:03:35 UTC, Vladimir Panteleev wrote: int[] arr = [1, 2, 3]; auto r = iota(4, 10); // ??? assert(equal(arr, iota(1, 10))); import std.array : array; arr ~ r.array;

Re: How to append range to array?

2015-05-23 Thread weaselcat via Digitalmars-d-learn
On Saturday, 23 May 2015 at 08:35:45 UTC, weaselcat wrote: On Saturday, 23 May 2015 at 07:03:35 UTC, Vladimir Panteleev wrote: int[] arr = [1, 2, 3]; auto r = iota(4, 10); // ??? assert(equal(arr, iota(1, 10))); import std.array : array; arr ~ r.array; woops, meant ~= but this is probably

Re: Necessity of D Library (and/or Core Library)

2015-05-23 Thread Kagamin via Digitalmars-d-learn
On Saturday, 23 May 2015 at 06:35:50 UTC, Anthony Monterrosa wrote: Does D require the standard library to function? Or to be more direct, does D as a language need its library, or core library, to function correctly? Phobos is not required completely. D runtime can be a couple of lines

Re: What happens when you launch a D application ?

2015-05-23 Thread Mike via Digitalmars-d-learn
Could you explain what mean C main inside the runtime. I thought that is only one main is possible. And why it's named *С* main D is not C-translated language. Same question is about _Dmain -- what is it? If I will call this() before main? What it will be? Will it run before main?

Re: Necessity of D Library (and/or Core Library)

2015-05-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 23 May 2015 at 12:47:12 UTC, Mike wrote: You can disable linking phobos and the D Runtime with the -nophoboslib compiler flag. I'm not sure if DMD or LDC offer a similar compiler option. -defaultlib= You can use that to change to linking to a .so for example but leaving it

Re: Python's features, which requires D

2015-05-23 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 23 May 2015 at 10:58:33 UTC, Kagamin wrote: Well, list comprehension is built into language in python (and not in D), such level of support is definitely more streamlined. Well, what's to keep D more functions to work with slist and dlist ? In my opinion, lists in D completely

Re: Necessity of D Library (and/or Core Library)

2015-05-23 Thread lobo via Digitalmars-d-learn
On Saturday, 23 May 2015 at 06:35:50 UTC, Anthony Monterrosa wrote: Does D require the standard library to function? Or to be more direct, does D as a language need its library, or core library, to function correctly? I have become very interested in how programming languages do

Re: What happens when you launch a D application ?

2015-05-23 Thread Suliman via Digitalmars-d-learn
Every D program is started as if it were a C program. Why is so necessary? What about C++ and other languages? Does they have more then one main? Why it's more than one main is needed? Why D apps can't start with single main?

Re: Python's features, which requires D

2015-05-23 Thread Kagamin via Digitalmars-d-learn
On Saturday, 23 May 2015 at 02:36:14 UTC, Dennis Ritchie wrote: For example, the code in Python looks quite natural: a = [[int(j) for j in input().split()] for i in range(n)] About D-code, I can not say: auto a = stdin .byLine .map!(l = l.splitter.map!(to!int).array)

Re: What happens when you launch a D application ?

2015-05-23 Thread Rikki Cattermole via Digitalmars-d-learn
On 23/05/2015 10:57 p.m., Suliman wrote: Every D program is started as if it were a C program. Why is so necessary? What about C++ and other languages? Does they have more then one main? Depends on the implementation. I believe Visual C++ does. But it is used like D's to allow it to

Re: What happens when you launch a D application ?

2015-05-23 Thread Mike via Digitalmars-d-learn
On Saturday, 23 May 2015 at 10:57:22 UTC, Suliman wrote: Every D program is started as if it were a C program. Why is so necessary? It's not actually necessary. You could implement the `_start` function in your D program. Here's a D program without any C runtime, D runtime, or main.

Re: Necessity of D Library (and/or Core Library)

2015-05-23 Thread Mike via Digitalmars-d-learn
On Saturday, 23 May 2015 at 06:35:50 UTC, Anthony Monterrosa wrote: Does D require the standard library to function? Or to be more direct, does D as a language need its library, or core library, to function correctly? There are two main libraries in D: The D Runtime, and the standard

Re: Dual conditions in D and Python

2015-05-23 Thread Andrei Alexandrescu via Digitalmars-d-learn
On 5/21/15 2:35 PM, Ali Çehreli wrote: On 05/21/2015 12:44 PM, Meta wrote: All we need is user-defined opIs and then we're really cooking with gas. if (5 is between(4, 6)) { //... } We're almost there. :) bool is_between(T0, T1, T2)(T0 what, T1 min, T2 max) { return (what = min)

Re: Dual conditions in D and Python

2015-05-23 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2015-05-23 at 10:17 -0700, Andrei Alexandrescu via Digitalmars-d-learn wrote: […] if (ordered(4, 5, 6)) { ... } if (strictlyOrdered(4, 5, 6)) { ... } So the latter means the integers have to lashed as well as ordered? ; -) -- Russel.

Re: Python's features, which requires D

2015-05-23 Thread Alex Parrill via Digitalmars-d-learn
On Friday, 22 May 2015 at 00:23:30 UTC, Dennis Ritchie wrote: Hi, I've collected some of Python's features. It seems to me that they are not in the D! Surely all this is in the D? :) http://rextester.com/CNQQR import std.algorithm; import std.range; import std.stdio; import std.conv;

Re: How to append range to array?

2015-05-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 23, 2015 08:36:47 weaselcat via Digitalmars-d-learn wrote: On Saturday, 23 May 2015 at 08:35:45 UTC, weaselcat wrote: On Saturday, 23 May 2015 at 07:03:35 UTC, Vladimir Panteleev wrote: int[] arr = [1, 2, 3]; auto r = iota(4, 10); // ??? assert(equal(arr, iota(1,

Re: Dual conditions in D and Python

2015-05-23 Thread weaselcat via Digitalmars-d-learn
On Saturday, 23 May 2015 at 17:17:17 UTC, Andrei Alexandrescu wrote: On 5/21/15 2:35 PM, Ali Çehreli wrote: On 05/21/2015 12:44 PM, Meta wrote: All we need is user-defined opIs and then we're really cooking with gas. if (5 is between(4, 6)) { //... } We're almost there. :) bool