Re: User defined type and foreach
On Friday, 17 November 2017 at 03:15:12 UTC, Tony wrote: Thanks T! Good information, especially "iterating over a range is supposed to consume it". I have been reading dlang.org->Documentation->Language Reference, but should have also read dlang.org->Dlang-Tour->Ranges. Although that page You might also find use in this article (poorly adapted from Chapter 6 of Learning D by the publisher, but still readable): https://www.packtpub.com/books/content/understanding-ranges makes a distinction about "range consumption" with regard to a "reference type" or a "value type" and it isn't clear to me why there would be a difference. With a value type, you're consuming a copy of the original range, so you can reuse it after. With a reference type, you're consuming the original range and therefore can't reuse it. struct ValRange { int[] items; bool empty() @property { return items.length == 0; } int front() @property { return items[0]; } void popFront() { items = items[1 .. $]; } } class RefRange { int[] items; this(int[] src) { items = src; } bool empty() @property { return items.length == 0; } int front() @property { return items[0]; } void popFront() { items = items[1 .. $]; } } void main() { import std.stdio; int[] ints = [1, 2, 3]; auto valRange = ValRange(ints); writeln("Val 1st Run:"); foreach(i; valRange) writeln(i); assert(!valRange.empty); writeln("Val 2nd Run:"); foreach(i; valRange) writeln(i); assert(!valRange.empty); auto refRange = new RefRange(ints); writeln("Ref 1st Run:"); foreach(i; refRange) writeln(i); assert(refRange.empty); writeln("Ref 2nd Run:"); foreach(i; refRange) writeln(i); // prints nothing }
Re: writeln, alias this and dynamic arrays.
On Friday, 17 November 2017 at 02:13:54 UTC, matthewh wrote: [...] as is it produces: [1, 2, 3, 4, 5, 6, 7, 8] [] I expected it to produce: [1, 2, 3, 4, 5, 6, 7, 8] [1, 2, 3, 4, 5, 6, 7, 8] And with the toString override included it does. Why does the version without the toString override output an empty array? Actually, it looks like it's this 4-year old bug. https://issues.dlang.org/show_bug.cgi?id=9506 So frustrating :( Mike
Re: writeln, alias this and dynamic arrays.
On Friday, 17 November 2017 at 02:16:35 UTC, Michael V. Franklin wrote: On Friday, 17 November 2017 at 02:13:54 UTC, matthewh wrote: And with the toString override included it does. Why does the version without the toString override output an empty array? I think that is due to this bug: https://issues.dlang.org/show_bug.cgi?id=13189 It's actually on my todo list to fix, but I'm not sure yet if its within my current abilities. Actually, after playing with your example, I don't think that's the case. There's something else going on, and I'm not sure what it is. It's a strange error indeed. Mike
Re: ESR on post-C landscape
On Friday, 17 November 2017 at 00:36:21 UTC, codephantom wrote: On Thursday, 16 November 2017 at 11:52:45 UTC, Ola Fosheim Grostad wrote: Uhm, no? What do you mean by 'primary focus of program design' and in which context? I the context that, this is specifically what Stroustrup says in his book (The Design and Evolution of C++ 1994) "Simula's class concept was seen as the key difference, and ever since I have seen classes as the proper primary focus of program design." (chp1, page 20) Yes, that is reasonable, it is very useful when made available in a generic form. I believe Simula was used in teaching at his university. A class in Simula is essentially a record, library scope, block-scope, coroutines, with inheritance and virtual functions, implemented as a closure where the body acts as an extensible constructor. So it is a foundational primitive. Nygaard and Dahl got the Turing award for their work. Ole-Johan Dahl was also a coauthor of an influental book on structured programming which had a chapter on it IIRC. Nygaard and others in Denmark later in the 70s and 80s refined the class concept into a unifying concept that was essentially the only primary building block in Beta (called pattern, which allows functions to be extended using inheritance, instantiation of objects from virtual patterns, type variables as members etc). So Beta establish that you don't need other structural mechanisms than a powerful class concept + tuples for parameters. Self establish the same with objects. Freud would tell us, that Stroustups obssesion with Simula, is where it all began. Anyone that cares already know that Simula was an ancestor for C++, Smalltalk, Java and many other OO languages... But Stroustrup wasn't obsessed by Simula, if he was he would have added things like coroutines, local functions, used the class as a module scope etc. He also would have avoided multiple inheritance.
Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?
On Friday, 17 November 2017 at 05:50:24 UTC, rumbu wrote: You are not ending with nothing, you are ending with a run time error in D. In C# it's a compile-time error. Ideally, something ending for sure in an error at run time, must be catch at compile-time. Well.. sometimes it's just nice...to do nothing, and I'm glad D lets me do that. And the runtime should just stay out of it. It's always interfering in something - even when its nothing.
Re: How to define variadic delegate with a ref/out argument?
On Friday, 17 November 2017 at 05:08:23 UTC, pham wrote: struct DelegateList(Args...) { public: alias DelegateHandler = void delegate(Args args) nothrow; DelegateHandler[] items; void opCall(Args args) nothrow { foreach (i; items) i(args); } } DelegateList!(string, int) list; // Compile OK so far DelegateList!(string, int*) list2; // Compile OK so far DelegateList!(string, ref int) list3; // Compile error -> How to make it work? Thanks Pham The only way I know of is using a template which behaves like a reference. Which can be done with nullableRef I suppose. Haven't actually tried it. import std.typecons : NullableRef, nullableRef; DelegateList!(NullableRef!int)(nullableRef(some_int));
Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?
On Friday, 17 November 2017 at 02:25:21 UTC, codephantom wrote: On Friday, 17 November 2017 at 01:47:01 UTC, Michael V. Franklin wrote: It peeked my interested, because when I first started studying D, the lack of any warning or error for this trivial case surprised me. // Example A class Test { int Value; } void main(string[] args) { Test t; t.Value++; // No compiler error, or warning. Runtime error! } Also, if you start with nothing, and add 1 to it, you still end up with nothing, cause you started with nothing. That makes completed sense to me. So why should that be invalid? You are not ending with nothing, you are ending with a run time error in D. In C# it's a compile-time error. Ideally, something ending for sure in an error at run time, must be catch at compile-time.
Re: [OT] mobile rising
On Thursday, 16 November 2017 at 23:03:41 UTC, solidstate1991 wrote: On Wednesday, 15 November 2017 at 11:46:48 UTC, Joakim wrote: [...] I'm thinking on picking up some Android tablet for development purposes, would be good to port my game engine for mobile devices, probably have to resort for OpenGL for graphics acceleration instead of using CPU blitter, although that might work under NEON (currently I'm using SSE2). Great! Let me know if you have any problem using ldc to compile for Android. One caveat, ldc only supports 32-bit ARM chips right now. I've been looking into making it work with 64-bit ARM, but I'm not sure exactly what that platform's doing for TLS and llvm will require some modification to make it work with D on AArch64. David has been working on linux/AArch64, you're welcome to chip into that effort if you like: https://github.com/ldc-developers/ldc/issues/2153 On Friday, 17 November 2017 at 02:01:41 UTC, solidstate1991 wrote: On Wednesday, 15 November 2017 at 04:34:09 UTC, Walter Bright wrote: [...] It's filled with Assembly code, and otherwise not very readable. Would need a lot of work, I don't think it would worth it. Let's hope that MS will allow us to distribute a linker alongside DMD. If you want to help with that, I suggest you see what Go is doing and submit a PR for us to do the same: http://forum.dlang.org/post/bwtknbuhnmadpspac...@forum.dlang.org
Re: Zig mentions D in justifying its existence
On Thursday, 16 November 2017 at 22:58:32 UTC, solidstate1991 wrote: Often I just don't find a use for them, so I won't make the compiler to do CTFE if it's not needed. Why wouldn't you? It gives less overhead at run-time, giving your application better performance.
How to define variadic delegate with a ref/out argument?
struct DelegateList(Args...) { public: alias DelegateHandler = void delegate(Args args) nothrow; DelegateHandler[] items; void opCall(Args args) nothrow { foreach (i; items) i(args); } } DelegateList!(string, int) list; // Compile OK so far DelegateList!(string, int*) list2; // Compile OK so far DelegateList!(string, ref int) list3; // Compile error -> How to make it work? Thanks Pham
Re: User defined type and foreach
On Friday, 17 November 2017 at 01:16:38 UTC, H. S. Teoh wrote: It should be .empty, .popFront, and .front, not .pop. Also, these methods are *range* primitives, and over time, we have come to a consensus that generally speaking, it's a bad idea to conflate containers with ranges over containers. The main thing is that iterating over a range is supposed to consume it, which is usually not what you want with a container. The usual idiom is to separate the two concepts, and have the container provide a mechanism for returning a range over its contents, usually via .opIndex with no arguments, or .opSlice. Then you would just write: foreach (e; myContainer[]) { // [] calls .opIndex/.opSlice ... } Unfortunately, built-in arrays, which are also ranges, are one exception to this rule that, due to their ubiquity in D, also serve to mislead newcomers to D about when/where range primitives should be implemented. Generally speaking, built-in arrays should not be considered exemplary in this respect, but rather should be understood as exceptions. The general convention is to separate your containers from ranges over its contents, and to provide .opIndex / .opSlice that constructs a range over the container when needed. The other consideration is that if you don't really need range functionality, i.e., the only thing you want to do with your container is to put it in a foreach loop, then you can sidestep this whole mess and just implement .opApply for your container and call it a day. Of course, then you won't be able to use generic algorithms like those in std.algorithm with your container, but if you didn't intend to anyway, it's not a big deal. T Thanks T! Good information, especially "iterating over a range is supposed to consume it". I have been reading dlang.org->Documentation->Language Reference, but should have also read dlang.org->Dlang-Tour->Ranges. Although that page makes a distinction about "range consumption" with regard to a "reference type" or a "value type" and it isn't clear to me why there would be a difference.
[Issue 17382] void main(){}pragma(msg,main()); crashes DMD
https://issues.dlang.org/show_bug.cgi?id=17382 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --
[Issue 17382] void main(){}pragma(msg,main()); crashes DMD
https://issues.dlang.org/show_bug.cgi?id=17382 --- Comment #2 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/db8c74b6cfccb4ac14d32b3f9d16aaff1e806a0c Fix Issue 17382 - void main(){}pragma(msg,main()); crashes DMD https://github.com/dlang/dmd/commit/aebbe30de5bbe34b4d2841f07dbe91548da3d0d9 Merge pull request #7316 from RazvanN7/Issue_17382 Fix Issue 17382 - void main(){}pragma(msg,main()); crashes DMD --
TLC for ddox
Whenever I look at the documentation, I find things that could be improved. Consider https://dlang.org/library/, one of the most important pages - the portal - of the hopefully future default documentation renderer. It goes something like this: Module Description std.algorithm.comparison This is a submodule of std.algorithm. It contains generic comparison algorithms. std.algorithm.iteration This is a submodule of std.algorithm. It contains generic iteration algorithms. std.algorithm.mutation This is a submodule of std.algorithm. It contains generic mutation algorithms. std.algorithm.searching This is a submodule of std.algorithm. It contains generic searching algorithms. ... Makes you want to go postal, innit? Reminds me of this quote from David Foster Wallace's unfinished The Pale King: https://www.goodreads.com/quotes/621837-irrelevant-chris-fogle-turns-a-page-howard-cardwell-turns-a Can a kind volunteer please put some tender love care into that page? Thanks, Andrei
Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?
On Friday, 17 November 2017 at 01:47:01 UTC, Michael V. Franklin wrote: In C#, you get a compiler error. // Example B class Test { public int Value; } public class Program { public static void Main() { Test t; t.Value++; // Error: Use of unassigned local variable 't' } } https://dotnetfiddle.net/8diEiG Let's try reversing that question. Is there hope for C#, so that it will let me do something with nothing. D let's me do that ;-) The problem though, seems to be the runtime environment..My code specifically said I wanted to do something with nothing, the compiler said, sure, go ahead..and then it crashed at execution? Fix the runtime so it does what I want.
[Issue 17986] New: Erratic failure with std/experimental/allocator/common.d(445): unittest failure
https://issues.dlang.org/show_bug.cgi?id=17986 Issue ID: 17986 Summary: Erratic failure with std/experimental/allocator/common.d(445): unittest failure Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: regression Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: bugzi...@digitalmars.com Happens under the autotester: timelimit -t 90 generated/osx/debug/32/unittest/test_runner std.experimental.allocator.common ** FAIL debug32 std.experimental.allocator.common core.exception.AssertError@std/experimental/allocator/common.d(445): unittest failure 4 test_runner 0x013bb3b7 onAssertErrorMsg + 91 5 test_runner 0x013bb404 onUnittestErrorMsg + 28 6 test_runner 0x013bb644 _d_unittest_msg + 28 7 test_runner 0x013bb693 _d_unittest + 71 8 test_runner 0x013bb620 _d_unittestp + 56 9 test_runner 0x00f34472 void std.experimental.allocator.common.__unittest_std_experimental_allocator_common_d_404_9() + 322 10 test_runner 0x00f3373b void std.experimental.allocator.common.__modtest() + 55 11 test_runner 0x00051d17 void test_runner.doTest(object.ModuleInfo*, ref bool) + 91 12 test_runner 0x00051c40 bool test_runner.testModules() + 308 13 test_runner 0x00051b00 bool test_runner.tester() + 20 14 test_runner 0x013bc0f7 runModuleUnitTests + 187 15 test_runner 0x013d05dd void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() + 37 16 test_runner 0x013d055a void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) + 34 17 test_runner 0x013d04ab _d_run_main + 651 18 test_runner 0x000519d7 main + 55 19 test_runner 0x00051974 start + 52 20 ??? 0x0001 0x0 + 1 make[1]: *** [unittest/std/experimental/allocator/common.run] Error 1 --
Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?
On Friday, 17 November 2017 at 01:47:01 UTC, Michael V. Franklin wrote: It peeked my interested, because when I first started studying D, the lack of any warning or error for this trivial case surprised me. // Example A class Test { int Value; } void main(string[] args) { Test t; t.Value++; // No compiler error, or warning. Runtime error! } Also, if you start with nothing, and add 1 to it, you still end up with nothing, cause you started with nothing. That makes completed sense to me. So why should that be invalid?
Re: writeln, alias this and dynamic arrays.
On Friday, 17 November 2017 at 02:13:54 UTC, matthewh wrote: And with the toString override included it does. Why does the version without the toString override output an empty array? I think that is due to this bug: https://issues.dlang.org/show_bug.cgi?id=13189 It's actually on my todo list to fix, but I'm not sure yet if its within my current abilities. Mike
writeln, alias this and dynamic arrays.
I am new to D and have been fiddling with bits and pieces. I have this code: import std.stdio : writeln; import std.format : format; class Base { override { //string toString() //{ // return format("%s", store); //} } ubyte[] store; alias store this; this() { store = [1, 2, 3, 4, 5, 6, 7, 8]; } } class Top { Base store; alias store this; this() { store = new Base; } } void main() { auto f = new Top; writeln(f.store); writeln(f.store); } as is it produces: [1, 2, 3, 4, 5, 6, 7, 8] [] I expected it to produce: [1, 2, 3, 4, 5, 6, 7, 8] [1, 2, 3, 4, 5, 6, 7, 8] And with the toString override included it does. Why does the version without the toString override output an empty array? Thank you.
Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?
On Friday, 17 November 2017 at 01:47:01 UTC, Michael V. Franklin wrote: // Example A class Test { int Value; } void main(string[] args) { Test t; t.Value++; // No compiler error, or warning. Runtime error! } //Test t; Test t = new Test;
Re: Note from a donor
On Wednesday, 15 November 2017 at 04:34:09 UTC, Walter Bright wrote: On 11/14/2017 7:15 PM, solidstate1991 wrote: Walter Bright: What's the licensing state of DMC and OPTLINK? Boost Can it made open-source? Yes. If yes, we should patch in a COFF32/64 support, maybe even port it to D for easier development. I can spend some of my time working on the DLL support if needed. You're welcome to do it, it's something I've been meaning to do anyway. Optlink will never support MsCoff, you'll realize that when you look at the source :-( It's filled with Assembly code, and otherwise not very readable. Would need a lot of work, I don't think it would worth it. Let's hope that MS will allow us to distribute a linker alongside DMD.
Introducing Nullable Reference Types in C#. Is there hope for D, too?
I ran into this blog post today: https://blogs.msdn.microsoft.com/dotnet/2017/11/15/nullable-reference-types-in-csharp/ It peeked my interested, because when I first started studying D, the lack of any warning or error for this trivial case surprised me. // Example A class Test { int Value; } void main(string[] args) { Test t; t.Value++; // No compiler error, or warning. Runtime error! } https://run.dlang.io/is/naTgHC In C#, you get a compiler error. // Example B class Test { public int Value; } public class Program { public static void Main() { Test t; t.Value++; // Error: Use of unassigned local variable 't' } } https://dotnetfiddle.net/8diEiG But, it's not perfect: // Example C class Test { private static Test _instance; public static Test Instance { get { return _instance; } } public int Value; } public class Program { public static void Main() { Test t = Test.Instance; t.Value++; // No compiler error, or warning. Runtime error! } } https://dotnetfiddle.net/GEv2fh With Microsoft's proposed change, the compiler will emit a warning for Example C. If you want to opt out of the warning, you'll need to declare `_instance` as `Test? _instance` (see the '?' there). Notice that that is a "breaking" change for C#, but Microsoft still considers it an improvement to the language worth pursuing. Is there hope for D, too? Mike
Re: User defined type and foreach
On Fri, Nov 17, 2017 at 01:06:31AM +, Tony via Digitalmars-d-learn wrote: [...] > But I do have a complaint about the methods empty(), popFront() and > pop(). I think they should have a special syntax or name to reflect > that they are not general purpose methods. __empty() or preferably > __forEachDone(). empty() is typically used to say if a container has > no data, not if you are at the end of external foreach loop > processing. pop() and popFront() also would typically have different > meanings with certain containers and their names don't reflect that > they have a special "external foreach loop" purpose. It should be .empty, .popFront, and .front, not .pop. Also, these methods are *range* primitives, and over time, we have come to a consensus that generally speaking, it's a bad idea to conflate containers with ranges over containers. The main thing is that iterating over a range is supposed to consume it, which is usually not what you want with a container. The usual idiom is to separate the two concepts, and have the container provide a mechanism for returning a range over its contents, usually via .opIndex with no arguments, or .opSlice. Then you would just write: foreach (e; myContainer[]) { // [] calls .opIndex/.opSlice ... } Unfortunately, built-in arrays, which are also ranges, are one exception to this rule that, due to their ubiquity in D, also serve to mislead newcomers to D about when/where range primitives should be implemented. Generally speaking, built-in arrays should not be considered exemplary in this respect, but rather should be understood as exceptions. The general convention is to separate your containers from ranges over its contents, and to provide .opIndex / .opSlice that constructs a range over the container when needed. The other consideration is that if you don't really need range functionality, i.e., the only thing you want to do with your container is to put it in a foreach loop, then you can sidestep this whole mess and just implement .opApply for your container and call it a day. Of course, then you won't be able to use generic algorithms like those in std.algorithm with your container, but if you didn't intend to anyway, it's not a big deal. T -- Heads I win, tails you lose.
Re: User defined type and foreach
On Thursday, 16 November 2017 at 18:34:54 UTC, Steven Schveighoffer wrote: On 11/16/17 8:10 AM, ag0aep6g wrote: On 11/16/2017 09:03 AM, Tony wrote: However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods, rather than create a dynamic array. https://issues.dlang.org/show_bug.cgi?id=14619 I took a shot at fixing. Way more complex than I realized. I was initially miffed that I had added empty(), popFront() and pop() and they weren't being used, but I don't have a problem with using [] instead of them. Maybe call it a feature and document it. But I do have a complaint about the methods empty(), popFront() and pop(). I think they should have a special syntax or name to reflect that they are not general purpose methods. __empty() or preferably __forEachDone(). empty() is typically used to say if a container has no data, not if you are at the end of external foreach loop processing. pop() and popFront() also would typically have different meanings with certain containers and their names don't reflect that they have a special "external foreach loop" purpose.
Re: ESR on post-C landscape
On Thursday, 16 November 2017 at 11:52:45 UTC, Ola Fosheim Grostad wrote: Uhm, no? What do you mean by 'primary focus of program design' and in which context? I the context that, this is specifically what Stroustrup says in his book (The Design and Evolution of C++ 1994) "Simula's class concept was seen as the key difference, and ever since I have seen classes as the proper primary focus of program design." (chp1, page 20). Freud would tell us, that Stroustups obssesion with Simula, is where it all began. Stroustrup also wrote this paper in 1995 (due to all the hype of OO in the 90's), where again, he highlights how classes (and there derivatives) are his primary focus of program design: http://www.stroustrup.com/oopsla.pdf
Re: DConf 2018 Call for Submissions
On Thursday, 16 November 2017 at 18:08:07 UTC, Ali Çehreli wrote: For convenience, two talks by Chuck: http://dconf.org/2014/talks/allison.html Thanks. I must have missed this one. I'll watch it today. (youtube one seems to be missing though) http://dconf.org/2015/talks/allison.html Seen this, was berry berry interesting. and one by one of his students: http://dconf.org/2015/talks/gubler.html Ahh.. the enthusiasm of youth...those were the days... I think Eric's always going to look back on this video and ask himself..why did I say that.("..grease that barrier of entry into D.."). I'm stil trying to visualise that...but it's just not working for me.
Re: Should aliasing a lambda expression be allowed?
On Thursday, 16 November 2017 at 16:10:50 UTC, Meta wrote: int function(int) f1 = (int n) => n; int function(int) f2 = (char c) => c; Should be int function(char)
Re: DConf 2018 Logo
On Thu, Nov 16, 2017 at 08:21:41PM +, user1234 via Digitalmars-d wrote: > On Thursday, 16 November 2017 at 14:11:22 UTC, Dukc wrote: > > On Wednesday, 15 November 2017 at 14:56:53 UTC, Andrei Alexandrescu > > wrote: > > > Hello, for all of you with expertise in graphics, we'd be in your > > > debt if you could create a logo for DConf 2018. Proposals would be > > > appreciated! > > > > > > Thanks, > > > > > > Andrei > > > > Probably too crude to be worth considering but feel free to use it > > as base if here's someone who wan't to imporove it. > > > > https://imgur.com/a/eU4Id > > Nice, the subject is centered, the perspective is good ^^ For an official logo, though, I'd expect something more refined. The concept itself seems workable. T -- Живёшь только однажды.
Re: [OT] mobile rising
On Wednesday, 15 November 2017 at 11:46:48 UTC, Joakim wrote: I just saw this post about the upcoming Lenovo/AT Moto Tab and thought of you: https://www.phonearena.com/news/Lenovo-Moto-Tab-ATT-features_id99782 For $300, you can buy a tablet that lets you do everything you normally do on a tablet, plus watch TV on the go. If you want to use it for work, you buy the bluetooth accessories shown in that embedded promo youtube video and you can do that too. Want a screen in your kitchen, to control that optional speaker, watch recipe videos while you cook, and do video calls? That's a fairly new use case you can try out too. So for $300 or a bit more, depending on what accessories you get, you replace your laptop and TV, and have completely new things you can do. While this effort is fairly ambitious- having watched movies on my tablet with family members, similar to how the family in the video does, I can attest that your arms get tired holding the tablet out front like they do- seems to me that mobile convergence is only increasing. As for your mom and cousin going back to PCs, let me tell you about my own mom. Five years ago, we were both using Windows laptops: her chunky laptop for her business, my Win7 ultrabook for coding and recreation. Today, we both use Android tablets for these same uses- we're both on our second Android tablet now- plus she'll actually use her tablet at home now because a 10" tablet is nowhere as bulky as a Windows laptop. She never typed much in her business use, mostly reading emails and other viewing, so the laptop keyboard was always superfluous, but she had to have one because almost nobody was selling tablets a decade ago when she got it. Whereas, I paired a bluetooth keyboard with my tablet and get by just fine with that. The sales data I've linked shows that there are a lot more people like us than those you point out, and my point is that the mobile market is encroaching even on to people like your family, with products like that Moto Tab. btw, if you want to get back on-topic, simply change the topic of your post up top and write a post about the original topic, rather than posting in an OT thread about what we're talking about. I'm thinking on picking up some Android tablet for development purposes, would be good to port my game engine for mobile devices, probably have to resort for OpenGL for graphics acceleration instead of using CPU blitter, although that might work under NEON (currently I'm using SSE2).
Re: Zig mentions D in justifying its existence
On Tuesday, 14 November 2017 at 01:01:16 UTC, codephantom wrote: As someone new to D, I think this point stood out the most(for me): "C++, Rust, and D have a large number of features and it can be distracting from the actual meaning of the application you are working on. One finds themselves debugging their knowledge of the programming language instead of debugging the application itself." The best thing about language features, that you don't have to use them. I just very recently started using certain language features (eg. templates, conditional compilation), and for a long time I used it like Java without forcing classes into everything. Often I just don't find a use for them, so I won't make the compiler to do CTFE if it's not needed.
Re: ESR on post-C landscape
On Thursday, 16 November 2017 at 22:27:58 UTC, sarn wrote: In the 90s (and a bit into the 00s) there was a pretty extreme "everything must be an object; OO is the solution to everything" movement in the industry. Yes, around 1991, the computer mags were all over C++ and the bookshelves in the programming section of book stores too… Look around most programming languages today and you'll see objects, so in that sense OOP never failed. What failed was the hype train. It's no different from most other tech fads (except XML has declined drastically since the hype passed). *nods* I recall Kristen Nygaard (driving force behind OO and Simula) being sceptical of some of the drive away from OO modelling and towards OO-everything in the mid 90s. However in Scandinavia I think the focus was predominantly on supporting modelling. OOP is a way to support the model. I never heard any of the people behind OO suggest anything more than that OO was one paradigm among many. Nygaard also believed that OO modelling would be useful outside programming, as a mode-of-thinking when doing analysis, for instance in government. Of course there are plenty of pure OO languages that also are interesting in their own right: Smalltalk, Beta, gBeta, Self, and in online text games Moo. Javascript could have made it onto that list too, if it had been given a more suitable syntax and slightly different semantics.
Re: ESR on post-C landscape
On Tuesday, 14 November 2017 at 09:43:07 UTC, Ola Fosheim Grøstad wrote: ESR got famous for his cathedral vs bazaar piece, which IMO was basically just a not very insightful allegory over waterfall vs evolutionary development models, but since many software developers don't know the basics of software development he managed to become infamous for it… Everything ESR says is worth taking with a good dose of salt, but his "The Art of Unix Programming" isn't a bad read.
Re: DConf 2018 Logo
On Wednesday, 15 November 2017 at 14:56:53 UTC, Andrei Alexandrescu wrote: Hello, for all of you with expertise in graphics, we'd be in your debt if you could create a logo for DConf 2018. Proposals would be appreciated! Thanks, Andrei I think I'll do something in Illustrator, probably our mascot riding a rocket.
Re: ESR on post-C landscape
On Thursday, 16 November 2017 at 11:52:45 UTC, Ola Fosheim Grostad wrote: On Thursday, 16 November 2017 at 11:24:09 UTC, codephantom I would never say OO itself is a failure. But the idea that is should be the 'primary focus of program design' .. I think that is a failure...and I think that principle is generally accepted these days. Uhm, no? What do you mean by 'primary focus of program design' and in which context? In the 90s (and a bit into the 00s) there was a pretty extreme "everything must be an object; OO is the solution to everything" movement in the industry. Like most tech fads, it was associated with a lot of marketing and snake oil from people promising anything managers would pay money to hear (e.g., "use OO and your projects will be made up of reusable objects that you can simply drop into your next project!"). Look around most programming languages today and you'll see objects, so in that sense OOP never failed. What failed was the hype train. It's no different from most other tech fads (except XML has declined drastically since the hype passed).
Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation
can you post both code, java and d, for sure we are all testing the sames On Thu, Nov 16, 2017 at 8:37 PM, ade90036 via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > So, what is next? > > Can we enable some sort of profiling to see what is going on? >
Re: DConf 2018 Logo
On Thursday, 16 November 2017 at 14:11:22 UTC, Dukc wrote: On Wednesday, 15 November 2017 at 14:56:53 UTC, Andrei Alexandrescu wrote: Hello, for all of you with expertise in graphics, we'd be in your debt if you could create a logo for DConf 2018. Proposals would be appreciated! Thanks, Andrei Probably too crude to be worth considering but feel free to use it as base if here's someone who wan't to imporove it. https://imgur.com/a/eU4Id Nice, the subject is centered, the perspective is good ^^
Re: DConf 2018 Logo
On Wednesday, 15 November 2017 at 22:43:03 UTC, codephantom wrote: On Wednesday, 15 November 2017 at 14:56:53 UTC, Andrei Alexandrescu wrote: Hello, for all of you with expertise in graphics, we'd be in your debt if you could create a logo for DConf 2018. Proposals would be appreciated! Thanks, Andrei I can't draw, sadly. But an idea: D rocket..taking off... (that seems to be the theme at the moment ;-) 1/ Do you see the D ? http://medias.micromania.fr/catalog/product/cache/1/image/940x500/9584d58a0ae6a5dee7a3194ff248c49a/c/h/choppe_stark.jpg replace the text with - DConf 2018 - --- Munich --- maybe the D first, in the other direction (vertical mirror) and conf on the glass Ɋ 2/ Include the D in a biceps http://www.simpsonspark.com/images/references/cartoons/popeye/austere4.jpg
Re: Language server protocol
On Thursday, 16 November 2017 at 19:42:09 UTC, Arun Chandrasekaran wrote: On Thursday, 16 November 2017 at 19:22:37 UTC, Johannes Pfau wrote: https://github.com/Pure-D/serve-d -- Johannes BTW, what are the feature available with serve-d? Does it support all of the below? Code completion, Hover, Jump to def, Workspace symbols, Find references, Stream reference results, Diagnostics I'll try to get in touch with WebFreak. Yes, Yes, Yes, Yes, No, No, Yes Also some additional features available via commands
Re: Deprecate implicit `int` to `bool` conversion for integer literals
On 11/16/2017 02:29 AM, Michael V. Franklin wrote: On Thursday, 16 November 2017 at 07:24:44 UTC, Andrei Alexandrescu wrote: Try it here: https://run.dlang.io/is/nfMGfG DMD-nightly Cool, thanks. That seems to be an unrelated bug. Have you added it to bugzilla? Thanks! -- Andrei Bugzilla Issue is here: https://issues.dlang.org/show_bug.cgi?id=17983 Mike Gracias! -- Andrei
Re: Language server protocol
On Thursday, 16 November 2017 at 19:22:37 UTC, Johannes Pfau wrote: https://github.com/Pure-D/serve-d -- Johannes BTW, what are the feature available with serve-d? Does it support all of the below? Code completion, Hover, Jump to def, Workspace symbols, Find references, Stream reference results, Diagnostics I'll try to get in touch with WebFreak.
Re: Language server protocol
On Thursday, 16 November 2017 at 19:22:37 UTC, Johannes Pfau wrote: Am Thu, 16 Nov 2017 19:09:14 + https://github.com/Pure-D/serve-d We should probably get it listed in the homepage.
Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation
So, what is next? Can we enable some sort of profiling to see what is going on?
Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation
Mediocre result... let me create a java equivalent program so we have a direct comparison.. These are the tests for a similar program in java. bombardier -c 200 -n 1 http://localhost:8081 Bombarding http://localhost:8081/ with 1 requests using 200 connections 1 / 1 [==] 100.00% 0s Done! StatisticsAvg StdevMax Reqs/sec 24527.29 14797.09 46439 Latency8.25ms15.52ms 235.79ms HTTP codes: 1xx - 0, 2xx - 1, 3xx - 0, 4xx - 0, 5xx - 0 others - 0 Throughput: 3.87MB/s
Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation
Result: bombardier -c 200 -n 1 http://localhost: Bombarding http://localhost: with 1 requests using 200 connections 1 / 1 [===] 100.00% 1m24s Done! StatisticsAvg StdevMax Reqs/sec 122.27 909.33 20363 Latency 49.98ms 192.16ms 1.07s HTTP codes: 1xx - 0, 2xx - , 3xx - 0, 4xx - 0, 5xx - 0 others - 1 Errors: the server closed connection before returning the first response byte. Make sure the server returns 'Connection: close' response header before closing the connection - 1 Throughput:36.89KB/s Mediocre result... let me create a java equivalent program so we have a direct comparison..
Re: Language server protocol
Am Thu, 16 Nov 2017 19:09:14 + schrieb Arun Chandrasekaran: > Is someone working on D community to implement > https://langserver.org ? > > What will the D community miss out if we ignore LSP? > > PS: HackerPilot's tools are very helpful. https://github.com/Pure-D/serve-d -- Johannes
Language server protocol
Is someone working on D community to implement https://langserver.org ? What will the D community miss out if we ignore LSP? PS: HackerPilot's tools are very helpful.
Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation
On Thursday, 16 November 2017 at 18:44:11 UTC, Daniel Kozak wrote: It works for me because I have multiple threads, but when I use only one thread per pool (defaultPoolThreads(1)), it obviosly blocks, which is correct behavior Ok, let me force the: "defaultPoolThreads(8)" and let me re-test it. By the way, if the socket is blocking you can remove all the socketSet and the socket.select as they are not needed anymore. like this.. https://dpaste.dzfl.pl/ca09e4c54789
[Issue 17985] New: Implement -stdin for rdmd
https://issues.dlang.org/show_bug.cgi?id=17985 Issue ID: 17985 Summary: Implement -stdin for rdmd Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: tools Assignee: nob...@puremagic.com Reporter: an...@s-e-a-p.de Similiar to the -stdin enhancement for dmd (https://github.com/dlang/dmd/pull/6880) it would make sense to implement it for rdmd too. This would enable following command: echo import std.stdio; void main() { writeln("Success"); } | rdmd - --
Re: ESR on post-C landscape
On Thursday, 16 November 2017 at 18:02:10 UTC, Patrick Schluter wrote: The shear amount of inscrutable cruft and rules, plus the moving target of continuously changing semantics an order or two of magnitude bigger than C added to the fact that you still need to know C's gotchas, makes it one or two order of magnitude more difficult to mental model the hardware. I don't feel that way, most of what C++ adds to C happens on a typesystem or textual level. The core language is similar to C. Even worse in C++ with its changing standards ever 5 years. But those features are mostly short hand for things that already are in the language. E.g. lambdas are just objects, move semantics is just an additional nominal ref type with barely any semantics attached to it (some rules for coercion to regular references)... So while these things make a difference, it doesn't change my low level mental model of C++, which remain as close to C today as it did in the 90s.
Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation
It works for me because I have multiple threads, but when I use only one thread per pool (defaultPoolThreads(1)), it obviosly blocks, which is correct behavior On Thu, Nov 16, 2017 at 7:20 PM, Daniel Kozakwrote: > Hmm works ok for me. What OS? > > Dne 16. 11. 2017 12:05 dop. napsal uživatel "kdevel via > Digitalmars-d-learn" : > > On Wednesday, 15 November 2017 at 13:31:46 UTC, Daniel Kozak wrote: >> >>> This one works ok for me, but I am on linux: >>> https://dpaste.dzfl.pl/f54decee45bc >>> >> >> It works, but it does not handle two connects in parallel. STR: >> >> 1. start the binary in console 1 >> 2. telnet localhost in console 2 >> 3. telnet localhost in console 3 >> 4. enter a [RETURN] in console (3) >> >> observed: nothing (the "thread" handling the first connect blocks) >> expected: response >> >> On my machine defaultPoolThreads() returns 1. This can easily be >> increased: >> >> ``` >>defaultPoolThreads(8); >> ``` >> >> There is also another problem with Socket.select: It may return -1. This >> frequently happens when the ACCEPT socket is non-blocking and the select is >> interrupted (by the GC?) then errno == EINTR. >> >> Also not having a timeout in the Socket.select of handle_socket allows >> for DOS attacks like the one above. In case of a timeout select also >> returns -1. >> >
Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation
On Thursday, 16 November 2017 at 18:20:36 UTC, Daniel Kozak wrote: Hmm works ok for me. What OS? Dne 16. 11. 2017 12:05 dop. napsal uživatel "kdevel via Digitalmars-d-learn": [...] I'm running MacOS..
[Issue 10310] VRP for bitwise &|^ does not always produce the tightest bounds.
https://issues.dlang.org/show_bug.cgi?id=10310 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --
[Issue 10310] VRP for bitwise &|^ does not always produce the tightest bounds.
https://issues.dlang.org/show_bug.cgi?id=10310 --- Comment #5 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/1757224765982088b8454500aeecdd0a08473475 VRP and,or,xor + fix issue 10310 https://github.com/dlang/dmd/commit/6395d48df6cc0f809c4dcb8b2e25b43d34908628 Merge pull request #7317 from somzzz/vrp_andOr VRP for and,or,xor + Refactoring intrange.d + Fix Issue 10310 merged-on-behalf-of: Andrei Alexandrescu--
Re: User defined type and foreach
On 11/16/17 8:10 AM, ag0aep6g wrote: On 11/16/2017 09:03 AM, Tony wrote: However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods, rather than create a dynamic array. https://issues.dlang.org/show_bug.cgi?id=14619 I took a shot at fixing. Way more complex than I realized. -Steve
[Issue 14619] foreach implicitly slices ranges
https://issues.dlang.org/show_bug.cgi?id=14619 Steven Schveighofferchanged: What|Removed |Added CC||schvei...@yahoo.com --- Comment #3 from Steven Schveighoffer --- So I tried fixing this in a simple way (simply preferring the presence of the range functions over opSlice), and the first place I see a failure is druntime's rt.util.container.array.Array: https://github.com/dlang/druntime/blob/master/src/rt/util/container/array.d#L14 This type is not copyable, and has opSlice, front, back, popBack, empty, but not popFront. My first attempt was just to prefer front over opSlice (was surprised to see that only front is searched for), and obviously Array has this so it fails to compile (cannot be copied). My second attempt is to require front, popFront, and empty (or back popBack and empty if foreach_reverse). There were a few tests with foreach_reverse on an Array, and this fails (cannot be copied). So really, the foreachable range definition is that it needs front/back, popFront/popBack, and empty, AND it needs to be copyable. The problem is that the code that determines WHICH aggregate to use (or whether opApply should be used or not), is run FIRST, and THEN the compiler tries to compile with those choices. So the Array type fails because it first picks to use the range functions in Array, but then realizes it cannot use that in foreach. What I would expect is the following logic: 1. If opApply is present, use it. 2. If foreach with front, popFront, empty (or back, popBack, empty) compiles, then use it. 3. If the aggregate can slice, do it, and check for range primitives, don't try and slice again. The key here in the second step (to get Array to work) is that the reduced for-line should compile. Even this logic has issues, because there could be other reasons it doesn't compile. Part of me says the error here is in Array, and not the compiler (don't define back, popBack, and empty if you don't want it to be foreachable directly). The current logic is: 1. If opApply is present, use it. 2. If it can slice, then do it. Assume the resulting type has range primitives. 3. If it can't slice, try range primitives. In order to reorder the logic, I have to combine the two functions, and rearrange the original logic. Moving one simple piece of logic around was within my capabilities, but this is like a complete rewrite, and the code is VERY complex if you don't know what everything means, or the right tools to use. So I give up, but it definitely can be done. The code that generates the pseudo for-loop: https://github.com/dlang/dmd/blob/ba36f3a3b2f82fd1ec249476e4477a6a3457aad3/src/ddmd/opover.d#L1729 And the code that figures out whether to slice the aggregate (called very early in the above function): https://github.com/dlang/dmd/blob/ba36f3a3b2f82fd1ec249476e4477a6a3457aad3/src/ddmd/opover.d#L1729 --
Re: ESR on post-C landscape
On Thursday, 16 November 2017 at 18:06:22 UTC, Patrick Schluter wrote: On Tuesday, 14 November 2017 at 16:38:58 UTC, Ola Fosheim Grostad wrote: changing. C no longer models the hardware in a reasonable manner. Because of the flawed interpretation of UB by the compiler writers, not because of a property of the language itself. No, I am talking about the actual hardware, not UB. In the 80s there was almost 1-to-1 correspondence between C and CPU internals. CPUs are still designed for C, but the more code shift away from C, the more rewarding it will be for hardware designers to move to more parallell designs.
Re: Inference of GC allocation scope
On Thursday, 16 November 2017 at 17:39:02 UTC, Petar Kirov [ZombineDev] wrote: https://github.com/ldc-developers/ldc/blob/master/gen/passes/GarbageCollect2Stack.cpp Does this include GC allocations that don't fit on stack?
Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation
Hmm works ok for me. What OS? Dne 16. 11. 2017 12:05 dop. napsal uživatel "kdevel via Digitalmars-d-learn": > On Wednesday, 15 November 2017 at 13:31:46 UTC, Daniel Kozak wrote: > >> This one works ok for me, but I am on linux: >> https://dpaste.dzfl.pl/f54decee45bc >> > > It works, but it does not handle two connects in parallel. STR: > > 1. start the binary in console 1 > 2. telnet localhost in console 2 > 3. telnet localhost in console 3 > 4. enter a [RETURN] in console (3) > > observed: nothing (the "thread" handling the first connect blocks) > expected: response > > On my machine defaultPoolThreads() returns 1. This can easily be increased: > > ``` >defaultPoolThreads(8); > ``` > > There is also another problem with Socket.select: It may return -1. This > frequently happens when the ACCEPT socket is non-blocking and the select is > interrupted (by the GC?) then errno == EINTR. > > Also not having a timeout in the Socket.select of handle_socket allows for > DOS attacks like the one above. In case of a timeout select also returns -1. >
Re: DConf 2018 Call for Submissions
On 11/16/2017 12:20 AM, Mike James wrote: On Thursday, 16 November 2017 at 00:45:58 UTC, codephantom wrote: I would like to see Chuck Allison talk about the experiences of students approaching D. Chucks already done a talk like that - it was berry, berry good... For convenience, two talks by Chuck: http://dconf.org/2014/talks/allison.html http://dconf.org/2015/talks/allison.html and one by one of his students: http://dconf.org/2015/talks/gubler.html Ali
Re: ESR on post-C landscape
On Tuesday, 14 November 2017 at 16:38:58 UTC, Ola Fosheim Grostad wrote: On Tuesday, 14 November 2017 at 11:55:17 UTC, codephantom wrote: [...] Well, in another thread he talked about the Tango split, so not sure where he is coming from. [...] No, the starting point for C++ was that Simula is better for a specific kind of modelling than C. [...] It is flawed... ESR got that right, not sure how anyone can disagree. The only thing C has going for it is that CPU designs have been adapted to C for decades. But that is changing. C no longer models the hardware in a reasonable manner. Because of the flawed interpretation of UB by the compiler writers, not because of a property of the language itself.
Re: ESR on post-C landscape
On Tuesday, 14 November 2017 at 09:43:07 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 14 November 2017 at 06:32:55 UTC, lobo wrote: "[snip]...Then came the day we discovered that a person we incautiously gave commit privileges to had fucked up the games’s AI core. It became apparent that I was the only dev on the team not too frightened of that code to go in. And I fixed it all right – took me two weeks of struggle. After which I swore a mighty oath never to go near C++ again. ...[snip]" Either no one manages SW in his team so that this "bad" dev could run off and to build a monster architecture, which would take weeks, or this guy has no idea how to revert commit. ESR got famous for his cathedral vs bazaar piece, which IMO was basically just a not very insightful allegory over waterfall vs evolutionary development models, but since many software developers don't know the basics of software development he managed to become infamous for it… But I think embracing emergence has hurt open source projects more than it has helped it. D bears signs of too much emergence too, and is still trying correct those «random moves» with DIPs. ESR states «C is flawed, but it does have one immensely valuable property that C++ didn’t keep – if you can mentally model the hardware it’s running on, you can easily see all the way down. If C++ had actually eliminated C’s flaws (that it, been type-safe and memory-safe) giving away that transparency might be a trade worth making. As it is, nope.» I don't think this is true, you can reduce C++ down to the level where it is just like C. If he cannot mentally model the hardware in C++ that basically just means he has never tried to get there… The shear amount of inscrutable cruft and rules, plus the moving target of continuously changing semantics an order or two of magnitude bigger than C added to the fact that you still need to know C's gotchas, makes it one or two order of magnitude more difficult to mental model the hardware. You can also mental model the hardware with Intercal, if you haven't managed just means you haven't tried hard enough. I also think he is in denial if he does not see that C++ is taking over C. Starting a big project in C today sounds like a very bad idea to me. Even worse in C++ with its changing standards ever 5 years.
Re: Inference of GC allocation scope
On Thursday, 16 November 2017 at 17:29:56 UTC, Nordlöw wrote: Are there any plans on a compiler pass that finds scoped GC-allocations and makes their destructors deterministic similar to D's struct scope behaviour? https://github.com/ldc-developers/ldc/blob/master/gen/passes/GarbageCollect2Stack.cpp
Inference of GC allocation scope
Are there any plans on a compiler pass that finds scoped GC-allocations and makes their destructors deterministic similar to D's struct scope behaviour?
Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation
On Wednesday, 15 November 2017 at 23:04:46 UTC, kdevel wrote: On Wednesday, 15 November 2017 at 13:31:46 UTC, Daniel Kozak wrote: This one works ok for me, but I am on linux: https://dpaste.dzfl.pl/f54decee45bc It works, but it does not handle two connects in parallel. STR: 1. start the binary in console 1 2. telnet localhost in console 2 3. telnet localhost in console 3 4. enter a [RETURN] in console (3) observed: nothing (the "thread" handling the first connect blocks) expected: response On my machine defaultPoolThreads() returns 1. This can easily be increased: ``` defaultPoolThreads(8); ``` There is also another problem with Socket.select: It may return -1. This frequently happens when the ACCEPT socket is non-blocking and the select is interrupted (by the GC?) then errno == EINTR. Also not having a timeout in the Socket.select of handle_socket allows for DOS attacks like the one above. In case of a timeout select also returns -1. Hi Guys, so i have tried the latest changes with destroy(socket) rather than socket.close(). Still the program is extremely slow. I see that the httpclinet is making successfully 100 request at a time and then it freezes for 5/10 seconds and then it process another 100 request. As Kdevel pointed out, this could be related to the Socket.select blocking on the interupt or it would be GC kicking in. I also have seen the value computed for the defaultThread is not correct, hence i manually started the TaskPool(int thread) manually. I'm going to share my benchmark program so you can guys test with the same tool. Unfortunately it seems that there is some underline issue which is blocking the program and preventing to process all the incoming requests in a performant fashion, or at-least utilising the full CPU cycles. reagrds ade90036
Re: Should aliasing a lambda expression be allowed?
On Thursday, 16 November 2017 at 13:05:51 UTC, Petar Kirov [ZombineDev] wrote: On Wednesday, 15 November 2017 at 19:29:29 UTC, Steven Schveighoffer wrote: On 11/15/17 11:59 AM, Andrea Fontana wrote: On Wednesday, 15 November 2017 at 15:25:06 UTC, Steven Schveighoffer wrote: alias foo = lambda1; alias foo = lambda2; What? Yep. Would never have tried that in a million years before seeing this thread :) But it does work. Tested with dmd 2.076.1 and 2.066. So it's been there a while. -Steve I guess you guys haven't been keeping up with language changes :P https://dlang.org/changelog/2.070.0.html#alias-funclit And yes, you can use 'alias' to capture overload sets. See also: https://github.com/dlang/dmd/pull/1660/files https://github.com/dlang/dmd/pull/2125/files#diff-51d0a1ca6214e6a916212fcbf93d7e40 https://github.com/dlang/dmd/pull/2417/files https://github.com/dlang/dmd/pull/4826/files https://github.com/dlang/dmd/pull/5162/files https://github.com/dlang/dmd/pull/5202 https://github.com/dlang/phobos/pull/5818/files Yes, as far as I understand this is just the normal way that you add a symbol to an existing overload set, except now it also interacts with the functionality of using an alias to create a named function literal. Kind of interesting because I don't think it was possible to do this before, e.g.: int function(int) f1 = (int n) => n; int function(int) f2 = (char c) => c; Would obviously be rejected by the compiler. However, using the alias syntax we can create an overload set from function literals in addition to regular functions.
Re: DConf 2018 Logo
On Wednesday, 15 November 2017 at 14:56:53 UTC, Andrei Alexandrescu wrote: Hello, for all of you with expertise in graphics, we'd be in your debt if you could create a logo for DConf 2018. Proposals would be appreciated! Thanks, Andrei Probably too crude to be worth considering but feel free to use it as base if here's someone who wan't to imporove it. https://imgur.com/a/eU4Id
Re: User defined type and foreach
On Thursday, 16 November 2017 at 13:35:13 UTC, Tony wrote: On Thursday, 16 November 2017 at 13:10:11 UTC, ag0aep6g wrote: On 11/16/2017 09:03 AM, Tony wrote: However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods, rather than create a dynamic array. https://issues.dlang.org/show_bug.cgi?id=14619 And also this one which was marked as a duplicate of yours https://issues.dlang.org/show_bug.cgi?id=16374 "When lowering a foreach, the compiler gives priority to opSlice over front/popFront/empty, which is counter-intuitive (and also undocumented)." "opSlice" -> "opSlice or opIndex". That should be "opSlice or opIndex-with-no-parameters"
Re: User defined type and foreach
On Thursday, 16 November 2017 at 13:10:11 UTC, ag0aep6g wrote: On 11/16/2017 09:03 AM, Tony wrote: However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods, rather than create a dynamic array. https://issues.dlang.org/show_bug.cgi?id=14619 And also this one which was marked as a duplicate of yours https://issues.dlang.org/show_bug.cgi?id=16374 "When lowering a foreach, the compiler gives priority to opSlice over front/popFront/empty, which is counter-intuitive (and also undocumented)." "opSlice" -> "opSlice or opIndex".
Re: User defined type and foreach
On Thursday, 16 November 2017 at 12:56:18 UTC, Steven Schveighoffer wrote: On 11/16/17 3:03 AM, Tony wrote: I made a stack data type and created an opIndex() so it could be turned into a dynamic array, and created empty() (unfortunate name), front() and popFront() methods, which I read allow it to be used with foreach. However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods, rather than create a dynamic array. Remove the opIndex, and see if it works. If it does, then this is a bug. The compiler should try to use the type as a range before seeing if opIndex gives it something. Yes, if I remove opIndex() from the class, doing a foreach loop causes popFront(),empty(), and front() to be called and the foreach loop works.
Re: User defined type and foreach
On 11/16/2017 09:03 AM, Tony wrote: However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods, rather than create a dynamic array. https://issues.dlang.org/show_bug.cgi?id=14619
Re: Should aliasing a lambda expression be allowed?
On Wednesday, 15 November 2017 at 19:29:29 UTC, Steven Schveighoffer wrote: On 11/15/17 11:59 AM, Andrea Fontana wrote: On Wednesday, 15 November 2017 at 15:25:06 UTC, Steven Schveighoffer wrote: alias foo = lambda1; alias foo = lambda2; What? Yep. Would never have tried that in a million years before seeing this thread :) But it does work. Tested with dmd 2.076.1 and 2.066. So it's been there a while. -Steve I guess you guys haven't been keeping up with language changes :P https://dlang.org/changelog/2.070.0.html#alias-funclit And yes, you can use 'alias' to capture overload sets. See also: https://github.com/dlang/dmd/pull/1660/files https://github.com/dlang/dmd/pull/2125/files#diff-51d0a1ca6214e6a916212fcbf93d7e40 https://github.com/dlang/dmd/pull/2417/files https://github.com/dlang/dmd/pull/4826/files https://github.com/dlang/dmd/pull/5162/files https://github.com/dlang/dmd/pull/5202 https://github.com/dlang/phobos/pull/5818/files
Re: User defined type and foreach
On 11/16/17 3:03 AM, Tony wrote: I made a stack data type and created an opIndex() so it could be turned into a dynamic array, and created empty() (unfortunate name), front() and popFront() methods, which I read allow it to be used with foreach. However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods, rather than create a dynamic array. Remove the opIndex, and see if it works. If it does, then this is a bug. The compiler should try to use the type as a range before seeing if opIndex gives it something. -Steve
Re: DConf 2018 Logo
On Wednesday, 15 November 2017 at 22:43:03 UTC, codephantom wrote: On Wednesday, 15 November 2017 at 14:56:53 UTC, Andrei Alexandrescu wrote: Hello, for all of you with expertise in graphics, we'd be in your debt if you could create a logo for DConf 2018. Proposals would be appreciated! Thanks, Andrei I can't draw, sadly. But an idea: D rocket..taking off... (that seems to be the theme at the moment ;-) Graphic design is not my strength, but perhaps something like this? https://imgur.com/a/dJapO
Re: ESR on post-C landscape
On Thursday, 16 November 2017 at 11:24:09 UTC, codephantom wrote: On Thursday, 16 November 2017 at 06:35:30 UTC, Ola Fosheim Grostad wrote: Yes, I agree that classes are a powerful modelling primitive, but my point was that Stroustrup made classes the 'primary focus of program design'. Yes, that made it more uniform alright... uniformly more complicated. And why? Because he went on to throw C into the mix, because performance in Simula was so poor, and would not scale. C promised the efficiency and scalability he was after. But an efficient and scalable 'class oriented' language, means complexity was inevitable. Nah, he is just making excuses. Simula wasn't particularly slow as a design, but used a GC similar to the one in D and bounds checks on arrays, like D. C++ was just a simple layer over C and evolved from that. Had nothing to do with language design, but was all about cheap implementation. Initial version of C++ was cheap and easy to do. I would never say OO itself is a failure. But the idea that is should be the 'primary focus of program design' .. I think that is a failure...and I think that principle is generally accepted these days. Uhm, no? What do you mean by 'primary focus of program design' and in which context? If the next C++ doesn't get modules, that'll be the end of it...for sure. I like namespaces. Flat is generally better when you want explicit qualifications. Yeah..but into what? It's all those furry gopher toys, t-shirts, and playful colors.. I think that's what's attracting people to Go. Google is the master of advertising afterall. Would work well in a kindergarten. But it makes me want to puke. It's so fake. It is the runtime and standard library. And stability. Nice for smaller web services. correct the past. They should be focused on the future. They should have got some experienced younger programmers at google to design a language instead. I bet it wouldn't look anything like Go. Go isnt exciting and has some short-comings that is surprising, but they managed to reach a stable state, which is desirable when writing server code. It is this stability that has ensured that they could improve on the runtime. ("experienced young programmers" is a rather contradictory term, btw :-)
Re: ESR on post-C landscape
On Thursday, 16 November 2017 at 06:35:30 UTC, Ola Fosheim Grostad wrote: No, classes is a powerful modelling primitive. C++ got that right. C++ is also fairly uniform because of it. Yes, I agree that classes are a powerful modelling primitive, but my point was that Stroustrup made classes the 'primary focus of program design'. Yes, that made it more uniform alright... uniformly more complicated. And why? Because he went on to throw C into the mix, because performance in Simula was so poor, and would not scale. C promised the efficiency and scalability he was after. But an efficient and scalable 'class oriented' language, means complexity was inevitable. It wasn't a bad decision on his part. It was right for the time I guess. But it set the stage for its demise I believe. People who harp about how OO is a failure don't know how to do real world modelling... I would never say OO itself is a failure. But the idea that is should be the 'primary focus of program design' .. I think that is a failure...and I think that principle is generally accepted these days. I have to wonder whether that conclusion sparked the inevitable demise of C++. There is no demise... If the next C++ doesn't get modules, that'll be the end of it...for sure. Eric should be asking a similar question about Go ..what decision has been made that sparked Go's inevitable demise - or in the case of Go, decision would be decisions. Go is growing... Yeah..but into what? It's all those furry gopher toys, t-shirts, and playful colors.. I think that's what's attracting people to Go. Google is the master of advertising afterall. Would work well in a kindergarten. But it makes me want to puke. It's so fake. a := b A practical shorthand, if you dont like it, then dont use it. Was just a senseless, unnecessary change. The immediate impression I got, was that they were trying to undo a decision, that was made when B was developed, rather doing it because it really assisted the modern programmer (what language uses that? None that I use that's for sure). And I get that feeling about other decisions they've made...as if they are just trying to correct the past. They should be focused on the future. They should have got some experienced younger programmers at google to design a language instead. I bet it wouldn't look anything like Go.
Re: User defined type and foreach
On Thursday, November 16, 2017 08:43:17 Tony via Digitalmars-d-learn wrote: > On Thursday, 16 November 2017 at 08:26:25 UTC, Andrea Fontana > > wrote: > > On Thursday, 16 November 2017 at 08:03:48 UTC, Tony wrote: > >> I made a stack data type and created an opIndex() so it could > >> be turned into a dynamic array, and created empty() > >> (unfortunate name), front() and popFront() methods, which I > >> read allow it to be used with foreach. > >> > >> However, when I use the class with foreach, the opindex gets > >> called to create a dynamic array, rather than use the > >> empty(),front(),popFront() routines. I would prefer it use the > >> three methods, rather than create a dynamic array. > > > > You can try to implement opApply(). > > Check: > > http://ddili.org/ders/d.en/foreach_opapply.html > > Thanks. Interesting that that page does not mention the behavior > I am seeing, which is that foreach over a user-defined datatype > can be implemented with only a 'T[] opIndex()' method. What you're seeing is intended for containers. If you implement opIndex or opSlice with no parameters so that you can slice the object with no indices, the idea is that it's going to return a range. foreach knows about this so that you can then iterate over a container with foreach rather than having to explicitly call a function on the container to get the range to then iterate over. e.g. with RedBlackTree rbt; ... you can do foreach(e; rbt) {...} instead of foreach(e; rbt[]) {...} though if you then pass the container to a range-based function, you're still going to have to explicitly slice it. - Jonathan M Davis
Re: The latest Terrarium TV 1.8.1 has been updated.
On Wednesday, 8 November 2017 at 09:40:01 UTC, Theresa Henson wrote: The update is compatible with the latest Android OS as well as all others over Android 4.0 Here are updated version of Terrarium TV: https://terrariumtvforpcdownload.com/terrarium-tv-apk/
Re: Treating a slice as an InputRange
On Wednesday, November 15, 2017 22:48:12 unleashy via Digitalmars-d-learn wrote: > On Wednesday, 15 November 2017 at 21:02:35 UTC, Jonathan M Davis > wrote: > > If you specifically want a function to accept a range and > > mutate it without returning it, then it should take its > > argument by ref. Having it take auto ref is actually quite odd, > > since that means that the behavior can depend on whether an > > lvalue or rvalue is passed in. > > I was under the impression that templated parameters needed `auto > ref` to work as `ref` properly. Good to know that's not true. What auto ref does is make it so that the parameter is infered as ref if the argument is an lvalue and infered as non-ref if it's an rvalue. That way, lvalues get passed by references, and rvalues get moved. It's really not the sort of thing you use when you intend to mutate the parameter. It's either used with the intent of avoiding copying (similar to when you use const T& in C++), or it's used to forward the refness of the argument (e.g. that's important with something like emplace, which forwards the arguments to the constructor of the type being constructed). Because auto ref generates different template instantiations based on the refness of the type, it only works with templated functions, but ref in general doesn't function any differently with templates than it does with non-templates. - Jonathan M Davis
Re: Zig mentions D in justifying its existence
On Thursday, 16 November 2017 at 02:48:27 UTC, Tony wrote: I am surprised C hasn't tried to become a "better C". Most of the people that wanted to work on a spec for a better C has already moved to C++ or other languages. The ones that remain want C to stay simple, but they have added new stuff, even generics: https://en.wikipedia.org/wiki/C11_(C_standard_revision) Ola
Re: Bloat in Executable
On Thursday, 16 November 2017 at 03:32:26 UTC, codephantom wrote: // --- module test; import core.stdc.stdio; extern (C) int main() { printf("hello world\n"); return 0; } // --- compiled with dmd v2.077.0, using the -betterC option, I get: .. on windows .. 23k executable if 32bit (i.e. -m32 ) 112k executable if 64bit (i.e. -m64 ) .. on freebsd .. 5.6k executable if 32bit (i.e. -m32 ) 7.5k executable if 64bit (i.e. -m64 ) This is not meant to be an anti-windows thing...so let me stop those responses right here. I am genuinely interested in understanding why the 'order of magnitude' increase for the 64bit executable on Windows? If you're worried about executable size, you're probably better off using ldc on non-Windows platforms, because David made ldc work with the linker's --gc-sections. I don't think that work was ever done for dmd, which is why ldc invokes --gc-sections by default for non-MSVC targets but dmd doesn't.
Re: User defined type and foreach
On Thursday, 16 November 2017 at 08:26:25 UTC, Andrea Fontana wrote: On Thursday, 16 November 2017 at 08:03:48 UTC, Tony wrote: I made a stack data type and created an opIndex() so it could be turned into a dynamic array, and created empty() (unfortunate name), front() and popFront() methods, which I read allow it to be used with foreach. However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods, rather than create a dynamic array. You can try to implement opApply(). Check: http://ddili.org/ders/d.en/foreach_opapply.html Thanks. Interesting that that page does not mention the behavior I am seeing, which is that foreach over a user-defined datatype can be implemented with only a 'T[] opIndex()' method.
Re: User defined type and foreach
On Thursday, 16 November 2017 at 08:03:48 UTC, Tony wrote: I made a stack data type and created an opIndex() so it could be turned into a dynamic array, and created empty() (unfortunate name), front() and popFront() methods, which I read allow it to be used with foreach. However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods, rather than create a dynamic array. You can try to implement opApply(). Check: http://ddili.org/ders/d.en/foreach_opapply.html
Re: DConf 2018 Call for Submissions
On Thursday, 16 November 2017 at 00:45:58 UTC, codephantom wrote: On Wednesday, 15 November 2017 at 23:53:40 UTC, Ali Çehreli wrote: I would like to see Chuck Allison talk about the experiences of students approaching D. I think that would be really worthwhile - or even yourself for that matter, given your strong interest in this area. Technical stuff is good and helpful, but I like to know about peoples experiences too...that's what really interests me the most, and should be at the core of any language design. So somebody examining D from this perspective could be really insightful to those contributing to the language. It's really critical that D remain accessible to newcomers, or its' replacement is just around the corner. Chucks already done a talk like that - it was berry, berry good... -=mike=-
User defined type and foreach
I made a stack data type and created an opIndex() so it could be turned into a dynamic array, and created empty() (unfortunate name), front() and popFront() methods, which I read allow it to be used with foreach. However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods, rather than create a dynamic array.