Re: Status of Win32 C++ interop
On Monday, 7 September 2015 at 19:30:44 UTC, drug wrote: 07.09.2015 21:37, Benjamin Thaut пишет: snip So far I haven't found a situation where I couldn't make it work the way I wanted. Its just some work to write the D headers for the C++ classes and vise versa, because you have to duplicate everything once more. An automated tool for this would be nice, but unfotunately there is currently none. Kind Regards Benjamin Thaut It's great. But isn't it based on your custom modifications of compiler and the others? No, the compiler modifications are only for the Windows DLL support. All modifications I did to the c++ binding are already in 2.068
Re: Benchmarking suite
On Tuesday, 8 September 2015 at 08:24:43 UTC, Robert burner Schadek wrote: Why not go really big. aka: http://forum.dlang.org/post/vzcvwrbqpeamtnopm...@forum.dlang.org You suggest to create a benchmark suite from all the unittests in Phobos? I don't think this is a good idea. Most programs don't make good performance tests. Even the Benchmarks Game / Shootout benchmarks are partially stupid. For example, threadring measures context switching. The best strategy is "use pthreads and pthread mutex and restrict to one core". It only shows how good your language can access the pthread API. The context switching is done by Linux. The pidigits programs basically measures libGMP performance. I'm all for adding more programs into the benchmark suite, but they should be carefully selected to measure different aspects. I don't understand all the programs enough to know what is lacking. Probably some memory management aspects. Maybe some concurrency stuff.
Re: What's the "right" way to do openmp-style parallelism?
On Tuesday, 8 September 2015 at 05:50:30 UTC, Russel Winder wrote: void main() { immutable imax = 10; immutable jmax = 10; float[imax][jmax] x; foreach(int j; 1..jmax){ foreach(int i, ref item; parallel(x[j-1])){ x[j][i] = complicatedFunction(i, item); } } } (though sadly, this doesn't compile for a reason I can't fathom instantly) Hmm. Shouldn't you instead parallel the outer loop?
Re: Benchmarking suite
Why not go really big. aka: http://forum.dlang.org/post/vzcvwrbqpeamtnopm...@forum.dlang.org
Re: OSX prompt limit
On Friday, 4 September 2015 at 03:31:40 UTC, Adam D. Ruppe wrote: On Friday, 4 September 2015 at 02:17:57 UTC, Joel wrote: In Mac OS, when typing with readln etc. I can't use the cursor keys. Works in Windows though. That's normal, line editing on Unix terminals is a kinda advanced library feature. The most common lib to do it, GNU readline, is actually a big thing that pushed the GPL because of how useful it was and it happened to use that license. I wrote one too though it is a bit bulky. https://github.com/adamdruppe/arsd/blob/master/terminal.d import terminal; void main() { auto terminal = Terminal(ConsoleOutputMode.linear); auto line = terminal.getline("your prompt: "); terminal.writeln("You wrote: ", line); } compile: dmd yourapp.d terminal.d I get these errors with terminal.d (on OSX): Joels-MacBook-Pro:small joelcnz$ rdmd term.d arsd/terminal.d(1268): Error: undefined identifier 'SIGWINCH' arsd/terminal.d(1381): Error: undefined identifier 'SIGWINCH' Joels-MacBook-Pro:small joelcnz$ Note: I've got term.d as the main file, I've got terminal.d in arsd folder I've put up an issue on your github site.
Re: "Programming in D" paper book is available for purchase
On 09/07/2015 08:54 PM, lobo wrote: > it's so much nicer to read it in print than PDF. Thank you all, for your kind words! Strange, but perhaps because I was raised with real books, I completely agree that physical books feel better. :) Let me use this opportunity to give a short report. As of now, in the three weeks that the book has been available, there were 61 copies sold. This means that almost one third of my out of pocket expenses have been covered at this time. Obviously, it will take much longer to cover the remaining amount. If you are curious, the expense was for the tool that I used for converting from HTML to PDF (Prince XML), for the cover art and design, for copies that I bought myself to give away (marketing cost). I have just completed submitting the book at IngramSpark as well. This will give the book a chance to appear on book shelves, which I find important because I think seeing and touching a book has an effect on anybody visiting a book shop. Interestingly, the IngramSpark edition has a separate ISBN, less number of pages, and has a different price. For example, although the list price of the currently available book is $28.50, the IngramSpark edition will cost $33.33. This is to be able to give brick-and-mortar booksellers sufficient discount so that the book is interesting to them to put on their shelves. To me, the difference in price covers the shipping cost and eliminates any shipment waits. You go to the store and get the book! It feels more natural. :) This edition will have 682 pages as opposed to the 798 pages of the current book. However, the content is the same. The difference comes from slightly smaller font (9.75pt versus 10pt), less margins, and inline curly brackets (aka Egyptian brackets) throughout. I have already ordered a proof copy... Anyway, thanks again, Ali
[Issue 9891] Ability to modify immutable using default value of ref/out parameter
https://issues.dlang.org/show_bug.cgi?id=9891 Kenji Harachanged: What|Removed |Added Keywords||pull --- Comment #2 from Kenji Hara --- https://github.com/D-Programming-Language/dmd/pull/5056 --
Re: Regression?
On Tuesday, 8 September 2015 at 04:04:16 UTC, Sebastiaan Koppe wrote: Fixed it by changing into: ``` import std.conv : text; string json = File("../languages.json","r").byLineCopy().joiner.text; auto ls = json.parseJSON(); ``` Why would you read file by line and then merge all into one string? You end up with reading the whole file (well, getting rid of line ends) anyway, so probably the more efficient solution would be just read the whole file at once with std.file.read and cast to string.
Re: Parameterized unittests and benchmarks (aka quickfix + benchmark) PR 2995
On Wednesday, 2 September 2015 at 08:30:40 UTC, Robert burner Schadek wrote: Everybody is talking about benchmarks and making code faster, yet phobos is still lacking any long term benchmark gathering and monitoring solution. PR https://github.com/D-Programming-Language/phobos/pull/2995 provides all that, and is done some time now. It will give us pretty pictures we can put on the webpage. These will show how awesome phobos already is, and how much we improve performance wise with time progressing. This does sound like a really good idea. Is the plan to turn every unittest block into a benchmark (automatically), or did you add specific benchmarks blocks? Might be nice to have a mock up of the webpage with all the results/benchmarks.
[Issue 15027] New: cannot pass arguments of type DirEntry to std.file functions
https://issues.dlang.org/show_bug.cgi?id=15027 Issue ID: 15027 Summary: cannot pass arguments of type DirEntry to std.file functions Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: rejects-valid Severity: regression Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: r.sagita...@gmx.de On git-head, this loop no longer compiles: import std.file; string foo() { foreach(f; dirEntries("/", "*", SpanMode.shallow, false)) if(std.file.isDir(f)) return f; return null; } >dmd -c test.d test.d(8): Error: template std.file.isDir cannot deduce function from argument types !()(DirEntry), candidates are: c:\s\d\rainers\phobos\std\file.d(1399):std.file.isDir(R)(R name) if (isInputRange!R && isSomeChar!(ElementEncodingType!R)) compiling with dmd-2.068.1 is ok. The problem seems to be that the rangified file functions no longer accept arguments that alias this to strings. --
Re: Why 1f.iota(100f).array returns double[] not float[]?
On 09/08/2015 12:00 AM, drug wrote: import std.array : array; import std.range : iota; pragma(msg, typeof(iota(1f, 100f).array)); // why double[] not float[]? void main() { } It is probably because the type of floating point literals like 1.0 is double. Probably there is a 1.0 in iota's implementation, converting the element type to double according to rule number 2 here: http://dlang.org/type.html#usual-arithmetic-conversions Yep, here it is: https://github.com/D-Programming-Language/phobos/blob/master/std/range/package.d#L4630 auto iota(B, E)(B begin, E end) if (isFloatingPoint!(CommonType!(B, E))) { return iota(begin, end, 1.0); } Although any such expression can become double easily, I think the literal should be 1.0f in this case. Ali
Re: How To Compile D2SQLite3 on OSX?
On Tuesday, 8 September 2015 at 07:02:43 UTC, Jacob Carlborg wrote: On 2015-09-08 07:50, Mike McKee wrote: [...] You need to link with the library, i.e. $ dmd test.d libd2sqlite3.a [...] Jacob, you fixed me! :) Thanks also for explaining the dub thing -- I wasn't quite getting it.
Re: How To Compile D2SQLite3 on OSX?
On 2015-09-08 07:50, Mike McKee wrote: $ dmd test.d Undefined symbols for architecture x86_64: How do I get this going? You need to link with the library, i.e. $ dmd test.d libd2sqlite3.a You probably need to link the native SQLite3 library as well: $ dmd test.d libd2sqlite3.a -L/usr/local/Cellar/sqlite/3.8.11.1/lib/libsqlite3.dylib But the correct way to do this is create a dub.json file for your own project which adds "d2sqlite3" as a dependency: 1. Run "dub init foo" 2. Navigate to the newly created directory "foo" 3. Add your source file(s) to "source" 4. Add "d2sqlite3" as a dependency in "dub.json" in the "dependencies" object/dictionary 5. Run "dub" to build and run the project. It will automatically fetch and build the dependencies You might need to add that linker [2] flag to your dub.json file if the library is not in the standard library path (/usr/lib or /usr/local/lib). For more information about the dub.json format see [1]. [1] http://code.dlang.org/package-format?lang=json [2] "lflags": ["-L/usr/local/Cellar/sqlite/3.8.11.1/lib/libsqlite3.dylib"] -- /Jacob Carlborg
Why 1f.iota(100f).array returns double[] not float[]?
import std.array : array; import std.range : iota; pragma(msg, typeof(iota(1f, 100f).array)); // why double[] not float[]? void main() { }
Re: Parameterized unittests and benchmarks (aka quickfix + benchmark) PR 2995
On Tuesday, 8 September 2015 at 09:01:22 UTC, Robert burner Schadek wrote: On Tuesday, 8 September 2015 at 08:42:59 UTC, Edwin van Leeuwen wrote: This does sound like a really good idea. Is the plan to turn every unittest block into a benchmark (automatically), or did you add specific benchmarks blocks? you would add specific benchmark blocks, because the benchmarks might run to long for a rapid development cycle. Just to be clear. The PR is to add the needed ground work for adding benchmark, or does it also add some benchmarks itself? It does seem a bit of a shame not to use the unittests at all for baseline benchmarks. The unittests already exist, with reasonable good coverage. Getting good benchmark coverage by writing specific/new benchmarks would mean a huge amount of extra effort.
[Issue 15028] New: Weird disassembly on asm.dlang.org
https://issues.dlang.org/show_bug.cgi?id=15028 Issue ID: 15028 Summary: Weird disassembly on asm.dlang.org Product: D Version: D2 Hardware: All URL: http://asm.dlang.org/ OS: All Status: NEW Severity: normal Priority: P1 Component: dlang.org Assignee: nob...@puremagic.com Reporter: dfj1es...@sneakemail.com Code --- void f() { const char* c="a"; g(c); } extern void g(in char* s); --- Gives disassembler output --- void example.f(): push rbp movrbp,rsp movedi,0x0 call e poprbp ret --- The function is called with null argument? --
Re: Parameterized unittests and benchmarks (aka quickfix + benchmark) PR 2995
On Tuesday, 8 September 2015 at 09:07:10 UTC, Edwin van Leeuwen wrote: Just to be clear. The PR is to add the needed ground work for adding benchmark, or does it also add some benchmarks itself? The PR adds benchmarks for some functions of std.string. It does seem a bit of a shame not to use the unittests at all for baseline benchmarks. The unittests already exist, with reasonable good coverage. Getting good benchmark coverage by writing specific/new benchmarks would mean a huge amount of extra effort. I disagree, the unittests in phobos are often very short, only test corner cases, test regression fix, serve add doc unittests or do some basic sanity checking. Benchmarks have other requirements.
Re: Article: More hidden treasure in the D standard library
On Monday, 31 August 2015 at 18:39:22 UTC, wobbles wrote: On Monday, 31 August 2015 at 16:09:02 UTC, Gary Willoughby wrote: I've written a new article on D here: http://nomad.so/2015/08/more-hidden-treasure-in-the-d-standard-library/ Hopefully to drive other programmers to investigate D. It's a continuation of a similar one I wrote a few months ago which attracted over 60k readers. It's a simple overview of some cool features in the D standard library hopefully to fuel curiosity. Reddit link: https://www.reddit.com/r/programming/comments/3j3j87/more_hidden_treasure_in_the_d_standard_library/ Up vote away. :) Nice article. I regularly find things like this where I spend a couple hours implementing a solution, only to find its already been done for me. Mostly occurs in std.algorithm. And it's not even lack of documentation, it's me thinking "this will never be in the library, time to go do it myself". That predSwitch code is a perfect example. Same here. I've learned to go to Phobos first (mainly std.algorithm), before I come up with my own solution. But Phobos is so vast that it's easy to miss a gem or two. I'd appreciate more articles about how common problems can be solved with Phobos. One issue I've encountered is that function names don't always reflect well what they do, so I filter them. This might be my own fault though.
Re: Parameterized unittests and benchmarks (aka quickfix + benchmark) PR 2995
On Tuesday, 8 September 2015 at 08:42:59 UTC, Edwin van Leeuwen wrote: This does sound like a really good idea. Is the plan to turn every unittest block into a benchmark (automatically), or did you add specific benchmarks blocks? you would add specific benchmark blocks, because the benchmarks might run to long for a rapid development cycle. Might be nice to have a mock up of the webpage with all the results/benchmarks. that is the idea
What is "FilterResult" type?
From what I can gather the output of `std.algorithm.iteration : filter` is a `FilterResult` type. I need a bit of help dealing with this type: 1. Why this type is there in the first place instead of simply using the type of input range? 2. Where is the documentation for this type? The documentation always uses `auto` for `filter` return values. 3. How can I convert this type back into a range? Thanks.
Re: What is "FilterResult" type?
On Tuesday, 8 September 2015 at 09:48:35 UTC, Bahman Movaqar wrote: From what I can gather the output of `std.algorithm.iteration : filter` is a `FilterResult` type. I need a bit of help dealing with this type: 1. Why this type is there in the first place instead of simply using the type of input range? 2. Where is the documentation for this type? The documentation always uses `auto` for `filter` return values. 3. How can I convert this type back into a range? Thanks. Filter is a template and returns a FilterResult range which is used to lazily compute the result. This behaviour is the same for map and the majority of functions in std.algorithm. It is an input range really (ie: it has front, popFront and empty). You can chain it just like any other range with other functions and normally don't have to know the exact type (which would be complicated since it is a templated thing). To store it in a variable if you don't know the exact type you can use auto to use type deduction. If you need the type (for a template for example) you can then use typeof. Example: void main() { import std.stdio: writeln; import std.algorithm: filter, map; int[] arr = [1, 2, 3, 4, 5]; auto result = arr.filter!(x => x%2); // filter out even numbers result.writeln; // Writes [1, 3, 5]; // What is the type of result? typeid(result).writeln; //-> temporary.main.FilterResult!(__lambda2, int[]).FilterResult // Map takes a range, this works because result is one. auto result2 = result.map!(x => 2*x); //-> temporary.main.MapResult!(__lambda3, FilterResult!(__lambda2,int[])).MapResult // Here is the reason you don't want to type them yourself. auto FTW! typeid(result).writeln; // main.FilterResult!(__lambda2, int[]).FilterResult // You can put it back in an array too import std.array: array; int[] resultArr = result2.array; } If you want more precise documentation the best is to look to the source code (/usr/include/dlang/dmd/std/algorithm/iteration if you are on linux).
Re: What is "FilterResult" type?
On Tuesday, 8 September 2015 at 11:08:59 UTC, Bahman Movaqar wrote: On Tuesday, 8 September 2015 at 10:08:03 UTC, cym13 wrote: Filter is a template and returns a FilterResult range which is used to lazily compute the result. This behaviour is the same for map and the majority of functions in std.algorithm. You can also use .array to (greedily) evaluate the results, which (for filter) will return a range of the same type as went in: void main() { import std.array : array; int[] arr = [1, 2, 3, 4, 5]; int[] result = arr.filter!(x => x%2).array; }
Re: So what about -betterC flag?
On Saturday, 5 September 2015 at 14:32:39 UTC, Laeeth Isharc wrote: On Saturday, 5 September 2015 at 12:56:48 UTC, Adam D. Ruppe wrote: On Saturday, 5 September 2015 at 10:51:23 UTC, Rel wrote: I remember that there was some buzz around undocumented -betterC compiler flag that should allow people get away from hard druntime dependencies and write bare metal code, drivers or kernel modules in some limited D subset. -betterC used to exist, not sure if it still does, but it does very little and I don't think it helps much; you're still basically on your own in making such code work right. switch still there. don't know what it does, if anything. https://github.com/D-Programming-Language/dmd/search?utf8=%E2%9C%93=betterC I see, it seems that all that flag does is prevent module info generation, I don't really know if it may be helpful or not in using D as a "better C" (without druntime). But thanks!
Re: Benchmarking suite
On Tuesday, 8 September 2015 at 09:27:13 UTC, qznc wrote: On Tuesday, 8 September 2015 at 08:24:43 UTC, Robert burner Schadek wrote: Why not go really big. aka: http://forum.dlang.org/post/vzcvwrbqpeamtnopm...@forum.dlang.org You suggest to create a benchmark suite from all the unittests in Phobos? I don't think this is a good idea. Most programs don't make good performance tests. Read your PR more closely now. We already agree on that. :P Still a difference: You propose a method to measure Phobos performance and detect regressions. My shootout wants to compare D and C/C++ performance.
Re: Status of Win32 C++ interop
On 08.09.2015 11:45, Benjamin Thaut wrote: On Monday, 7 September 2015 at 19:30:44 UTC, drug wrote: 07.09.2015 21:37, Benjamin Thaut пишет: snip So far I haven't found a situation where I couldn't make it work the way I wanted. Its just some work to write the D headers for the C++ classes and vise versa, because you have to duplicate everything once more. An automated tool for this would be nice, but unfotunately there is currently none. Kind Regards Benjamin Thaut It's great. But isn't it based on your custom modifications of compiler and the others? No, the compiler modifications are only for the Windows DLL support. All modifications I did to the c++ binding are already in 2.068 It's good. Thank you!
Re: What is "FilterResult" type?
On Tuesday, 8 September 2015 at 10:08:03 UTC, cym13 wrote: Filter is a template and returns a FilterResult range which is used to lazily compute the result. This behaviour is the same for map and the majority of functions in std.algorithm. Ah...now it makes sense why use a proxy to the results. It is an input range really (ie: it has front, popFront and empty). You can chain it just like any other range with other functions and normally don't have to know the exact type (which would be complicated since it is a templated thing). I agree. Some types are better left unspecified; like some 300+ characters long type signatures one would get from a generic Scala function :-D However, I have made this a strict practice of mine to specify the full signature of my public API. I suppose, if I want to be pedantic, I have to realise the lazy value first and pass the resulting array out. Is this correct? To store it in a variable if you don't know the exact type you can use auto to use type deduction. True. Example: Great. The usage is crystal clear to me now. If you want more precise documentation the best is to look to the source code (/usr/include/dlang/dmd/std/algorithm/iteration if you are on linux). Thanks for the help and pointers.
Tutorial on D + Chromium / CEF / DerelictCEF with OSX ?
I downloaded DerelictCEF and used dub to compile it on my OSX (Yosemite). Now how do I get CEF downloaded and ready to work with it? I found an OSX 64 bit version file here: https://cefbuilds.com/ There doesn't seem to be any documentation for that part. From there, what is the trick to load up a local HTML page that says Hello World?
Re: Parameterized unittests and benchmarks (aka quickfix + benchmark) PR 2995
On Tuesday, 8 September 2015 at 09:20:08 UTC, Robert burner Schadek wrote: On Tuesday, 8 September 2015 at 09:07:10 UTC, Edwin van Leeuwen wrote: Just to be clear. The PR is to add the needed ground work for adding benchmark, or does it also add some benchmarks itself? The PR adds benchmarks for some functions of std.string. I sort of like what Rust is using: https://github.com/rust-lang/rust/tree/master/src/test/bench If we can have similar benchmarks suite which can be tested with every release, it can help to spot speed regressions or promote new optimisations.
Re: Why 1f.iota(100f).array returns double[] not float[]?
On Tuesday, 8 September 2015 at 07:17:01 UTC, Ali Çehreli wrote: https://github.com/D-Programming-Language/phobos/blob/master/std/range/package.d#L4630 auto iota(B, E)(B begin, E end) if (isFloatingPoint!(CommonType!(B, E))) { return iota(begin, end, 1.0); } Such kind of stuff would better be written as auto iota(B, E)(B begin, E end) { return iota(begin, end, cast(CommonType!(B, E))1.0); } this doesn't need a constraint anymore, or maybe use if(isNumeric!(CommonType!(B, E))) I tend to use the above kind of cast often, because I like to work with ubyte or ushort, and every f***ing number literal changes the type to uint :-/
Re: std.Stream.InputStream convenience functions
On Sunday, 6 September 2015 at 21:40:08 UTC, bitwise wrote: On Sunday, 6 September 2015 at 21:33:36 UTC, BBasile wrote: I don't care about your problem Then I suggest another thread. Another thread is useless. It was a dead end since the beginning. std.streams are dead: https://github.com/D-Programming-Language/phobos/commit/7a6e685ec924d198dd3b3a6856a635d1452b2c93
Re: Regression?
On Tuesday, September 08, 2015 07:12:50 FreeSlave via Digitalmars-d-learn wrote: > On Tuesday, 8 September 2015 at 04:04:16 UTC, Sebastiaan Koppe > wrote: > > Fixed it by changing into: > > > > ``` > > import std.conv : text; > > string json = > > File("../languages.json","r").byLineCopy().joiner.text; > > auto ls = json.parseJSON(); > > ``` > > Why would you read file by line and then merge all into one > string? You end up with reading the whole file (well, getting rid > of line ends) anyway, so probably the more efficient solution > would be just read the whole file at once with std.file.read and > cast to string. Or just use std.file.readText: http://dlang.org/phobos/std_file.html#readText - Jonathan M Davis
Re: Concurency wtf?
On 9/8/15 2:54 PM, Prudence wrote: I can't seem to receive certain messages, my code is very simple and it all works except for receiving: in one thread I do locate("MyMonitor").send(cast(shared)pt); You are casting to shared here. which sends the message(pt is a windows POINT structure). In the MyMonitor spawned thread, I have while (true) { POINT y; receiveTimeout(100.msecs, (POINT p) But not receiving a shared(POINT) here. So the types are different. What is a POINT struct? If it's simple POD (with no pointers), then you don't need the shared type modifier. -Steve
Re: Is D suitable for my latest project?
On Sunday, 6 September 2015 at 14:45:45 UTC, BBasile wrote: You have Object.factory for this. You can also use a custom factory based on string comparison. (with some: static if(condition) return new This; else static if(otherCondition) return new That; etc). I just had a look at Object.factory and this isn't actually what I wanted. I was looking for something that would allow me to create new (previously undefined) classes in D at runtime that I could then use with Object.factory to create instances of. I think I can do this with Variants and dynamic, is this possible? Or is there another way?
Re: Range functions expand char to dchar
On Tuesday 08 September 2015 20:28, Matt Kline wrote: > If we have a range of char elements, won't that do? regex() uses > the standard isSomeString!S constraint to take any range of chars. isSomeString!S doesn't check if S is a range. It checks if S is "some string", meaning: "Char[], where Char is any of char, wchar or dchar, with or without qualifiers". http://dlang.org/phobos/std_traits.html#isSomeString Checking for ranges would be done with isInputRange, isForwardRange, etc. http://dlang.org/phobos/std_range_primitives.html
Re: Implicit conversion with ctor like C++
I made a mistake it's more like: //Sample class class CClass { this(string MyValue){...} } //Called function void MyFunction(CClass MyClass){} void main() { MyFunction("Hello World!"); //Failed : MyFunction not callable... }
Re: Implicit conversion with ctor like C++
On Tuesday, 8 September 2015 at 19:23:47 UTC, Pierre wrote: Hi everybody, I would like to use implicit conversion like this: //Sample class class MyClass { this(string MyValue){...} } //Called function void MyFunction(Foo MyFoo){} void main() { MyFunction("Hello World!"); //Failed : MyFunction not callable... } I saw in forum this is OK because D doesn't do implicit conversion with ctor like C++ But how can I do ? May I use alias ? Thank you for your attention. No, as far as I know, D does not support implicit construction of classes or structs. There is *some* implicit conversion allowed, but in the opposite direction. struct Test { string s; alias s this; //Necessary for nice construction syntax this(string s) { this.s = s; } } void foo(string s) { writeln(s); } void main() { Test t = "asdf"; foo(t); //Prints "asdf" } So with alias this, you can pass a Test to a function expecting a string, but not vice-versa.
Re: Range functions expand char to dchar
On 08-Sep-2015 20:57, Matt Kline wrote: On Tuesday, 8 September 2015 at 17:52:13 UTC, Matt Kline wrote: Whether by design or by oversight, this is quite undesirable. My apologies for double-posting, but is this intended behavior, or an unfortunate consequence of the metaprogramming used to determine the resulting type of these range functions? Historical consequence of enabling auto-decoding for arrays of char and wchar (and only those). Today it's recognized that one should either wrap an array of char as code unit range or code point range explicitly using byUTF helper. -- Dmitry Olshansky
Re: Benchmarking suite
On Tuesday, 8 September 2015 at 09:27:13 UTC, qznc wrote: For example, threadring measures context switching. thread-ring has aged badly. It was added when the measurements were only made on single-core hardware, and Erlang's huge number of lightweight processes seemed interesting ;-) It's been many years since the thread-ring measurements were included in the summary charts. The pidigits programs basically measures libGMP performance. And arbitrary precision arithmetic without libGMP :-)
Re: Implicit conversion with ctor like C++
OK that's very clear thank you for the answer.
Re: What is "FilterResult" type?
On Tuesday, September 08, 2015 11:08:57 Bahman Movaqar via Digitalmars-d-learn wrote: > However, I have made this a strict practice of mine to specify > the full signature of my public API. If your API returns ranges, that's general not only bad practice but arguably impossible. Most range-based functions purposefully return Voldemort types (the type is declared inside of the function, meaning that you cannot name it). FilterResult really should be to, but I think that it's not in order to work around a bug. Regardless, it's private and should never be used explicitly. If you want to put a range type in an API, you're forced to do stuff like typeof(rangeFunc!someFunc(SomeOtherRange.init)) myFunc(int); If you're returning a range, you should be returning auto. The documentation should then say whether it's an input range, forward range, etc. - but you should pretty much never be using range types explicitly. Your code will become an unmaintainable, unreadable mess if you try. And really, it's unnecessary. Simply having the documentation say what sort of range it's returning is plenty. Exact types are unnecessary in this case and counterproductive. - Jonathan M Davis
Re: Benchmarking suite
On Saturday, 29 August 2015 at 12:05:18 UTC, qznc wrote: I started something on my own. Kudos to qznc! The C/C++ programs were selected quite randomly. Note: There are separate C and C++ programs shown on the benchmarks game -- so for something like regex-dna there's a C program using the C library written for Tcl and there's a C++ program using the re library. fwiw Doing both would make your comparison a little broader.
Concurency wtf?
I can't seem to receive certain messages, my code is very simple and it all works except for receiving: in one thread I do locate("MyMonitor").send(cast(shared)pt); which sends the message(pt is a windows POINT structure). In the MyMonitor spawned thread, I have while (true) { POINT y; receiveTimeout(100.msecs, (POINT p) { y = p; } ); Thread.sleep(100.msecs); continue; } Note that everything works except the matching in receiveTimeout. (I've tired various things and simplifications to no avail). I can send simple types like int and bool. e.g., sending a literal works fine. My guess is the shared is causing problems but I've tried all common sense combinations. But I have to send shared, else send complains about sending unshared types. Of course, the great thing is, all examples use literals and hence not real world examples(isn't that nice?). Please don't ask me to provide source. The issue has nothing to do with the other code but specifically the TYPE that is being sent. Works for some types and not others. It is almost surely due to the shared issue, any ideas?
Re: What is "FilterResult" type?
On Tuesday, 8 September 2015 at 11:08:59 UTC, Bahman Movaqar wrote: However, I have made this a strict practice of mine to specify the full signature of my public API. I suppose, if I want to be pedantic, I have to realise the lazy value first and pass the resulting array out. Is this correct? If you _really_ want to specify the return type, you can import std.range.interfaces[1] and use the appropriate return type (e.g., InputRange!int, RandomAccessFinite!char, etc.) and then append a `.inputRangeObject` to the end of your range chain. Ex: import std.algorithm; import std.range; InputRange!int doRangeyThings(R)(R r) if (isInputRange!R) { return r.filter!(x => !(x & 1)) .map!(x => x * 2) .inputRangeObject; } void main() { auto n = [1, 2, 3, 4]; auto m = n.doRangeyThings(); assert(is(typeof(m) == InputRange!int)); assert(m.equal([4, 8])); } You should use this sparingly, however. The types in std.range.interfaces are interfaces that allow you to combine ranges with runtime polymorphism, and you have to pay the corresponding price for that, namely, you'll be hitting the GC and the virtual functions entail a speed hit. 1. http://dlang.org/phobos/std_range_interfaces.html
Implicit conversion with ctor like C++
Hi everybody, I would like to use implicit conversion like this: //Sample class class MyClass { this(string MyValue){...} } //Called function void MyFunction(Foo MyFoo){} void main() { MyFunction("Hello World!"); //Failed : MyFunction not callable... } I saw in forum this is OK because D doesn't do implicit conversion with ctor like C++ But how can I do ? May I use alias ? Thank you for your attention.
Re: Is D suitable for my latest project?
On Monday, 7 September 2015 at 07:57:07 UTC, Kagamin wrote: On Sunday, 6 September 2015 at 15:15:03 UTC, chris stevens wrote: I guess you're right it wouldn't be too difficult to do it all using strings. The code generation I'd done before in c# I'd used some 3rd person library where you build up an object model rather than using strings. Maybe with dparse you can construct an AST and later convert it to string. Thanks for the reply Kagamin, just had a quick look at dparse and not sure how I could use it in the way you describe. Any examples of this?
Re: Benchmarking suite
On Tuesday, 8 September 2015 at 18:41:10 UTC, Isaac Gouy wrote: On Saturday, 29 August 2015 at 12:05:18 UTC, qznc wrote: I started something on my own. Kudos to qznc! The C/C++ programs were selected quite randomly. Note: There are separate C and C++ programs shown on the benchmarks game -- so for something like regex-dna there's a C program using the C library written for Tcl and there's a C++ program using the re library. fwiw Doing both would make your comparison a little broader. Yes. I'm not sure how to structure this whole suite. The general goal is "D claims that it can match C/C++ in performance, let's have some actual numbers". So far D mostly disappoints in terms of performance. There are at least three interesting variations "fastest parallel programs", "fastest sequential programs" and "short idiomatic programs". Probably all of them should be compared.
[Issue 15030] New: [Reg 2.068.1] ICE with recursive delegate, -unittest, and std.range
https://issues.dlang.org/show_bug.cgi?id=15030 Issue ID: 15030 Summary: [Reg 2.068.1] ICE with recursive delegate, -unittest, and std.range Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Keywords: ice Severity: regression Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: c...@dawg.eu cat > modA.d << CODE import std.range; CODE cat > modB.d << CODE unittest { import std.algorithm; import std.range; auto dg = (int[] delegate(int[]) self) => (int[] arr) => arr ? self(arr.filter!(a => a).array) : null; } CODE dmd -unittest -c modA.d modB.d dmd: glue.c:1060: void FuncDeclaration_toObjFile(FuncDeclaration*, bool): Assertion `!v->csym' failed. --
Re: std.Stream.InputStream convenience functions
On Tuesday, 8 September 2015 at 17:16:45 UTC, Jonathan M Davis wrote: On Saturday, 5 September 2015 at 19:59:03 UTC, bitwise wrote: [...] I would have to study the problem to give a good answer. It's been too long since I looked at the issue for me to remember the finer details at this point. IIRC, a big part of the problem had something to do with the fact that you essentially want a range of bytes, but the underlying C APIs really give something more like a range of a range of bytes, because you read the data into a buffer rather than reading it a byte at a time (which gets even further complicated by the fact that you generally want to reuse that buffer and not allocate extra memory if you can avoid it). On some level at least, that's the problem that byLine and byChunk in std.stdio run into. I really don't remember the details of what needed to be done differently for solid stream support though. But all of the stuff relating to getting objects out of a byte stream can almost certainly be done by building it on top of a range of bytes rather than having any of that talk to the disk or generally care where the data comes from, and I very much doubt that std.stream does anything like that. So, at minimum, what std.stream does would have to be shifted so that all of the transformations are done on top of ranges of ubyte rather than talking to the disk or network stack or whatever. But I'd have to go digging through the code to even know what std.stream does right now, and I don't have the time right now to figure out how it should work. It's been discussed before, and it was decided that what's there was not what we wanted, though how far off it is, I really don't know other than the fact that it's not range-based. Any stream solution should be consuming and producing ranges and should be agnostic to wherever the data comes from unless it has a _really_ good reason not to be. Steven Schveighoffer has been working off and on on a replacement for std.stdio which supports streams and cleans up some of the uglier things with std.stdio.File, so we may get something out of that at some point, but he has yet to get far enough with it to actually present it for review and possible inclusion in Phobos. However, I haven't heard of any other work being done on streams, and it seems like everyone's simply making do without, for better or worse. - Jonathan M Davis Ok, I guess I'll try rummaging through the archives and see if I can find the rest of the story... Or maybe just ask Steven where he's at if this becomes important. 2.070 seems quite a ways away though. I'm not sure if DMD is on a steady release schedule, but I imagine there is quite a lot of work to do in terms of optimization and refactoring before even 2.069 comes out. Anyways, Thanks for the info, Bit
Re: std.Stream.InputStream convenience functions
On Tuesday, 8 September 2015 at 21:54:09 UTC, bitwise wrote: On Tuesday, 8 September 2015 at 18:59:12 UTC, BBasile wrote: On Sunday, 6 September 2015 at 21:40:08 UTC, bitwise wrote: On Sunday, 6 September 2015 at 21:33:36 UTC, BBasile wrote: I don't care about your problem Then I suggest another thread. Another thread is useless. It was a dead end since the beginning. std.streams are dead: https://github.com/D-Programming-Language/phobos/commit/7a6e685ec924d198dd3b3a6856a635d1452b2c93 Well, you're half right. Streams do indeed appear to be dead ;) I guess that you deserve the remaining half of the truth... If it was up to me i would rather take three quavers on the beat but it's fine like that.
Re: std.Stream.InputStream convenience functions
On Tuesday, 8 September 2015 at 22:19:13 UTC, BBasile wrote: On Tuesday, 8 September 2015 at 21:54:09 UTC, bitwise wrote: On Tuesday, 8 September 2015 at 18:59:12 UTC, BBasile wrote: On Sunday, 6 September 2015 at 21:40:08 UTC, bitwise wrote: On Sunday, 6 September 2015 at 21:33:36 UTC, BBasile wrote: I don't care about your problem Then I suggest another thread. Another thread is useless. It was a dead end since the beginning. std.streams are dead: https://github.com/D-Programming-Language/phobos/commit/7a6e685ec924d198dd3b3a6856a635d1452b2c93 Well, you're half right. Streams do indeed appear to be dead ;) I guess that you deserve the remaining half of the truth... If it was up to me i would rather take three quavers on the beat but it's fine like that. Weelll says here that a Quaver is an eighth note.. https://www.google.ca/search?safe=off=2=define%3A+quaver So I suppose if you only wanna be 3/8 right instead of 1/2, I guess that's fine by me :)
Re: Benchmarking suite
On Tuesday, 8 September 2015 at 18:53:02 UTC, Isaac Gouy wrote: On Tuesday, 8 September 2015 at 09:27:13 UTC, qznc wrote: For example, threadring measures context switching. thread-ring has aged badly. It was added when the measurements were only made on single-core hardware, and Erlang's huge number of lightweight processes seemed interesting ;-) It's been many years since the thread-ring measurements were included in the summary charts. It is interesting that Erlang and others are considered "preemptive" threads. Afaik the Erlang runtime does not interrupt processes. The pidigits programs basically measures libGMP performance. And arbitrary precision arithmetic without libGMP :-) In this comparison it is actually interesting, because D has its own bignum implementation in the standard library. It holds well against libGMP.
[Issue 15030] [Reg 2.068.1] ICE with recursive delegate, -unittest, and std.range
https://issues.dlang.org/show_bug.cgi?id=15030 --- Comment #1 from Martin Nowak--- Digger points this back to https://github.com/D-Programming-Language/dmd/pull/4944. --
[Issue 15021] [REG2.068.1] linker error with speculative instantiation and -inline
https://issues.dlang.org/show_bug.cgi?id=15021 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --
Re: Is D suitable for my latest project?
On Tuesday, 8 September 2015 at 19:30:16 UTC, chris stevens wrote: On Sunday, 6 September 2015 at 14:45:45 UTC, BBasile wrote: You have Object.factory for this. You can also use a custom factory based on string comparison. (with some: static if(condition) return new This; else static if(otherCondition) return new That; etc). I just had a look at Object.factory and this isn't actually what I wanted. I was looking for something that would allow me to create new (previously undefined) classes in D at runtime that I could then use with Object.factory to create instances of. I think I can do this with Variants and dynamic, is this possible? Or is there another way? No, it's not possible with variants. What you want to do is actually complex and won't be solved here. To create a new class instance, the runtime needs the TypeInfo class for the class type. Why ? because for example if in a class declaration you declare an int initially equal to 1, the TypeInfo class provide the memory layout that matches to this initital value. For example this is how class instances are creates in D: https://github.com/D-Programming-Language/druntime/blob/master/src/rt/lifetime.d#L71 --- extern (C) Object _d_newclass(const ClassInfo ci) --- without the 'ClassInfo' parameter, you can't get the initial state of a class. This is what the runtime needs to create a class instance.
[Issue 15021] [REG2.068.1] linker error with speculative instantiation and -inline
https://issues.dlang.org/show_bug.cgi?id=15021 --- Comment #3 from github-bugzi...@puremagic.com --- Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/61f79a8aa18a2d551cfeb7c1bc218ebc3f21cfc6 fix Issue 15021 - linker error with speculative instantiation and -inline https://github.com/D-Programming-Language/dmd/commit/334e29178254ef0f02639b595a75f906e1b357ee Merge pull request #5055 from 9rnsr/fix15021 [REG2.068.1] Issue 15021 - linker error with speculative instantiation and -inline --
Re: Is D suitable for my latest project?
On Tuesday, 8 September 2015 at 19:30:16 UTC, chris stevens wrote: On Sunday, 6 September 2015 at 14:45:45 UTC, BBasile wrote: You have Object.factory for this. You can also use a custom factory based on string comparison. (with some: static if(condition) return new This; else static if(otherCondition) return new That; etc). I just had a look at Object.factory and this isn't actually what I wanted. I was looking for something that would allow me to create new (previously undefined) classes in D at runtime that I could then use with Object.factory to create instances of. I think I can do this with Variants and dynamic, is this possible? Or is there another way? "Previously undefined". As far as I know, this is impossible in D. Thr compiler has to know how much memory to allocate/request and it has to know that at compiletime (else it wouldn't be the compiler!) This functionality in Java/C# is possible because it's running on a vm that allows special instructions to make the vm compile and make available a class dynamically (and by extension, slowly)
Re: std.Stream.InputStream convenience functions
On Tuesday, 8 September 2015 at 18:59:12 UTC, BBasile wrote: On Sunday, 6 September 2015 at 21:40:08 UTC, bitwise wrote: On Sunday, 6 September 2015 at 21:33:36 UTC, BBasile wrote: I don't care about your problem Then I suggest another thread. Another thread is useless. It was a dead end since the beginning. std.streams are dead: https://github.com/D-Programming-Language/phobos/commit/7a6e685ec924d198dd3b3a6856a635d1452b2c93 Well, you're half right. Streams do indeed appear to be dead ;)
Re: Behavior of opEquals
On 09/08/2015 06:49 PM, Jonathan M Davis wrote: On Monday, 7 September 2015 at 10:26:00 UTC, Timon Gehr wrote: On 09/05/2015 08:18 AM, Jonathan M Davis wrote: On Friday, 4 September 2015 at 20:39:14 UTC, Timon Gehr wrote: On 09/04/2015 09:21 PM, H. S. Teoh via Digitalmars-d wrote: Wait, wait, did I miss something? Since when was operator overloading allowed as free functions? Since UFCS, but DMD does not implement it. There is nothing in the spec about supporting operator overloading with free functions, so I don't know where you get the idea that it's even intended to be a feature. UFCS applies to functions which use the member function call syntax, and operators aren't used that way. Specifying semantics via lowering is somewhat pointless if rewrites are not transitive. Specifying semantics via lowering makes the compiler simpler Not necessarily. The compiler can do lowering (even using internal syntax tree nodes that have no D syntax equivalent!) no matter how the behaviour is specified. It's just easier to come up with the required compiler code and to verify it if the specification does it this way. and the expected behavior easier to understand. Nothing about that requires that it transitively apply all syntactic sugar, and UFCS is simply syntactic sugar. All about that requires that it applies all rewrites transitively. It is the entire point that the lowered version is again plain D code. (Also, UFCS is not "simply syntactic sugar". There are special lookup rules. Operator overloading ought to be the simple syntactic sugar here, but it isn't, because built-in types don't define the respective operator overloading functions. They should.) Sure, it _could_ be implemented that way, but the only reason I see to do that is if we're specifically looking to support defining overloaded operators outside of the types that they apply to. I can't think of anything else that would be affected by it. ... The compiler does not match the specification. I see no reason to change the specification here, but it would be easy. Regardless, I honestly think that it would be a very bad technical decision to support defining overloaded operators outside of the type itself - _especially_ when you take into account operators that have defaults generated by the compiler (e.g. opEquals), since that would allow a third party to change what your code does by adding their own overloaded operator. Well, how? "Overloaded operators" are just specially named functions that support an additional call syntax. There are no strange issues with modularity that somehow only apply to overloaded operators. UFCS calls can never ignore methods of the type. It does not matter how they were generated. Was this your strongest point against having the compiler combine UFCS and operator call syntax in the straightforward fashion?
Re: Tutorial on D + Chromium / CEF / DerelictCEF with OSX ?
On Tuesday, 8 September 2015 at 11:37:13 UTC, Mike McKee wrote: I downloaded DerelictCEF and used dub to compile it on my OSX (Yosemite). Now how do I get CEF downloaded and ready to work with it? I found an OSX 64 bit version file here: https://cefbuilds.com/ There doesn't seem to be any documentation for that part. From there, what is the trick to load up a local HTML page that says Hello World? Mike's busy writing a book, you're on your own for now: http://dblog.aldacron.net/2015/01/derelictcef-binding-to-chromium-embedded-framework/ You could try building and linking the sample code that he pasted there, using the standard procedure to link against C libraries, ie add "-L-L path/to/ceflib -L-l name_of_ceflib" to your dmd invocation.
Re: Status of Win32 C++ interop
On Tuesday, 8 September 2015 at 12:56:00 UTC, Laeeth Isharc wrote: How does it work when external APIs expect objects from the C++ standard library? strings, and so on? How about funny pointer types? shared_ptr etc? std::vector, std::list? No, in current state nothing smart is supported. See https://issues.dlang.org/show_bug.cgi?id=14086
Re: OSX prompt limit
Or just take it from the man page: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/signal.3.html
Re: Parameterized unittests and benchmarks (aka quickfix + benchmark) PR 2995
On Tuesday, 8 September 2015 at 12:24:19 UTC, tchaloupka wrote: On Tuesday, 8 September 2015 at 09:20:08 UTC, Robert burner Schadek wrote: On Tuesday, 8 September 2015 at 09:07:10 UTC, Edwin van Leeuwen wrote: Just to be clear. The PR is to add the needed ground work for adding benchmark, or does it also add some benchmarks itself? The PR adds benchmarks for some functions of std.string. I sort of like what Rust is using: https://github.com/rust-lang/rust/tree/master/src/test/bench If we can have similar benchmarks suite which can be tested with every release, it can help to spot speed regressions or promote new optimisations. Have you taken a look at the source of the PR. It does exactly that. Of course not ever function of phobos will get its benchmark in this PR, but this makes it easy to create benchmarks.
Re: Why 1f.iota(100f).array returns double[] not float[]?
On Tuesday, 8 September 2015 at 12:28:07 UTC, Dominikus Dittes Scherkl wrote: On Tuesday, 8 September 2015 at 07:17:01 UTC, Ali Çehreli wrote: https://github.com/D-Programming-Language/phobos/blob/master/std/range/package.d#L4630 auto iota(B, E)(B begin, E end) if (isFloatingPoint!(CommonType!(B, E))) { return iota(begin, end, 1.0); } Such kind of stuff would better be written as auto iota(B, E)(B begin, E end) { return iota(begin, end, cast(CommonType!(B, E))1.0); } this doesn't need a constraint anymore, or maybe use if(isNumeric!(CommonType!(B, E))) I tend to use the above kind of cast often, because I like to work with ubyte or ushort, and every f***ing number literal changes the type to uint :-/ Even better, use D's universal construction feature. auto iota(B, E)(B begin, E end) { return iota(begin, end, CommonType!(B, E)(1.0)); }
[Issue 15029] [Reg 2.068.0] _postblitRecurse invokes opDispatch with __xpostblit (breaks emplace)
https://issues.dlang.org/show_bug.cgi?id=15029 --- Comment #1 from Martin Nowak--- (In reply to Martin Nowak from comment #0) > but `__traits(hasMember, S, "__xpostblit")` should have instantiated > opDispatch > anyhow. `__traits(hasMember, S, "__xpostblit")` should NOT instantiate opDispatch and return false. --
Re: OSX prompt limit
On 9/8/15 9:20 AM, Adam D. Ruppe wrote: On Tuesday, 8 September 2015 at 13:17:31 UTC, Ola Fosheim Grøstad wrote: Or just take it from the man page: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/signal.3.html ah excellent. My web search came up with https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sigaction.2.html which didn't give the value! That's because it's iOS. You have to be careful with apple documentation, they look the same for both MacOS and ios, but often they are slightly different. -Steve
Re: Why 1f.iota(100f).array returns double[] not float[]?
On 9/8/15 3:17 AM, Ali Çehreli wrote: On 09/08/2015 12:00 AM, drug wrote: import std.array : array; import std.range : iota; pragma(msg, typeof(iota(1f, 100f).array)); // why double[] not float[]? void main() { } It is probably because the type of floating point literals like 1.0 is double. Probably there is a 1.0 in iota's implementation, converting the element type to double according to rule number 2 here: http://dlang.org/type.html#usual-arithmetic-conversions Yep, here it is: https://github.com/D-Programming-Language/phobos/blob/master/std/range/package.d#L4630 auto iota(B, E)(B begin, E end) if (isFloatingPoint!(CommonType!(B, E))) { return iota(begin, end, 1.0); } Although any such expression can become double easily, I think the literal should be 1.0f in this case. I think this warrants a bug report, iota with only floats as parameters should result in floats. -Steve
Re: OSX prompt limit
On Tuesday, 8 September 2015 at 13:17:31 UTC, Ola Fosheim Grøstad wrote: Or just take it from the man page: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/signal.3.html ah excellent. My web search came up with https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sigaction.2.html which didn't give the value! anyway the git is updated now
Re: Status of Win32 C++ interop
On Monday, 7 September 2015 at 18:37:49 UTC, Benjamin Thaut wrote: On Friday, 4 September 2015 at 16:19:49 UTC, Laeeth Isharc wrote: Hi Benjamin Would you be able to give a little more colour on what the limits are of interoperability for C++ with DMD master or release ? As I understand it destructors and constructors don't work, and obviously it will get tricky passing structures and classes from C++ libraries not ported to D. So, things that work really well are classes... So far I haven't found a situation where I couldn't make it work the way I wanted. Its just some work to write the D headers for the C++ classes and vise versa, because you have to duplicate everything once more. An automated tool for this would be nice, but unfotunately there is currently none. This is really very clear and helpful, and I appreciate your taking the time. I will place it on the wiki if that's okay. Library support is surely one of the largest impediments to the adoption of D, and we ought to place some emphasis on updating the documentation here: http://dlang.org/cpp_interface.html How does it work when external APIs expect objects from the C++ standard library? strings, and so on? How about funny pointer types? shared_ptr etc? std::vector, std::list? Here is one C++ library used by many in finance (at least as a backup). I think there might be a decent amount of value in making this usable from D. (Trying to put my own interests aside!) Paging Andy Smith ? http://quantlib.org/reference/_bermudan_swaption_8cpp-example.html Are there any well-known C++ libraries that you have interfaced to ? Could you give some examples of how long it takes ? Would you be able to drop me an email about something else? No contact info on your blog, but my domain is kaleidicassociates.com and my user id is laeeth@ Laeeth.
Re: OSX prompt limit
On Tuesday, 8 September 2015 at 13:02:35 UTC, Adam D. Ruppe wrote: On Tuesday, 8 September 2015 at 06:24:12 UTC, Joel wrote: arsd/terminal.d(1268): Error: undefined identifier 'SIGWINCH' There's a missing value in the signal header for OSX ! Could you run this little C program for me on your Mac and let me know the output? --- #include #include int main() { printf("%d\n", SIGWINCH); } --- I can't find the numeric value online either and I don't have a mac myself to check the headers :( ugh. 28SIGWINCH discard signal Window size change
Re: Benchmarking suite
On Tuesday, 8 September 2015 at 21:11:15 UTC, qznc wrote: Yes. I'm not sure how to structure this whole suite. The general goal is "D claims that it can match C/C++ in performance, let's have some actual numbers". So far D mostly disappoints in terms of performance. The most interesting thing to test is how they fare with high level optimization, not low level optimization. So make sure the implementation is similar...
Re: Behavior of opEquals
On Tuesday, 8 September 2015 at 20:55:35 UTC, Timon Gehr wrote: On 09/08/2015 06:49 PM, Jonathan M Davis wrote: Sure, it _could_ be implemented that way, but the only reason I see to do that is if we're specifically looking to support defining overloaded operators outside of the types that they apply to. I can't think of anything else that would be affected by it. ... The compiler does not match the specification. I see no reason to change the specification here, but it would be easy. I don't know where you get this idea. The spec says _nothing_ about UFCS applying to overloaded operators or that UFCS would apply to lowered code in any way shape or form. Regardless, I honestly think that it would be a very bad technical decision to support defining overloaded operators outside of the type itself - _especially_ when you take into account operators that have defaults generated by the compiler (e.g. opEquals), since that would allow a third party to change what your code does by adding their own overloaded operator. Well, how? "Overloaded operators" are just specially named functions that support an additional call syntax. There are no strange issues with modularity that somehow only apply to overloaded operators. UFCS calls can never ignore methods of the type. It does not matter how they were generated. Was this your strongest point against having the compiler combine UFCS and operator call syntax in the straightforward fashion? There would be no way to disambiguate overloaded operators if an operator were overloaded in multiple modules. foo + bar has no import paths involved in it at all. So, what would you do, write opBinary!"+"(foo, bar) instead? That's downright hideous, and it relies on you using the function call to emulate the operator correctly. For something like bar++, you'd be even more screwed, because it doesn't lower to a simple function call. UFCS is already enough of a problem on its own. It has some benefits, but it doesn't work when conflicts come into play, forcing you to just call the function normally, and its overload rules are such that it doesn't actually prevent hijacking in all cases (e.g. your code could suddenly change behavior, because you used UFCS with a type that then had a function with the same name and parameters added to it). And overloaded operators are closely tied to what a type does, whereas functions are far more diverse. So, there's a lot more to be gained with UFCS than with declaring overloaded operators separately from a type. I really don't see any reason why it would even make sense to declare operators separately from a type. So that you can declare multiple overloads of it for when you import different modules? That would just be plain confusing and incredibly error-prone. And if the problem is that you're dealing with someone else's type, then just declare a function to do what you want and be done with it. And do you really want people to be able to overload stray operators for stuff like strings and then write code that uses + and - and / or whatever on them? That would be ludicrous. It's one thing for people to do that with their own types. It's quite another to do that to built-in types or to someone else's types. What do you want next? To be able to declare constructors for someone else's type? That kind of stuff is part of the type, and allowing 3rd parties to declare it as well just makes it that much harder to figure out what's going on. At least when using UFCS, it's the exception that the function is on the type, so the overload rules don't usually shoot you in the foot (though they can), and you know to look elsewhere for the function just like you would with a function that was called normally. It's the complete opposite with operators. We have overloaded operators so that someone who is writing a user-defined type can make it act like a built-in type where appropriate. Allowing 3rd party code to declare overloaded operators for a type doesn't help with that at all. There is _nothing_ in the spec which supports UFCS having anything to do with overloaded operators and nothing to support overloading operators separately from a type. And I recall Walter Bright stating that it was on purpose that you can only overload operators on a type. So, even if the spec _could_ be interpreted to mean that you should be able to declare overloaded operators separately from the type that they apply to, that's _not_ its intention, and you're going to have to convince Walter if you want anything else. - Jonathan M Davis
Re: How to partially forward properties of struct array member to struct (disable length property) ?
On Sunday, 6 September 2015 at 10:12:58 UTC, ParticlePeter wrote: In the end all that I want is "just" to disable access to array.length through vector and alias this array. struct Vec(T, size_t n = 3) { T[n] data; alias data this; @disable @property size_t length() const; } void main() { Vec!int v; v[0] = 1; // ok assert(v[0] == 1); // ok int n = v.length; // error } - Kenji
Re: Are there any Phobos functions to check file permissions on Windows and Posix?
On Monday, 7 September 2015 at 15:48:56 UTC, BBasile wrote: On Sunday, 6 September 2015 at 23:05:29 UTC, Jonathan M Davis For example you can retieve the flags: archive/readonly/hidden/system/indexable(?) and even if it looks writable or readable, the file won't be open at all because the ACL for the file don't include the current user account. This guy enhanced the cross-platform fox toolkit capabilities. It would be worth looking at it if you intend to write something similar. See the section 7. Superior provision of host OS facilities portably http://tnfox.sourceforge.net/TnFOX/html/main.html
Re: Tutorial on D + Chromium / CEF / DerelictCEF with OSX ?
Bad timing on my part, I guess. If DerelictCEF gets off the ground, gets stable, and has good documentation (specifically on the CEF install part is what I lack), then that's an extremely robust, cross-platform GUI framework that D can take advantage of. I got DerelictCEF compiled okay -- it's the CEF install part that I lack. Here's what I'd like to do: * Show Chromium with my own custom titlebar, no tabs, a minimal menu, a non-resizable window but minimizable, and no page rightclick. * Load the HTML into Chromium from a resource file. * Inject D callbacks into the Javascript. * At that point, I can use CSS and jQuery in the HTML to interact with the D classes.
Win32 function vs delegate issues with api
I have hook = SetWindowsHookEx(WH_MOUSE, , NULL, ThreadID); Proc is the standard hook proc: public extern (Windows) LRESULT Proc(int code, WPARAM wParam, LPARAM lParam) I get a type mismatch because Proc is a delegate and SetWindowsHookEx expects a function. Making proc static works but not the behavior I want since all this stuff is wrapped in a class. Is there any way to pass Proc to SetWindowsHookEx without issues of GB and such? Error: function windows.winuser.SetWindowsHookExA (int, extern (Windows) int function(int, uint, int), void*, uint) is not callable using argument types (const(int), extern (Windows) int delegate(int code, uint wParam, int lParam), void*, uint) I could cast Proc to a function, obviously, but I'll loose the delegate behavior and create problems when I try to use this inside Proc?
[Issue 15031] New: rdmd should force rebuild when --compiler changes
https://issues.dlang.org/show_bug.cgi?id=15031 Issue ID: 15031 Summary: rdmd should force rebuild when --compiler changes Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: tools Assignee: nob...@puremagic.com Reporter: l...@luismarques.eu $ cat test.d version(LDC) static assert(false, "oops"); void main() {} $ rdmd --compiler=dmd test.d $ rdmd --compiler=ldc2 test.d $ touch test.d $ rdmd --compiler=ldc2 test.d test.d(1): Error: static assert "oops" Failed: ["ldc2", "-v", "-o-", "test.d", "-I."] --
Re: Benchmarking suite
On Monday, 7 September 2015 at 08:33:33 UTC, Dmitry Olshansky wrote: On 07-Sep-2015 11:29, qznc wrote: Maybe std.regex has just space for optimization? Sure thing, see WIP here (~25% faster but not yet complete): https://github.com/D-Programming-Language/phobos/pull/3314 It's been over a year since the last commit on that. Any updates?
Re: OSX prompt limit
On Tuesday, 8 September 2015 at 13:20:20 UTC, Adam D. Ruppe wrote: On Tuesday, 8 September 2015 at 13:17:31 UTC, Ola Fosheim Grøstad wrote: Or just take it from the man page: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/signal.3.html ah excellent. My web search came up with https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sigaction.2.html which didn't give the value! anyway the git is updated now Now I get the error: object.Exception@terminal.d(2745): too narrow terminal to draw It has a negative number in it. Thanks for working on it.
Re: OSX prompt limit
On Wed, Sep 09, 2015 at 12:05:52AM +, Joel via Digitalmars-d-learn wrote: > Now I get the error: What is your code calling the function? The prompt might just be too long.
Re: Tutorial on D + Chromium / CEF / DerelictCEF with OSX ?
On Tuesday, 8 September 2015 at 15:53:39 UTC, Mike McKee wrote: Bad timing on my part, I guess. If DerelictCEF gets off the ground, gets stable, and has good documentation (specifically on the CEF install part is what I lack), then that's an extremely robust, cross-platform GUI framework that D can take advantage of. Once the book is finished, my next focus will be on getting the documentation for all of the Derelict packages completed. Generally, I don't think it's my responsibility to document how to install the C libraries Derelict binds to, but given the scarcity of CEF documentation, I'll eventually put together a tutorial for it once I figure it all out myself. I'm eager to use CEF for a project I have in mind.
[Issue 15032] New: [REG2.068.1] coverage output is discreted around the calls to map(), canFind(), filter()
https://issues.dlang.org/show_bug.cgi?id=15032 Issue ID: 15032 Summary: [REG2.068.1] coverage output is discreted around the calls to map(), canFind(), filter() Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: regression Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: j...@red.email.ne.jp This is a 2.068.1 issue, not 2.068.0. The coverage counts for the lines are ommited, around some range operations holding lambdas. Image: |bool isParentOf(in Symbol p, in Symbol sym, in Scope scx ) { |if (!p.hasBaseClass) |return false; |if (!sym) |return false; |auto names = sym.baseClasses; 000|if (names.canFind!((a,b)=>a==b)(p.name)) |return true; |auto list = names.map!toAggrSym; 000|if (list.canFind!((n, p)=>isParentOf(p, n.s, n.scx))(p)) |return true; |return false; |} --
[Issue 14991] dmd doesn't build under OSX 32 bit
https://issues.dlang.org/show_bug.cgi?id=14991 --- Comment #2 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/591c1f865672c78a8d99b19642f8caaf8af0da63 fix Issue 14991 - dmd doesn't build under OSX 32 bit https://github.com/D-Programming-Language/dmd/commit/d90bcfb6c61bc315827a25d7de05110fdba31c79 Merge pull request #5016 from WalterBright/fix14991 [Reg] fix Issue 14991 - dmd doesn't build under OSX 32 bit --
Re: OSX prompt limit
On Wednesday, 9 September 2015 at 00:44:57 UTC, via Digitalmars-d-learn wrote: On Wed, Sep 09, 2015 at 12:05:52AM +, Joel via Digitalmars-d-learn wrote: Now I get the error: What is your code calling the function? The prompt might just be too long. import terminal; void main() { auto terminal = Terminal(ConsoleOutputType.linear); // I think I changed ConsoleOutputType from some thing else that didn't work auto line = terminal.getline("your prompt: "); terminal.writeln("You wrote: ", line); }
Re: Regression?
On Tuesday, 8 September 2015 at 07:12:52 UTC, FreeSlave wrote: On Tuesday, 8 September 2015 at 04:04:16 UTC, Sebastiaan Koppe wrote: Fixed it by changing into: ``` import std.conv : text; string json = File("../languages.json","r").byLineCopy().joiner.text; auto ls = json.parseJSON(); ``` Why would you read file by line and then merge all into one string? You end up with reading the whole file (well, getting rid of line ends) anyway, so probably the more efficient solution would be just read the whole file at once with std.file.read and cast to string. Thanks for your advice. But that is not what I asked for. The question was, why doesn't this work anymore with the latest (2.068.0 and 2.068.1) compiler: ``` auto ls = File("../languages.json","r").byLineCopy().joiner.parseJSON(); ``` It should. Right?
[Issue 15032] [REG2.068.1] coverage output is discreted around the calls to map(), canFind(), filter()
https://issues.dlang.org/show_bug.cgi?id=15032 --- Comment #1 from j...@red.email.ne.jp --- A reduced test case: [command] dmd -cov mod_a.d mod_b.d [mod_a.d] import std.string; [mod_b.d] import std.algorithm; void main() { int[] range; // this line should be counted // but suppressed by this bug // canFind, map, filter, and so on range.canFind!((a,b)=>true)(0); // this line is counted(but wrong?) } [Output(mod_b.lst)] ...snipped... |int[] range; // this line should be counted | // but suppressed by this bug |// canFind, map, filter, and so on 000|range.canFind!((a,b)=>true)(0); // this line is counted(but wrong?) ...snipped... Note: The order of mod_a.d and mod_b.d affects. --
Re: Win32 function vs delegate issues with api
On 09/09/15 12:18 PM, Prudence wrote: I have hook = SetWindowsHookEx(WH_MOUSE, , NULL, ThreadID); Proc is the standard hook proc: public extern (Windows) LRESULT Proc(int code, WPARAM wParam, LPARAM lParam) I get a type mismatch because Proc is a delegate and SetWindowsHookEx expects a function. Making proc static works but not the behavior I want since all this stuff is wrapped in a class. Is there any way to pass Proc to SetWindowsHookEx without issues of GB and such? Error: function windows.winuser.SetWindowsHookExA (int, extern (Windows) int function(int, uint, int), void*, uint) is not callable using argument types (const(int), extern (Windows) int delegate(int code, uint wParam, int lParam), void*, uint) I could cast Proc to a function, obviously, but I'll loose the delegate behavior and create problems when I try to use this inside Proc? You have the ability to store some user info along with the pointer. Store an integer. Use a global (private) array to map the integer to the actual delegate. Use a free function as the proc function. Of course, that has some indirection thats to the lookup. You could if able to rewrite as the free-function and pass in the class as user data, you could be smart about it ;) https://github.com/Devisualization/window/blob/master/platforms/win32/devisualization/window/window.d#L384 https://github.com/Devisualization/window/blob/master/platforms/win32/devisualization/window/window.d#L401
[Issue 15030] [Reg 2.068.1] ICE with recursive delegate, -unittest, and std.range
https://issues.dlang.org/show_bug.cgi?id=15030 Kenji Harachanged: What|Removed |Added Keywords||pull Hardware|x86_64 |All OS|Linux |All --- Comment #2 from Kenji Hara --- https://github.com/D-Programming-Language/dmd/pull/5058 --
[Issue 15030] [REG2.068.1] ICE with recursive delegate, -unittest, and std.range
https://issues.dlang.org/show_bug.cgi?id=15030 Kenji Harachanged: What|Removed |Added Summary|[Reg 2.068.1] ICE with |[REG2.068.1] ICE with |recursive delegate, |recursive delegate, |-unittest, and std.range|-unittest, and std.range --
Re: Article: More hidden treasure in the D standard library
On Monday, 31 August 2015 at 16:09:02 UTC, Gary Willoughby wrote: I've written a new article on D here: http://nomad.so/2015/08/more-hidden-treasure-in-the-d-standard-library/ Hopefully to drive other programmers to investigate D. It's a continuation of a similar one I wrote a few months ago which attracted over 60k readers. It's a simple overview of some cool features in the D standard library hopefully to fuel curiosity. Nice article! I've been using 'sequence' and just ignoring the state variables because I didn't realize that 'generate' existed. predSwitch is one that I know exists, but can never remember when I need it. And when I remember it exists, I've already forgotton where I last needed it...
Re: Visual Studio Code
On Monday, 3 August 2015 at 00:24:56 UTC, bitwise wrote: Just stumbled upon this: https://code.visualstudio.com/ I see support for Rust and Go, but no D. If you download it, there is a little smiley/frowny in the bottom right corner for feedback/feature requests. Or just vote here: http://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/7763160-support-the-d-programming-language Holding strong on page one of the top ideas! But if you haven't casted your vote(s) yet, please do! Bit
[Issue 15029] [Reg 2.069.0-devel] _postblitRecurse invokes opDispatch with __xpostblit (breaks emplace)
https://issues.dlang.org/show_bug.cgi?id=15029 Martin Nowakchanged: What|Removed |Added Summary|[Reg 2.068.0] |[Reg 2.069.0-devel] |_postblitRecurse invokes|_postblitRecurse invokes |opDispatch with __xpostblit |opDispatch with __xpostblit |(breaks emplace)|(breaks emplace) --
Re: dpaste web site
On Sunday, 30 August 2015 at 15:05:41 UTC, BBasile wrote: On Wednesday, 26 August 2015 at 05:54:44 UTC, nazriel wrote: On Thursday, 20 August 2015 at 20:28:48 UTC, Steven Schveighoffer wrote: [...] I will work on it. Should be fixed before weekend. I will also open source dpaste frontend and backend so such problems can be avoided in the future. Got a little bit behind with D related stuff and auto-updates of DMD stopped working for some reason. That's why we are on 2.065. Regards, Damian Ziemba since mothes 90% of the new content is spam. http://dpaste.dzfl.pl/pastes?p=8 Ok I've changed algorithm for spam detection Also tried to remove some of the spam already posted.
Re: Tutorial on D + Chromium / CEF / DerelictCEF with OSX ?
On 2015-09-08 13:37, Mike McKee wrote: I downloaded DerelictCEF and used dub to compile it on my OSX (Yosemite). Now how do I get CEF downloaded and ready to work with it? I found an OSX 64 bit version file here: https://cefbuilds.com/ I have no idea how to use the actual API but to use it you need to: 1. Download the 64bit binary 2. Extract the archive 3. Copy the file "Release/Chromium Embedded Framework.framework" to "/Library/Frameworks". DerelictCEF will automatically find the framework at runtime -- /Jacob Carlborg
Re: A collection of DIPs
On Tuesday, 8 September 2015 at 03:09:20 UTC, Rikki Cattermole wrote: On 08/09/15 5:27 AM, Shammah Chancellor wrote: void main() { import std.stdio : writeln; writeln("Hello world!"); } -Shammah It's not just an idiomatic way to code with local imports, it's a compilation performance technique too. I didn't read the DIP collection thoroughly (yup, D has a some grotesqueries that would be nice to fix but I doubt will happen) but local imports are one of the nice features of D (and Ada, and OCaml) that I wish would be adopted in some other languages, like Nim and Julia. I never thought of them as a performance optimization though. What's the reasoning? Are the observed differences significant? From my POV restricting the scope of an import makes local reasoning easier. I'd do it even if it were slightly less performant!
Re: Are there any Phobos functions to check file permissions on Windows and Posix?
On Monday, 7 September 2015 at 15:48:56 UTC, BBasile wrote: On Sunday, 6 September 2015 at 23:05:29 UTC, Jonathan M Davis wrote: [...] which makes treating some of this stuff in a cross-platform fashion quite difficult. And even more with ACLs that it could be: Not to mention, Windows locks files that are open and the recommended way to handle that is to open the file and see if you get an error.
Re: Tutorial on D + Chromium / CEF / DerelictCEF with OSX ?
On 2015-09-08 13:37, Mike McKee wrote: I downloaded DerelictCEF and used dub to compile it on my OSX (Yosemite). Now how do I get CEF downloaded and ready to work with it? I found an OSX 64 bit version file here: https://cefbuilds.com/ There doesn't seem to be any documentation for that part. From there, what is the trick to load up a local HTML page that says Hello World? BTW, these questions are more suited for the learn group [1]. [1] http://forum.dlang.org/group/learn -- /Jacob Carlborg
Re: Behavior of opEquals
On Saturday, 5 September 2015 at 09:45:36 UTC, Jacob Carlborg wrote: On 2015-09-05 08:26, Jonathan M Davis wrote: Clearly, you haven't read TDPL recently enough. ;) There is a free function, opEquals, in object.d which gets called for classes, and _it_ is what == gets translated to for classes, and it calls the member function version of opEquals on classes: https://github.com/D-Programming-Language/druntime/blob/master/src/object.d#L143 This allows us to avoid a number of fun bugs with opEquals that you get in languages like Java and makes it completely unnecessary to do stuff like check whether the argument to opEquals is null. Timon gave the link to the explanation in the spec: Bu you don't see my example as a problem? Well, it might be a bit annoying, but it's simply a matter of adjusting your code to call opEquals explicitly when trying to call the base version, whereas without the free function opEquals, you have subtle correctness problems. For instance, if you have base == derived and derived == base, you'll get the same result for both for D, whereas the equivalent Java or C# could would likely not, because the free function opEquals checks both lhs.opEquals(rhs) and rhs.OpEquals(lhs) whether you did base == derived or derived == base. So, while what we have is by no means perfect, I think that it is an improvement over what Java and C# did. - Jonathan M Davis
Re: OSX prompt limit
On Tuesday, 8 September 2015 at 06:24:12 UTC, Joel wrote: arsd/terminal.d(1268): Error: undefined identifier 'SIGWINCH' There's a missing value in the signal header for OSX ! Could you run this little C program for me on your Mac and let me know the output? --- #include #include int main() { printf("%d\n", SIGWINCH); } --- I can't find the numeric value online either and I don't have a mac myself to check the headers :( ugh.
[Issue 15029] New: [Reg 2.068.0] _postblitRecurse invokes opDispatch with __xpostblit (breaks emplace)
https://issues.dlang.org/show_bug.cgi?id=15029 Issue ID: 15029 Summary: [Reg 2.068.0] _postblitRecurse invokes opDispatch with __xpostblit (breaks emplace) Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: regression Priority: P1 Component: druntime Assignee: nob...@puremagic.com Reporter: c...@dawg.eu See https://github.com/D-Programming-Language/dub/issues/667. ~/dub$ ./build.sh Generating version file... Running dmd... /home/sun/INSTALL/dmd/include/d2/object.d(2329): Error: argument s.opDispatch!"__xpostblit" has no parent /home/sun/INSTALL/dmd/include/d2/std/conv.d(4054): Error: template instance object._postblitRecurse!(Json) error instantiating /home/sun/INSTALL/dmd/include/d2/std/conv.d(3917):instantiated from here: emplaceImpl!(Json) /home/sun/INSTALL/dmd/include/d2/std/array.d(2829):instantiated from here: emplaceRef!(Json, Json) /home/sun/INSTALL/dmd/include/d2/std/array.d(135):instantiated from here: put!(Json) source/dub/generators/sublimetext.d(39):instantiated from here: array!(MapResult!(targetFolderJson, Result)) source/dub/generators/sublimetext.d(61): Error: template instance std.array.array!(MapResult!(Json, string[])) error instantiating source/dub/generators/sublimetext.d(95): Error: template instance std.array.array!(Json[]) error instantiating source/dub/generators/sublimetext.d(99): Error: template instance std.array.array!(MapResult!(makeBuildSystem, string[])) error instantiating source/dub/internal/sdlang/lexer.d-mixin-1260(1260): Deprecation: constructor std.datetime.SysTime.this is deprecated - Please use the overload which takes a Duration instead of a FracSec. source/dub/internal/sdlang/lexer.d-mixin-1268(1268): Deprecation: constructor std.datetime.SysTime.this is deprecated - Please use the overload which takes a Duration instead of a FracSec. It fails over `s.opDispatch!"__xpostblit" has no parent` but `__traits(hasMember, S, "__xpostblit")` should have instantiated opDispatch anyhow. --
[Issue 9558] 0b and 0x prefixes for std.string.isNumeric
https://issues.dlang.org/show_bug.cgi?id=9558 hst...@quickfur.ath.cx changed: What|Removed |Added CC||hst...@quickfur.ath.cx --- Comment #1 from hst...@quickfur.ath.cx --- I'm not sure about this. The '0x', '0b', etc., prefixes are syntax defined by programming languages, whereas isNumeric is intended to check user input. Presumably, most users wouldn't know what 0x, 0b, etc., are, and may be surprised to learn that what they consider as invalid input (e.g. 0b10) is actually accepted by the program, with results that are unexpected to them. Parsing programming language literals should not be conflated with parsing user input. --