Re: ARM Cortex-M Microcontroller startup files
On Thursday, 30 April 2015 at 00:14:18 UTC, Martin Nowak wrote: Wonder if it makes more sense to start from zero and add as few files as possible. When I started I did not know D enough to understand what druntime does. Just picked the easy way. The amount of required changes has got smaller in every release. It is easy to maintain: I get mainstream updates and bug fixes just by patching. Mike has done some work with an empty runtime and Adam has a chapter in his book. I do not know any real programs made from this base Druntime doesn't do much useful stuff for a µC anyhow. - GC and rt.lifetime (new, arrays) - Moduleinfo - EH unwind support - AA implementation - vectorized array ops - core.time/sync/thread/demangle UC programs mostly use static resources but I think 'new' is useful to initialize class objects at runtime. I got exceptions to work but I do not know how much use they have. There should be some time routines. What might be interesting is this. - core.bitop - maybe core.atomic - some gcc simd module - libc bindings for core.stdc.math and core.stdc.stdio for printf Printf is a little tricky. It is actually a file operation to stdout and that is actually a syscall to kernel. In a controller board we may have several devices where we can send data like uart and oled display. (I even have a video output where video signal is generated with just one spi and one timer) I think java style would be better here like console = new Formatter (new uartWriter (uart2) ) console.printf(,...) This way the formatter can be reused and is not bound to any hardware. I think it is possible to make a minimum bare metal runtime fom scratch. However, there are some requirements: - A team. One man project may never get ready and it will not receive enough attention. It is also often tailored to personal needs which makes it difficult for others to use. - An insider. A project from unknown people will just be ignored. (I think we may have one now) - A project coordinator. I think we will find one. - Some people who want to work. We may have a couple. If people thik we should start, I am with.
Re: if(arr) now a warning
On Wednesday, 29 April 2015 at 17:35:58 UTC, Andrei Alexandrescu wrote: I have no doubt the change can find certain errors. Problem is false positives. FWIW these are the changes I had to operate on std.allocator to make it work with the new compiler. That code is contrived, confusing and consequently bug-prone, I'd say compiler complaints are legit in those cases, they are not as false positive as you want to make it look like. All in all your argument is quite biased and impractical.
Re: C++ interface problem
On Wednesday, 29 April 2015 at 19:04:11 UTC, extrawurst wrote: On Wednesday, 29 April 2015 at 13:55:46 UTC, Benjamin Thaut wrote: On Monday, 27 April 2015 at 21:19:02 UTC, extrawurst wrote: here is the shortened version of the returned class CSteamID: https://gist.github.com/Extrawurst/936f56ceaa87cf287257 this is the shortened interface (no destructors in the rest of the code either): https://gist.github.com/Extrawurst/b20dc5ab84132ecab30d the method `GetFriendByIndex` is the one crashing on win32. I assume that's because CSteamID is returned by value. Are you defining CSteamID in D as a struct? If not you have to because only structs can be returned by value. The next problem is that CSteamID is 64bits wide, this might be a problem as it can not be returned in a single register. You could try changeing the definition of GetFriendByIndex on the D side to ulong GetFriendByIndex(...) and reinterpret the ulong on the D side. If that does not work however you are most likely out of luck because the way your c++ library returns a value type 32-bit is not compatible with what dmd expects. Do you have debug symbols for the third party c++ library? Can you step into the virtual function call to actually see if it ends up in the correct function on the c++ side? Kind Regards Benjamin Thaut Seems i am out of luck. I tried all that. The Steamworks SDK is closed source without debugging symbols. so it wont work.. too bad, this library would have been a good example case of seamless c++-interfacing from D... Did you try windows 64-bit? Calling conventions on 64-bit windows are better standardized.
[Issue 14531] New: `@disable this() immutable` disable mutable default construction, too
https://issues.dlang.org/show_bug.cgi?id=14531 Issue ID: 14531 Summary: `@disable this() immutable` disable mutable default construction, too Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: DMD Assignee: nob...@puremagic.com Reporter: schue...@gmx.net struct S { @disable this() immutable; } void main() { S s; } = xx.d(6): Error: variable xx.main.s default construction is disabled for type S --
[Issue 14532] New: switch block allows creating uninitialized variables
https://issues.dlang.org/show_bug.cgi?id=14532 Issue ID: 14532 Summary: switch block allows creating uninitialized variables Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: DMD Assignee: nob...@puremagic.com Reporter: ket...@ketmar.no-ip.org consider the code: void main () { import std.stdio; char ch = '!'; switch (ch) { int n = 42; case '!': writeln(n, : wow!); break; //(1) default: } } `n` variable is available at (1), but it is not initialized to 42, it contains random garbage instead. compiler should either execute all code before first `case` label unconditionally, or forbid having unlabeled code in `switch` block. --
Re: [dvm] Can't install compilers on Mac
On 2015-04-29 23:24, Chris wrote: Yes. Doesn't work. What happens when you run ./dvm install dvm? What is the output? If the installation of DVM itself fails you will not be able to install compilers. You can verify the installation of DVM by opening a new shell session (a new tab or window in Terminal) and run type dvm | head -1. It should print dvm is a function. Maybe I should just download it and compile it myself? No, should not be necessary and would most likely not make a difference. -- /Jacob Carlborg
[Issue 14529] Bug in Regex case insensitive match
https://issues.dlang.org/show_bug.cgi?id=14529 Kasa Mia kasamia.o.kasa...@gmail.com changed: What|Removed |Added Summary|Bug in Regex insensitive|Bug in Regex case |match |insensitive match --
Re: getopt helpWanted
On Wednesday, 29 April 2015 at 22:02:29 UTC, novice2 wrote: Hello. Help me please to understand, how to show usage help to user, who enter wrong options? For example, user not provided required filename. I want to show error message, and program usage help text. But likely getopt don't provide help text until valid options will be parsed. Reduced code: /// import std.stdio: writefln; import std.getopt; void main (string[] args) { string fname; GetoptResult helpInfo; try { helpInfo = getopt( args, std.getopt.config.required, file|f, File name, fname); writefln(Options parsed: fname=%s, fname); } catch(Exception e) { writefln(\nERROR: %s, e.msg); defaultGetoptPrinter(Program usage:, helpInfo.options); } } /// Output: ERROR: Required option file|fwas not supplied Program usage: Also, I suggest you look at docopt: http://code.dlang.org/packages/docopt It makes the whole parsing of CLI arguments very nice and easy.
Re: getopt helpWanted
Thank you, Brian!
[Issue 14530] New: TickDuration to! is broken
https://issues.dlang.org/show_bug.cgi?id=14530 Issue ID: 14530 Summary: TickDuration to! is broken Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: druntime Assignee: nob...@puremagic.com Reporter: ket...@ketmar.no-ip.org this code is not working anymore with git HEAD: void main () { import core.time; auto t = TickDuration.from!seconds(1000); auto n = t.to!(msecs, float); } include/d2/core/time.d(1706): Error: 'this' is only defined in non-static member functions, not to coretime_bug00.d(4): Error: template instance core.time.to!(msecs, float, TickDuration) error instantiating this was introduced in commit cb525460829e6354f203b2c467dc6d58e6e24c0e --
Re: shouldn't this code at least trigger a warning?
On Wed, 29 Apr 2015 10:48:36 +, Gary Willoughby wrote: Please raise an issue in bugzilla. This is obviously an error. done: https://issues.dlang.org/show_bug.cgi?id=14532 signature.asc Description: PGP signature
Re: shouldn't this code at least trigger a warning?
On Wed, 29 Apr 2015 07:57:07 -0700, H. S. Teoh via Digitalmars-d-learn wrote: Switch statements in D allow all sorts of abominations, if only you would try it. I think it was originally designed to support a particular loop idiom (sorry I forgot what it was called, and don't have time to look it up right now), but in the process this also opened the door to all sorts of nasty infelicities that probably breaks the type system, control flow, and many other things. Basically, the block inside a switch statement essentially amounts to free-for-all spaghetti code where you're free to jump around case labels willy-nilly, declare variables and jump over their initializations, break out of loops with goto case, or enter into the middle of a loop, and all sorts of other crazy things that, ostensibly, you shouldn't be able to do in a language like D. yes, `switch` is one of those legacy cans of worms. i'm afraid that it's too late to redesign it, but it would be nice if each `case` will be an implicit `{}` block, and `goto case`/`break` will be allowed only as a last statement in `case` block. and unlabeled code in `switch` should be forbidden to. but, as i said, it's too late to introduce such breaking change to language. signature.asc Description: PGP signature
Re: How does D improve on C++17?
I believe that the developers of D is a great opportunity: to copy all the new features before the release of C++17 in Phobos :) In my opinion, that would be cool! Thoughts about C++17: https://isocpp.org/files/papers/D4492.pdf
[Issue 14533] New: Error 43: Not a Valid Library File
https://issues.dlang.org/show_bug.cgi?id=14533 Issue ID: 14533 Summary: Error 43: Not a Valid Library File Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: enhancement Priority: P1 Component: DMD Assignee: nob...@puremagic.com Reporter: do...@putao.com link a c lib to my D code pragma(lib, libmysql.lib); when dmd d file it shows error as follows: libmysql.lib Error 43: Not a Valid Library File how can I do this? --
Ada to D - an array for storing values of each of the six bits which are sufficient
Hi, There is an array of values to store each of which sufficiently 6 bits. As it is written down on the D? - With Ada.Text_IO; Use Ada.Text_IO; With Ada.Integer_Text_IO; Use Ada.Integer_Text_IO; procedure Program is type T_Type is range -10 .. 27; for T_Type'Size use 6; type Vector is array(1 .. 100) of T_Type; Pragma Pack(Vector); My_Array : constant Vector := (1 = -5, 2 = 22, others = 10); begin Put_Line(Integer'Image(My_Array'Size)); end Program; - http://ideone.com/uAzl41
Re: Ada to D - an array for storing values of each of the six bits which are sufficient
Dennis Ritchie: There is an array of values to store each of which sufficiently 6 bits. As it is written down on the D? You can't do it directly in D. Someone has to write a packed array data structure to do it. Bye, bearophile
Re: C++ interface problem
On Thursday, 30 April 2015 at 08:18:16 UTC, Benjamin Thaut wrote: On Wednesday, 29 April 2015 at 19:04:11 UTC, extrawurst wrote: On Wednesday, 29 April 2015 at 13:55:46 UTC, Benjamin Thaut wrote: On Monday, 27 April 2015 at 21:19:02 UTC, extrawurst wrote: here is the shortened version of the returned class CSteamID: https://gist.github.com/Extrawurst/936f56ceaa87cf287257 this is the shortened interface (no destructors in the rest of the code either): https://gist.github.com/Extrawurst/b20dc5ab84132ecab30d the method `GetFriendByIndex` is the one crashing on win32. I assume that's because CSteamID is returned by value. Are you defining CSteamID in D as a struct? If not you have to because only structs can be returned by value. The next problem is that CSteamID is 64bits wide, this might be a problem as it can not be returned in a single register. You could try changeing the definition of GetFriendByIndex on the D side to ulong GetFriendByIndex(...) and reinterpret the ulong on the D side. If that does not work however you are most likely out of luck because the way your c++ library returns a value type 32-bit is not compatible with what dmd expects. Do you have debug symbols for the third party c++ library? Can you step into the virtual function call to actually see if it ends up in the correct function on the c++ side? Kind Regards Benjamin Thaut Seems i am out of luck. I tried all that. The Steamworks SDK is closed source without debugging symbols. so it wont work.. too bad, this library would have been a good example case of seamless c++-interfacing from D... Did you try windows 64-bit? Calling conventions on 64-bit windows are better standardized. no i did not, win64-only is a no-option unfortunately
Re: [hackathon] An article about metaprogramming
On Wednesday, 29 April 2015 at 18:13:10 UTC, Mafi wrote: On Wednesday, 29 April 2015 at 16:55:58 UTC, bearophile wrote: Mafi: https://marfisc.wordpress.com/2015/04/29/using-d-templates-for-gamedev/ What do you think? Any remarks? The SDL_Event is a union. Accessing it is inherently unsafe for type consistency and memory safety. The SDL library mitigates this problem by adding a tag (the member type) which encodes which union-member is to be used. In Rust you use the built-in tagged unions and call it a day... Well, it is an already existing C library I am only adapting. And additionally the shonwn template encapsulates the whole outer loop as well. [...] The default should be aligned just like the other cases. Often is a good idea to use final switch with enumerations. Probably there are ways to make that code more dry, using a TypeTuple of pairs like (SDL_QUIT, quit). Bye, bearophile I cannot use a final switch there because it is not enumerated type. The values are just constants. Moreover I want to skip unneeded labels and instead unify them into the default branch. This is impossible with a final switch. If you invest some effort in redefining the event types as D structs and the event codes as a D enum, you can get rid of that routing-list construct altogether: http://dpaste.dzfl.pl/1e992d248355
[Issue 14533] Error 43: Not a Valid Library File
https://issues.dlang.org/show_bug.cgi?id=14533 Richard Cattermole alphaglosi...@gmail.com changed: What|Removed |Added CC||alphaglosi...@gmail.com --- Comment #1 from Richard Cattermole alphaglosi...@gmail.com --- Just to confirm this is for 64bit builds on Windows? And not the default of 32bit? --
Re: if(arr) now a warning
Vladimir Panteleev wrote in message news:ajrysqkjmlqjlmkip...@forum.dlang.org... On Wednesday, 29 April 2015 at 19:15:46 UTC, Jonathan M Davis wrote: but std.allocator is definitely not your average code OK, I'm tired of hearing this argument. It's valid though. Most array code cares more about the contents than the address, while std.allocator only cares about the address. Here's the results against my ae library: ... I didn't examine every single one, but the first dozen are all false positives. Yeah, looks like you're intentionally checking for null rather than empty. It sucks that so many places need updating. Oh, and note the few that occur in Phobos templates (with no instantiation trace). I'll have fun tracking those down! Is that from string lambdas? Does it give an instantiation trace when you use it with warning as errors?
dub -vgc
How can I make use of the -vgc compiler switch in my DUB project? -- Robert M. Münch http://www.saphirion.com smarter | better | faster
Re: Closure capture loop variables
On Thursday, 30 April 2015 at 12:01:32 UTC, Marc Schütz wrote: On Thursday, 30 April 2015 at 05:23:55 UTC, Vladimir Panteleev wrote: On Thursday, 30 April 2015 at 03:58:44 UTC, Freddy wrote: On Thursday, 30 April 2015 at 01:19:45 UTC, Vladimir Panteleev wrote: Because copy is still modified every time i is. But shouldn't copy be redeclared every loop iteration (or the compiler could pretend to redeclare it). No, it will have the same address every time. The current behaviour is wrong: https://issues.dlang.org/show_bug.cgi?id=2043 https://issues.dlang.org/show_bug.cgi?id=8621 These are slightly different problems. I think Freddy's programs are working as designed. D closures should work in the same way as, e.g., JS closures. Try rewriting the program in JavaScript. If it behaves in the same way, it's not a D bug.
Re: The amazing template which does nothing
On Wednesday, 29 April 2015 at 14:18:49 UTC, Iain Buclaw wrote: On 29 April 2015 at 14:50, John Colvin via Digitalmars-d digitalmars-d@puremagic.com wrote: On Wednesday, 29 April 2015 at 12:07:58 UTC, Vladimir Panteleev wrote: On Wednesday, 29 April 2015 at 07:00:15 UTC, John Colvin wrote: On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev wrote: On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote: Trying on d.godbolt.com it seems a lot of extra-code is generated for the first version. d.godbolt.com is dead, use asm.dlang.org d.godbolt.org (note .org not .com) works fine and will be updated to the latest GDC shortly. asm.dlang.org only has DMD. Ah, my bad! I know Iain was involved so I thought it had GDC as well :) d.godbolt.org now has the latest release as default. I take it you've been speaking to the site maintainer? :o) Looks like he downloaded the binary off gdcproject.org? Yes and yes.
Re: ARM Cortex-M Microcontroller startup files
On Thursday, 30 April 2015 at 00:14:18 UTC, Martin Nowak wrote: Wonder if it makes more sense to start from zero and add as few files as possible. Druntime doesn't do much useful stuff for a µC anyhow. - GC and rt.lifetime (new, arrays) - Moduleinfo - EH unwind support - AA implementation - vectorized array ops - core.time/sync/thread/demangle What might be interesting is this. - core.bitop - maybe core.atomic - some gcc simd module - libc bindings for core.stdc.math and core.stdc.stdio for printf Starting from zero appeals to my way of thinking. I've made several attempts at this both on the PC and for microcontrollers, so please allow me to offer my thoughts on the idea: If starting from zero, I recommend narrowing the scope to simply runtime initialization. IMO, if one can get to main with a small subset of the language ready for use, the rest is mostly icing on the cake. While this may seem simple to achieve, I think it will raise a few questions that will need answering. * Can ModuleInfo be leveraged, without introducing overhead, to call module constructors and static constructors? They might be useful for hardware initialization. * Is dynamic memory allocation a requirement of D, or a library feature? * Does D need the C runtime, or can it init on its own? * Should the C standard library bindings be part of the runtime, or exist as an external Deimos library? Either way they can still be used by the runtime, I'm just suggesting that they should be encapsulated. * What will be done about TypeInfo for now? It's causing me some serious code-bloat problems. See http://forum.dlang.org/post/quemhwpgijwmqtpxu...@forum.dlang.org * Is data and bss initialization part of the runtime, or delegated to toolchain, silicon, and BSP vendors? I think runtime initialization is a relatively simple task, but would still present a few challenges, choices, and even a few problems. However, due to the fact that it's narrow in scope, I suspect it would be a likely success and could put some momentum in the right direction. Mike
[Issue 10524] Switch skips initialization of 'with' variable
https://issues.dlang.org/show_bug.cgi?id=10524 yebblies yebbl...@gmail.com changed: What|Removed |Added Depends on||14532 --
[Issue 14532] switch block allows creating uninitialized variables
https://issues.dlang.org/show_bug.cgi?id=14532 yebblies yebbl...@gmail.com changed: What|Removed |Added Blocks||10524 --
Re: The amazing template which does nothing
On 30 April 2015 at 15:01, John Colvin via Digitalmars-d digitalmars-d@puremagic.com wrote: On Wednesday, 29 April 2015 at 14:18:49 UTC, Iain Buclaw wrote: On 29 April 2015 at 14:50, John Colvin via Digitalmars-d digitalmars-d@puremagic.com wrote: On Wednesday, 29 April 2015 at 12:07:58 UTC, Vladimir Panteleev wrote: On Wednesday, 29 April 2015 at 07:00:15 UTC, John Colvin wrote: On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev wrote: On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote: Trying on d.godbolt.com it seems a lot of extra-code is generated for the first version. d.godbolt.com is dead, use asm.dlang.org d.godbolt.org (note .org not .com) works fine and will be updated to the latest GDC shortly. asm.dlang.org only has DMD. Ah, my bad! I know Iain was involved so I thought it had GDC as well :) d.godbolt.org now has the latest release as default. I take it you've been speaking to the site maintainer? :o) Looks like he downloaded the binary off gdcproject.org? Yes and yes. You could have waited a month for gdc-5 to come out of experimental... https://packages.debian.org/experimental/gdc-5
Re: Closure capture loop variables
On Thursday, 30 April 2015 at 05:23:55 UTC, Vladimir Panteleev wrote: On Thursday, 30 April 2015 at 03:58:44 UTC, Freddy wrote: On Thursday, 30 April 2015 at 01:19:45 UTC, Vladimir Panteleev wrote: Because copy is still modified every time i is. But shouldn't copy be redeclared every loop iteration (or the compiler could pretend to redeclare it). No, it will have the same address every time. The current behaviour is wrong: https://issues.dlang.org/show_bug.cgi?id=2043 https://issues.dlang.org/show_bug.cgi?id=8621
Re: if(arr) now a warning
On Wed, 29 Apr 2015 22:44:22 -0400, Steven Schveighoffer wrote: On 4/29/15 8:35 PM, Martin Nowak wrote: Occasionally I'm using if (auto ary = func()), despite the fact that the semantics are wrong, but it's nice and short and works as long a func always returns null instead of empty slices. I wonder if it's possible to fix this, as it is, IMO, the only legitimate drawback of this change. Could we make the following work? if((auto ary = func()).length) -Steve I would have though this would work: if(auto x = foo(), !x.empty)
Re: dub building is extremely slow
On Thursday, 30 April 2015 at 03:00:36 UTC, zhmt wrote: On Thursday, 30 April 2015 at 02:02:50 UTC, zhmt wrote: dub build is running on centos7. It works well until today, It becomes very slow suddenly. It will take minuties per compilation, there is 10 files in project. Has anyone experienced this? It is because: The dub will connect to some website to check version of packages,but the destination website is limited by my gov,so... the compilation is slowed. solution: shutdown the network of pc. Try running with --nodeps (or --no-deps on phone so cant check). It will make dub stop contacting the network.
Re: if(arr) now a warning
Andrei Alexandrescu: I have no doubt the change can find certain errors. Problem is false positives. FWIW these are the changes I had to operate on std.allocator to make it work with the new compiler. One per 194 lines on average, all false positives: Just fix your code Andrei Alexandrescu :-) Bye, bearophile
Re: Quit running foreign unittests _
On Wednesday, 29 April 2015 at 15:00:53 UTC, Dicebot wrote: The core of Nick proposal (and what he does in his own libraries) is to not compile tests of dependnecies even when those are all compiled at once in -unittest mode. If they are compiled in unittest mode, all their unittests are compiled and run. What's problem? He uses `version(MyLibUnittest)` to disable all those completely and to run all tests you need to provide full set of such version flags for each dependency (transitively). This is what affects me and what I don't see implemented as a default. If the enhancement is implemented, that hack with versions won't be needed, all tests will be plain unittests, which will suit both you and Nick.
[Issue 14532] switch block allows creating uninitialized variables
https://issues.dlang.org/show_bug.cgi?id=14532 yebblies yebbl...@gmail.com changed: What|Removed |Added Keywords||accepts-invalid, safe CC||yebbl...@gmail.com --- Comment #1 from yebblies yebbl...@gmail.com --- This is the underlying issue in bug 10524 and is closely related to issue 602. --
Re: if(arr) now a warning
On Thursday, 30 April 2015 at 02:51:33 UTC, Vladimir Panteleev wrote: OK, I'm tired of hearing this argument. Distinction between null and empty can be done, the problem is it doesn't fly in mainstream.
Re: Range of chars (narrow string ranges)
On Friday, 24 April 2015 at 20:44:34 UTC, Walter Bright wrote: Time has shown, however, that UTF8 has pretty much won. wchar only exists for Windows API and Java Also NSString. It used to support UTF-16 and C encoding. AFAIK, the latter later evolved into UTF-8.
Re: if(arr) now a warning
On Thursday, 30 April 2015 at 11:46:05 UTC, Daniel Murphy wrote: Is that from string lambdas? I don't know. The one in std.exception is probably due to an array being used as a condition for enforce. Does it give an instantiation trace when you use it with warning as errors? It doesn't.
Re: Create custom data types
Another possible way is to check the bounds at compile time. The different operators need to be overloaded for that. For example, if you have to types Int!(0, 100) and Int!(20, 30), the result type of an addition needs to be Int!(20, 130). Then, there can be an overloaded opCast() to bool for use with if(): Int!(20, 130) i; if(auto j = i.checkBounds(20, 32)) { static assert(is(typeof(j) == Int!(20, 32))); }
Re: if(arr) now a warning
Vladimir Panteleev wrote in message news:swjdkyjsurpjdqrvq...@forum.dlang.org... I don't know. The one in std.exception is probably due to an array being used as a condition for enforce. Yep, that's not nice. From what I can see the warning in the template constraint is ignored, and so the call succeeds. I don't know how to force a failure there with a warning.
Re: Closure capture loop variables
On Thu, 30 Apr 2015 12:55:16 +, Vladimir Panteleev wrote: D closures should work in the same way as, e.g., JS closures. js closures are fubared. signature.asc Description: PGP signature
Re: Interrogative: What's a good blog title?
On Monday, 27 April 2015 at 22:54:07 UTC, Andrei Alexandrescu wrote: My only candidate right now is Greasemonkey Philosopher. I'm shooting for a title that reflects the contrast between my low-level and high-level aspirations. Deus Ex Machina (subtle D reference there) Machine Shop Philosopher (another subtle D reference) Template Assembler (reference to your book) Nanite Face Paint (subtle reference to your current job)
Re: if(arr) now a warning
On 4/30/15 4:46 AM, Daniel Murphy wrote: Vladimir Panteleev wrote in message news:ajrysqkjmlqjlmkip...@forum.dlang.org... On Wednesday, 29 April 2015 at 19:15:46 UTC, Jonathan M Davis wrote: but std.allocator is definitely not your average code OK, I'm tired of hearing this argument. It's valid though. I think we need to stop here. I'll make the PR today for reverting this language change. We can't handle D like a semester science project, because for as long as we do we won't have credibility. This trickle of teeny-bit breaking changes for the sake of touted benefits must stop. In the future please do not make breaking changes without my and Walter's approval. Thanks, Andrei
Re: Closure capture loop variables
On 04/30/2015 05:55 AM, Vladimir Panteleev wrote: D closures should work in the same way as, e.g., JS closures. Try rewriting the program in JavaScript. If it behaves in the same way, it's not a D bug. Right. I remember Seth Ladd's Dart language presentation at the local ACCU in Silicon Valley. He was explaining how Dart was different from other languages in this respect. I think he had mentioned JavaScript with the behavior that he was not fond of, so he had designed the language the way OP wants. He explains it here: http://blog.sethladd.com/2012/01/for-loops-in-dart-or-fresh-bindings-for.html Ali
Re: Possible to write a classic fizzbuzz example using a UFCS chain?
Just for fun: // map, join, text, iota, writeln, tuple import std.algorithm, std.array, std.conv, std.range, std.stdio, std.typecons; void main() { iota(1,100) .map!(a = tuple(a, a % 3 == 0 ? 0 : 4, a % 5 == 0 ? 8 : 4)) .map!(a = a[1] == a[2] ? a[0].text : fizzbuzz[a[1] .. a[2]]) .join(, ) .writeln; }
Re: Building DMD on SmartOS
On Thursday, 30 April 2015 at 17:39:02 UTC, flamencofantasy wrote: Hello, I would like to use D on SmartOS. Since there is no binary installer I tried to build DMD from source by following the instructions on this page; http://wiki.dlang.org/Building_DMD Unfortunately I get this error; [~/d/dmd/src]# make -f posix.mak MODEL=64 no cpu specified, assuming X86 dmd idgen.d make: dmd: Command not found posix.mak:320: recipe for target 'idgen' failed make: *** [idgen] Error 127 dmd git HEAD requires a host D compiler to build dmd because it's moving files from C++ to D, ie the compiler is becoming self-hosted. This is a problem for new platforms like SmartOS, as dmd doesn't really support cross-compiling yet. However, you can roll back to the last release branch, 2.067, and try compiling that on SmartOS with just a C++ compiler. Of course, the Solaris support in dmd/druntime/phobos is not really tested, so you may need to fill in some gaps for SmartOS.
Re: Interrogative: What's a good blog title?
The D Tales
Implicit conversion error
When compiled on a 64 bit machine, this line int r = uniform(0, mobs.length); gives me an error: Error: cannot implicitly convert expression (uniform(0, mobs.length)) of type ulong to int but it compiles ok on a 32 bit machine. I thought it was the expression on the righthand side returning a ulong which won't 'fit' in an int but if I substitute a numerical value instead of trying to get the length, eg uniform(0, 5) it compiles. Why is that? (mobs is an array of structs) TIA Paul
Re: Code coverage for D now supported
On 4/29/15 1:55 PM, Steve Peak wrote: With the help of @ColdenCullen, Codecov now supports D language. You can easily upload your coverage reports and utilize our many features to enhance your workflow. Writing tests for your code is important, no question. The results of your tests is simply pass or fail without proper coverage reports. Codecov makes it easy to upload coverage metrics to get more insight into how your tests are performing. A must have is our Browser Extension that overlays coverage reports directly in Github's interface for a seamless experience and further insight into your code. Unlimited public repos, free forever. Unlimited private repos only $5 a month. Learn more at https://codecov.io View examples at https://github.com/codecov/example-d Questions and comments: he...@codecov.io Twitter: @codecov Thank you and have a great day! Steve and the Codecov Family Awesome. Reddited it, now at position 30: http://www.reddit.com/r/programming -- Andrei
Re: if(arr) now a warning
On Thursday, 30 April 2015 at 16:49:59 UTC, Daniel Murphy wrote: Andrei Alexandrescu wrote in message news:mhtggg$26b5$1...@digitalmars.com... I think we need to stop here. I'll make the PR today for reverting this language change. We can't handle D like a semester science project, because for as long as we do we won't have credibility. This trickle of teeny-bit breaking changes for the sake of touted benefits must stop. This breaking change prevents hard-to-find bugs. The fact that you needed to make trivial changes to 39 places in std.allocator doesn't negate this. I can second this. The code is often not test in an apropriate manner. Let's say you have some code that goes as: auto foo(T[] ts) { if (ts) { // ... } else { // ... } } Now test : unitest { assert(foo([1, 2, 3]) == ...); assert(foo([]) == ...); } All tests passes, the code looks correct, but in fact it is going to break when foo is called with a drained range, or some slicing tat happen to have 0 elements. That makes for very hard to find bugs. The current behavior is also inconsistent with general slice behavior (which distinguish between identity and value). People are not making stuff up here. The current behavior is bug prone AND inconsistent. And yes, I'm working on SDC's GC, so I'm aware that there is code that specifically care about the address. This is what the is operator is for.
Re: if(arr) now a warning
On Thursday, 30 April 2015 at 17:10:23 UTC, Jeremy Powers wrote: On Thu, Apr 30, 2015 at 8:08 AM, Andrei Alexandrescu via Digitalmars-d digitalmars-d@puremagic.com wrote: This trickle of teeny-bit breaking changes for the sake of touted benefits must stop. This is how you improve the language. Only if you ignore the costs of the change...
Re: if(arr) now a warning
On Thu, Apr 30, 2015 at 8:08 AM, Andrei Alexandrescu via Digitalmars-d digitalmars-d@puremagic.com wrote: This trickle of teeny-bit breaking changes for the sake of touted benefits must stop. This is how you improve the language. You can disagree with the touted benefits, but without changes of this sort the language will never get better.
Re: if(arr) now a warning
Andrei Alexandrescu wrote in message news:mhtggg$26b5$1...@digitalmars.com... I think we need to stop here. I'll make the PR today for reverting this language change. We can't handle D like a semester science project, because for as long as we do we won't have credibility. This trickle of teeny-bit breaking changes for the sake of touted benefits must stop. This breaking change prevents hard-to-find bugs. The fact that you needed to make trivial changes to 39 places in std.allocator doesn't negate this.
Building DMD on SmartOS
Hello, I would like to use D on SmartOS. Since there is no binary installer I tried to build DMD from source by following the instructions on this page; http://wiki.dlang.org/Building_DMD Unfortunately I get this error; [~/d/dmd/src]# make -f posix.mak MODEL=64 no cpu specified, assuming X86 dmd idgen.d make: dmd: Command not found posix.mak:320: recipe for target 'idgen' failed make: *** [idgen] Error 127 Thanks!
Re: if(arr) now a warning
On 4/30/15 9:50 AM, Daniel Murphy wrote: Andrei Alexandrescu wrote in message news:mhtggg$26b5$1...@digitalmars.com... I think we need to stop here. I'll make the PR today for reverting this language change. We can't handle D like a semester science project, because for as long as we do we won't have credibility. This trickle of teeny-bit breaking changes for the sake of touted benefits must stop. This breaking change prevents hard-to-find bugs. The fact that you needed to make trivial changes to 39 places in std.allocator doesn't negate this. Nothing negates that. It's a judgment call. Please let's stop here. Thanks. -- Andrei
Re: if(arr) now a warning
On 4/30/15 10:10 AM, Jeremy Powers via Digitalmars-d wrote: On Thu, Apr 30, 2015 at 8:08 AM, Andrei Alexandrescu via Digitalmars-d digitalmars-d@puremagic.com mailto:digitalmars-d@puremagic.com wrote: This trickle of teeny-bit breaking changes for the sake of touted benefits must stop. This is how you improve the language. No. -- Andrei
[Issue 14534] New: Front-end should lower all non-scalar condition expressions
https://issues.dlang.org/show_bug.cgi?id=14534 Issue ID: 14534 Summary: Front-end should lower all non-scalar condition expressions Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: DMD Assignee: nob...@puremagic.com Reporter: ibuc...@gdcproject.org Types in D2 that have a non-scalar representation, this involves: - Dynamic arrays { size_t length, void *ptr } - Delegates { void *object, void *funcptr } - Associative arrays { void *ptr } Are silently allowed to pass through the front-end in checkToBoolean checks as valid boolean values. This means that type-strict backends (GDC, LDC) must do it's own special lowering to ensure that the correct value is extracted and proper scalar - bool conversion is done. This also means that dmd, gdc, and ldc may be each doing something different when it comes to the following operations. --- if (arr) { ... } // Could be (arr.ptr != null) or (arr.ptr || arr.length) if (dg) { ... } // Could be (dg.funcptr != null) or (dg.object || dg.funcptr) if (aa) { ... } // arr.ptr != null --- So I propose that the front-end should instead do this lowering so the behaviour is 'precisely defined' and not up for interpretation of the backend implementer. --
Re: if(arr) now a warning
On Thursday, 30 April 2015 at 11:43:06 UTC, Kagamin wrote: On Thursday, 30 April 2015 at 02:51:33 UTC, Vladimir Panteleev wrote: OK, I'm tired of hearing this argument. Distinction between null and empty can be done, the problem is it doesn't fly in mainstream. if (myslice is []) would wheck for null slice.
Re: if(arr) now a warning
On Thursday, 30 April 2015 at 18:04:18 UTC, Vladimir Panteleev wrote: On Thursday, 30 April 2015 at 17:10:23 UTC, Jeremy Powers wrote: On Thu, Apr 30, 2015 at 8:08 AM, Andrei Alexandrescu via Digitalmars-d digitalmars-d@puremagic.com wrote: This trickle of teeny-bit breaking changes for the sake of touted benefits must stop. This is how you improve the language. Only if you ignore the costs of the change... This one is quite straightforward. Dfix could probably handle it.
rdmd renames directories if they share the same name as an output file, what to do?
In the following bug report it's highlighted that rdmd renames directories if they share the same name as the output file. https://issues.dlang.org/show_bug.cgi?id=13758 Is there a consensus of opinion on what rdmd should do in this situation? i.e. should it raise an error and fail? Should there be a switch to enable this behaviour? Personally I think it *should* fail and report the name clash. The switch should not implemented.
Re: Building DMD on SmartOS
On Thursday, 30 April 2015 at 17:54:00 UTC, Joakim wrote: compiling that on SmartOS with just a C++ compiler. Of course, the Solaris support in dmd/druntime/phobos is not really tested, so you may need to fill in some gaps for SmartOS. I compiled dmd on OpenIndiana (Illumos based like SmartOS). The main issue was that binutils = 2.20 were required otherwise the compiled application did not run. Of course, ldc runs on Solaris, too. Regards, Kai
Re: ARM Cortex-M Microcontroller startup files
On 04/30/2015 08:43 AM, Timo Sintonen wrote: Printf is a little tricky. It is actually a file operation to stdout and that is actually a syscall to kernel. No, you usually have to implement some hook for outputting yourself, e.g. putc or write, printf solely takes care of the formatting.
[Issue 14528] GIT HEAD: can't pass protected member to template by alias
https://issues.dlang.org/show_bug.cgi?id=14528 Martin Nowak c...@dawg.eu changed: What|Removed |Added CC||c...@dawg.eu --- Comment #1 from Martin Nowak c...@dawg.eu --- Also see issue 12856. --
Destruction in D
After reading GC page in the reference, it seems that class destructors are called on a separate thread, in parallel to the main thread. Is this correct? What about structs? Are the destructors called when they go out of scope in a C++ RAII fashion, or do they happen on a separate thread too? I'm asking because one of the advantages listed for using a GC was something about not having to set up a special stack frame for destructors. I don't fully understand that point, but it seems like it would be incorrect if D structs destructed at end of scope.
Re: rdmd renames directories if they share the same name as an output file, what to do?
On Thursday, 30 April 2015 at 18:09:29 UTC, Gary Willoughby wrote: In the following bug report it's highlighted that rdmd renames directories if they share the same name as the output file. https://issues.dlang.org/show_bug.cgi?id=13758 Is there a consensus of opinion on what rdmd should do in this situation? i.e. should it raise an error and fail? Should there be a switch to enable this behaviour? Personally I think it *should* fail and report the name clash. The switch should not implemented. Agreed. It should just fail.
Re: ARM Cortex-M Microcontroller startup files
On Thursday, 30 April 2015 at 20:54:07 UTC, Martin Nowak wrote: On 04/30/2015 08:43 AM, Timo Sintonen wrote: Printf is a little tricky. It is actually a file operation to stdout and that is actually a syscall to kernel. No, you usually have to implement some hook for outputting yourself, e.g. putc or write, printf solely takes care of the formatting. My knowledge isn't really deep here, but doesn't printf call vfprintf(stdout, ...) and vfprintf call vsnprintf followed by fwrite, etc. ? Thus I would expect the hook to be somewhere in vfprintf ?
Capacity is first-come first served for multiple slices to all elements
(Thanks to Luís Marques for waking me up.) Although it makes sense now, somehow some parts of this story is news to me after all these years. :-/ When there are multiple slices to all elements of an array, they all start with same capacity until an element is added to one of them. After that, all the other slices get zero capacity: import std.stdio; void report(alias arr)() { writefln(%s - capacity: %s, %s, arr.stringof, arr.capacity, arr); } void main() { // Multiple slices to all elements auto a0 = [ 1, 2, 3, 4 ]; auto a1 = a0; auto a2 = a0; void reportAll() { report!a0; report!a1; report!a2; } reportAll(); a1 ~= 42;// -- After this, only a1 will have capacity reportAll(); } The output shows that a0 an a2 lose capacity: a0 - capacity: 7, [1, 2, 3, 4] a1 - capacity: 7, [1, 2, 3, 4] a2 - capacity: 7, [1, 2, 3, 4] a0 - capacity: 0, [1, 2, 3, 4] a1 - capacity: 7, [1, 2, 3, 4, 42] a2 - capacity: 0, [1, 2, 3, 4] Although I've known about the perceived non-determinism[1] about all this, what is still especially surprising to me is that passing a slice to a function can make the original slice lose capacity: import std.stdio; void foo(int[] arr) { arr ~= 42; } void main() { auto arr = [ 1, 2 ]; writefln(Before calling foo(): %s, arr.capacity); foo(arr); writefln(After calling foo() : %s, arr.capacity); } The output shows that the original variable in main() loses capacity: Before calling foo(): 3 After calling foo() : 0 Ali [1] http://dlang.org/d-array-article.html
Re: ARM Cortex-M Microcontroller startup files
On 04/30/2015 01:30 PM, Mike wrote: While this may seem simple to achieve, I think it will raise a few questions that will need answering. * Can ModuleInfo be leveraged, without introducing overhead, to call module constructors and static constructors? They might be useful for hardware initialization. Currently D sorts modules by initialization order,which requires every moduleinfo to contain an array of imported modules. Quite a lot of RAM for a nice to have feature, so we should drop it or at least provide a -fno-moduleinfo switch. * Is dynamic memory allocation a requirement of D, or a library feature? Definitely a library feature, though many language features, like array appending, won't work without it (delegate closures won't even work without a GC). * Does D need the C runtime, or can it init on its own? It shouldn't need a C runtime. * Should the C standard library bindings be part of the runtime, or exist as an external Deimos library? Either way they can still be used by the runtime, I'm just suggesting that they should be encapsulated. It doesn't cost you anything to include the bindings in a release, they could be maintained in a separate project if that helps. * What will be done about TypeInfo for now? It's causing me some serious code-bloat problems. See http://forum.dlang.org/post/quemhwpgijwmqtpxu...@forum.dlang.org Implement a -fno-rtti switch for GDC. * Is data and bss initialization part of the runtime, or delegated to toolchain, silicon, and BSP vendors? We should provide appropriate linker scripts and do the initialization.
Re: Destruction in D
On Thursday, 30 April 2015 at 20:07:11 UTC, bitwise wrote: destructors are called on a separate thread, in parallel to the main thread. Is this correct? Not necessarily. the way the GC works in D today is whenever any thread allocates, it runs the GC functions which might do a collection. This is where the destructors run, too. So a destructor may be run by whatever random thread happened to run out of memory and triggered the collection cycle. What about structs? Are the destructors called when they go out of scope in a C++ RAII fashion, or do they happen on a separate thread too? structs work basically the same as C++, yes. I don't know about your third thing...
[Issue 14535] New: std.net.curl.CurlException should include status line
https://issues.dlang.org/show_bug.cgi?id=14535 Issue ID: 14535 Summary: std.net.curl.CurlException should include status line Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: Phobos Assignee: nob...@puremagic.com Reporter: briancsch...@gmail.com The high-level curl functions such as get, put, and post throw CurlException when they fail. This exception does not include the status line, so the exception only contains information about the status code, such as request returned status code 500. Including the status line in the exception would allow clients to provide more helpful error messages to users. --
Re: ARM Cortex-M Microcontroller startup files
On Thursday, 30 April 2015 at 06:43:18 UTC, Timo Sintonen wrote: {snip} I think it is possible to make a minimum bare metal runtime from scratch. {snip} Yes I think it won't be too difficult. All are good points that we should have in mind, while deciding on how we proceed. -Also Mike's input is valuable. I agree with both of you. Mike, Timo, Martin and Johannes: Here's what I planned a few week ago ... 1: Get the toolchain working for Cortex-M0, Cortex-M3 and Cortex-M4. (Done, thanks to you). 2: Create a bunch of startup files for different devices as an appetizer. (Done, but ongoing) 3: Create a linker-script suitable for the casual MCU programmer. (Almost done) 4: Create a simple Makefile as an example. (Pending) 5: Create a set of files, which can be shared across all MCUs (for instance containing the *int*_t) types. This could later grow to a bare-metal druntime. (Pending) 6: Create a couple of driver files for one of the STM32 microcontrollers. (Pending) 7: Create a complete example project, similar to those already written in C, which demonstrates that it can be done completely in D. ... 10: Present this to Reinhard Keil, as the ARM Keil tools now use LLVM. I am sure Reinhard will find the D language intriguing. But as he is very busy, I would like to wait until I have a fully functioning example, which shows that D is now ready for microcontrollers. If step 10 is done too early, it might not be as appealing as if we have a working demo. Mike, Timo and I all have different approaches and needs. We can definitely use this to our benefit. D)iversity is great. =D I have the impression that Martin seems to have a good overview and also knowledge about different MCUs.
anonymous template predicates
I was wondering if there's a mechanism to make anonymous templates, e.g. given: enum Policy {A, B} alias List = TypeTuple!(...); instead of this: enum has_policy_A (T) = T.policy == Policy.A; alias Result = Filter!(has_policy_A, List); use something like this: Filter!(T = T.policy == Policy.A, List); I've tried templates that generate eponymous predicates from mixed-in strings but these have a number of caveats that limit their usability.
Re: Destruction in D
On Thursday, 30 April 2015 at 20:07:11 UTC, bitwise wrote: After reading GC page in the reference, it seems that class destructors are called on a separate thread, in parallel to the main thread. Is this correct? There's no guarantee what thread will be used in the standard GC implementation AFAIK. What about structs? Are the destructors called when they go out of scope in a C++ RAII fashion, or do they happen on a separate thread too? If they're on the stack(not allocated with `new`), then they have their destructor called upon leaving scope ala C++ RAII, otherwise see above.
Re: if(arr) now a warning
What about less intrusive change as a compromise? I'm the C# guy and they solve these problems just with warnings. Each warning has some ID and compiler spits it out with the description of a problem itself. Developers than have 4 ways to handle it: 1) ignore it and live with the warning 2) change the code to be correct 3) disable this exact warning type for a whole project 4) disable this exact warning in source file at the place of the warning itself I think that similar approach would be helpful here. Say we have an Andrei's allocator code which he knows that is correct. But spits out a lot of false positive warnings. So at the module header he just adds something like: pragma(disablewarn, 123); and don't care about it further. So personally I wouldn't necessarily deprecate current behaviour with actual codebreak, but just spit out warning about possible error which can be easily taken care of and still can be pretty useful to find possible bugs. Actually that should be major usage for warnings - notify developer that something is potentially wrong. More about C# pragmas for warning handling: https://msdn.microsoft.com/en-us/library/441722ys.aspx
[Issue 12856] template alias should not perform access check
https://issues.dlang.org/show_bug.cgi?id=12856 Martin Nowak c...@dawg.eu changed: What|Removed |Added CC||deadal...@gmail.com --- Comment #1 from Martin Nowak c...@dawg.eu --- *** Issue 13744 has been marked as a duplicate of this issue. *** --
[Issue 13744] Cannot pass private symbol as alias parameter
https://issues.dlang.org/show_bug.cgi?id=13744 Martin Nowak c...@dawg.eu changed: What|Removed |Added Status|NEW |RESOLVED CC||c...@dawg.eu Resolution|--- |DUPLICATE --- Comment #3 from Martin Nowak c...@dawg.eu --- *** This issue has been marked as a duplicate of issue 12856 *** --
Re: array operations and ranges
On 4/26/2015 3:17 AM, Manu via Digitalmars-d wrote: Array operations are super cool, and I'm using ranges (which kinda look and feel like arrays) more and more these days, but I can't help but feel like their incompatibility with the standard array operations is a massive loss. Let's say I want to assign one range to another: b[] = a[]; It's not clear to me why this should fall down if I want to apply a lazy operation for instance: b[] = a.map!(e=e*2)[]; ... or something to that effect. I find that my lazy ranges often end up on the stack, but I can't assign/initialise directly: float[] a = b.transform[]; Instead I need to: float[] a; b.transform.copy(a[]); The fact that they don't mix with array expressions or operators means as soon as a lazy range finds it wants to enter existing array code, it needs to be converted to a series of map()'s. There must be years of thoughts and work on this sort of thing? It seems arrays and ranges are unnecessarily distanced from eachother... what are the reasons for this? I think you've got the start of some dazz ideas. I want to think about this more.
Re: if(arr) now a warning
On Fri, 01 May 2015 11:12:12 +1000, Daniel Murphy wrote: Andrei Alexandrescu wrote in message news:mhto1k$2dk0$1...@digitalmars.com... Nothing negates that. It's a judgment call. Please let's stop here. Thanks. -- Andrei Please stop trying to undo this improvement. Just fix your code and move on. Thanks. D is not C++ enough, it needs more legacy warts. after all, the only thing that shows language maturity is how much legacy it accumulated. signature.asc Description: PGP signature
[Issue 13758] RDMD renames directory if -ofNAME is the name of a directory
https://issues.dlang.org/show_bug.cgi?id=13758 Vladimir Panteleev thecybersha...@gmail.com changed: What|Removed |Added Keywords||pull CC||thecybersha...@gmail.com --- Comment #2 from Vladimir Panteleev thecybersha...@gmail.com --- https://github.com/D-Programming-Language/tools/pull/167 (In reply to Andrej Mitrovic from comment #0) I don't think RDMD should have the power to move things around like that. It should fail compilation if the output name would overwrite the directory, with optionally providing a special switch for when you really need this behavior (I don't see the point of the feature though..). I added the renaming thing to work around Windows locking executable files that are still running. I just hadn't thought that on Posix executable don't have an extension, and writing the executable file might happen because the output file is actually a directory. --
Re: if(arr) now a warning
On Friday, 1 May 2015 at 02:16:01 UTC, deadalnix wrote: On Friday, 1 May 2015 at 01:12:08 UTC, Daniel Murphy wrote: Andrei Alexandrescu wrote in message news:mhto1k$2dk0$1...@digitalmars.com... Nothing negates that. It's a judgment call. Please let's stop here. Thanks. -- Andrei Please stop trying to undo this improvement. Just fix your code and move on. Thanks. There is probably a better way to introduce the change, that would facilitate the transition but I agree with the feeling. std.alocator is probably one of the only piece of code where this behavior is justified. I guess my earlier post got buried? http://forum.dlang.org/post/ajrysqkjmlqjlmkip...@forum.dlang.org
Re: if(arr) now a warning
On Thursday, 30 April 2015 at 18:07:12 UTC, deadalnix wrote: This one is quite straightforward. Dfix could probably handle it. I'd have to rewrite dfix on top of SDC to get this working. dfix can only work at the lexical and AST level at the moment. As soon as you need information like Is this a dynamic array? you need a compiler. I could try using DCD's suhmantick analisyss[1] code to try to get this to work, but it wouldn't work correctly in a lot of cases. [1] it's really dumb, but works well enough for an auto-complete engine
[Issue 14534] Front-end should lower all non-scalar condition expressions
https://issues.dlang.org/show_bug.cgi?id=14534 Walter Bright bugzi...@digitalmars.com changed: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #1 from Walter Bright bugzi...@digitalmars.com --- I don't think this is an enhancement - it's a bug fix. All the compilers must do the same thing. --
Re: Destruction in D
On Thu, 30 Apr 2015 16:17:10 -0400, Adam D. Ruppe destructiona...@gmail.com wrote: On Thursday, 30 April 2015 at 20:07:11 UTC, bitwise wrote: destructors are called on a separate thread, in parallel to the main thread. Is this correct? Not necessarily. the way the GC works in D today is whenever any thread allocates, it runs the GC functions which might do a collection. This is where the destructors run, too. So a destructor may be run by whatever random thread happened to run out of memory and triggered the collection cycle. What about structs? Are the destructors called when they go out of scope in a C++ RAII fashion, or do they happen on a separate thread too? structs work basically the same as C++, yes. I don't know about your third thing... Well, the third thing was just my reasoning for asking in the first place. I need to be able to acquire/release shared resources reliably, like an OpenGL texture, for example. Come to think of of though, I haven't thought this issue through with regard to multi-threaded rendering, so I guess I'll have to think of something more clever than a ref-counted texture.. Thanks Bitwise
Re: Destruction in D
On Thursday, 30 April 2015 at 23:27:49 UTC, bitwise wrote: Well, the third thing was just my reasoning for asking in the first place. I need to be able to acquire/release shared resources reliably, like an OpenGL texture, for example. If you want to release resources, you are going to have to call some functions that do that for you, so you can't escape that special stack frame(what's so special about it?) - though the compiler might inline it. When you use a GC the compiler don't need to invoke the destructor in the end of the scope because the object is destroyed in the background, but that also means you can't rely on it to release your resources, so languages like Java and C# use try-with-resources and using statements(corresponding) to call something at the end of the scope and end up using that stack frame anyways.
Re: Capacity is first-come first served for multiple slices to all elements
On Thursday, April 30, 2015 11:59:00 Ali Çehreli via Digitalmars-d-learn wrote: (Thanks to Luís Marques for waking me up.) Although it makes sense now, somehow some parts of this story is news to me after all these years. :-/ When there are multiple slices to all elements of an array, they all start with same capacity until an element is added to one of them. After that, all the other slices get zero capacity: LOL. This is the sort of thing that's pretty straightforward when you think through how arrays work, but it seems like so few people understand it. You'd _think_ that array slicing its associated semantics wouldn't be all that hard to understand, but it seems like it trips most of us up from time to time, and pretty much everyone has trouble with them initially. I expect that part of the problem is simply the fact that it's all hidden behind T[] rather than actually seeing something like struct Array(T) { size_t length; T* ptr; } when you're coding, since that alone makes a lot of the basic array semantics a lot more clear, and even if the capacity situation isn't clear at that point, at least it's clear that it's not actually part of the array itself, which makes some of semantics that one might expect with something like a vector clearly not work. I'm definitely going to have to cover some of the array basics in my talk on ranges at dconf, simply because of how much they affect ranges and how often they're misunderstand. And I _still_ occasionally end up Aha! moments occasionally when dealing with this stuff... - Jonathan M Davis
Re: dub -vgc
On Thursday, 30 April 2015 at 12:14:39 UTC, Robert M. Münch wrote: How can I make use of the -vgc compiler switch in my DUB project? Does dflags work ? http://code.dlang.org/package-format
Re: if(arr) now a warning
Andrei Alexandrescu wrote in message news:mhto1k$2dk0$1...@digitalmars.com... Nothing negates that. It's a judgment call. Please let's stop here. Thanks. -- Andrei Please stop trying to undo this improvement. Just fix your code and move on. Thanks.
[Issue 14534] Front-end should lower all non-scalar condition expressions
https://issues.dlang.org/show_bug.cgi?id=14534 yebblies yebbl...@gmail.com changed: What|Removed |Added CC||yebbl...@gmail.com --- Comment #2 from yebblies yebbl...@gmail.com --- The way to make this precisely defined is to put it in the spec and test suite, not to move the lowering into the frontend. Lowering early is not without downsides. --
Re: if(arr) now a warning
On Friday, 1 May 2015 at 01:12:08 UTC, Daniel Murphy wrote: Andrei Alexandrescu wrote in message news:mhto1k$2dk0$1...@digitalmars.com... Nothing negates that. It's a judgment call. Please let's stop here. Thanks. -- Andrei Please stop trying to undo this improvement. Just fix your code and move on. Thanks. There is probably a better way to introduce the change, that would facilitate the transition but I agree with the feeling. std.alocator is probably one of the only piece of code where this behavior is justified.
Re: if(arr) now a warning
On Thu, 30 Apr 2015 20:27:01 +, TC wrote: pragma(disablewarn, 123); please, no! nothing in source code should be able to disable warning -- except fixing the code. and such pragma simply ugly. signature.asc Description: PGP signature
Re: Quit running foreign unittests _
On 04/28/2015 07:04 PM, Dicebot wrote: I do want do test everything as part of my app tests, including all possible dependencies, transitively. Even Phobos? This is awesome default. With a simple `rdmd -main -unittest` call I can ensure that certain app/module works correctly without having to trust maintainers of dependencies to run tests regularly and without even knowing what those dependencies are. It is beautiful in its simplicity which makes it good default.
Re: ARM Cortex-M Microcontroller startup files
Martin, This is a bit of a tangent, but I would like to know what your thoughts are on this: http://forum.dlang.org/post/psssnzurlzeqeneag...@forum.dlang.org The problem is that when we use an unimplemented feature of D, the best we can hope for is to generate a linker error. I proposed this idea as a way to make the conversation between the user and their druntime implementation more polished. The runtime implementation, through its .di files informs the compiler and user what is and isn't supported so the user can get friendly compile-time errors and the compiler can make better assumptions about codegen. Mike
How to reuse functions
Hi everybody. I am tring to use a function where its parameter is another function, and at the same time are both already made - they cannot be modified - and the second one has to be conditioned before to be passed as argument. Let's say I have these function and I cannot modify: -jac(+d) that works on function and return real real jac(real function(real) fun, real x) {return d(fun, x);} real d(real function(real) fun, real x) {return fun(x);} -F1 that works on two reals and return real real F1(real a, real b) {return a + b;} So I need a way to condition F1 fixing b and then pass it to jac as argument. To do that I've created a delegate 'simp' conditionig F1: real delegate(real) simp(real function(real, real) f, real x) { real _simp(real z) { return f(z, x); } return _simp; } (here 'simp' fixes b at x). My main is: void main() { real x_n = 1; real x_m = -1; real delegate(real) s_n = simp(F1, x_n); //auto J = jac(s_n, x_m); //Error: function app.jac (real function(real) fun, real x) is not callable using argument types (real delegate(real), real) } the code fails because jac expect as argument a function but I found only a delegate to obtain a simplified function without any touch at already made functions jac, d and F1. There is a clean way to make it possible? I mean: without to touch (neither rewrite) jac, d and F1, obtain simplied F1 to pass to jac. Thaks in advance to anyone could help me. Luigi
Re: ARM Cortex-M Microcontroller startup files
On Thursday, 30 April 2015 at 21:08:22 UTC, Jens Bauer wrote: On Thursday, 30 April 2015 at 20:54:07 UTC, Martin Nowak wrote: On 04/30/2015 08:43 AM, Timo Sintonen wrote: Printf is a little tricky. It is actually a file operation to stdout and that is actually a syscall to kernel. No, you usually have to implement some hook for outputting yourself, e.g. putc or write, printf solely takes care of the formatting. My knowledge isn't really deep here, but doesn't printf call vfprintf(stdout, ...) and vfprintf call vsnprintf followed by fwrite, etc. ? Thus I would expect the hook to be somewhere in vfprintf ? As Timo said, eventually, what printf needs is the `write` syscall. The C library needs to be ported to the hardware in question. That requires implementing all the syscalls the the C library needs: `write` for printf, `sbrk` for malloc, etc... (http://wiki.osdev.org/Porting_Newlib#newlib.2Flibc.2Fsys.2Fmyos.2Fsyscalls.c) Sometimes the toolchain vendors provide this, sometimes the programmer has to do it. IMO, C library bindings are quite useful, and an important part of the microcontroller ecosystem, but I don't think it should be a prerequisite for druntime. I recommend keeping it as a separate project in Deimos, and leave it to the programmer to implement the syscalls if they choose to employ it. Mike
Re: Example from d-idioms is incorrect
On Thursday, 30 April 2015 at 21:30:36 UTC, TheGag96 wrote: I was looking at the d-idioms website today and saw this code example: http://p0nce.github.io/d-idioms/#Adding-or-removing-an-element-from-arrays And I was kind of irked. I just recently working with removing an element from an array in a small project I worked on two weeks ago, and I had to learn the hard way that to properly remove an element from an array in the way this example describes, you have to do array.length--; as well. This code: import std.stdio, std.algorithm; void main() { int[] arr; //ensuring it's dynamic arr ~= 1; arr ~= 5; arr ~= 10; arr.remove(1); writeln(arr); writeln(arr == [1, 10]); arr.length--; writeln(arr); writeln(arr == [1, 10]); } produces this output: [1, 10, 10] false [1, 10] true Compiled and ran on Windows, dmd v2.067.0. Unless I'm totally missing something here, that website is giving some pretty wrong information... Was the behavior of the remove() function changed recently? Thanks guys. http://dpaste.dzfl.pl/007a9319371d Application output: [1, 10] true [1] false
[Issue 14519] [Enh] foreach on strings should return replacementDchar rather than throwing
https://issues.dlang.org/show_bug.cgi?id=14519 Martin Nowak c...@dawg.eu changed: What|Removed |Added CC||c...@dawg.eu --- Comment #23 from Martin Nowak c...@dawg.eu --- (In reply to Vladimir Panteleev from comment #20) (In reply to Marc Schütz from comment #18) Data with other (or unknown) encodings needs to be stored in `ubyte[]`. Have you tried using ubyte[] to process ASCII text? It's horrible, you have to cast at every step, and nothing in std.string works even when it should. No one is suggesting you operate on ubyte[] as string. What people are is saying is you should validate a ubyte[] array before converting it to a string. This is by the way how readText works. You'll have to cast raw data to string to get strings with invalid UTF. --
[Issue 14519] [Enh] foreach on strings should return replacementDchar rather than throwing
https://issues.dlang.org/show_bug.cgi?id=14519 --- Comment #24 from Martin Nowak c...@dawg.eu --- If we validate encoding on data entry points such as readText or byLine, then decoding errors should be assertions rather than silent replacements, because it's a programming error to use unvalidated data as string. --
depend 0.0.1
https://github.com/funkwerk/depend depend checks actual import dependencies against a PlantUML model of target dependencies. In contrast to dhier, depend makes use of the import dependencies created by dmd with the --deps switch. In our company, we use this tool with CI to guard the development against unintended dependencies.
Re: if(arr) now a warning
On Thursday, 30 April 2015 at 21:58:17 UTC, Brian Schott wrote: On Thursday, 30 April 2015 at 18:07:12 UTC, deadalnix wrote: This one is quite straightforward. Dfix could probably handle it. I'd have to rewrite dfix on top of SDC to get this working. dfix can only work at the lexical and AST level at the moment. As soon as you need information like Is this a dynamic array? you need a compiler. I could try using DCD's suhmantick analisyss[1] code to try to get this to work, but it wouldn't work correctly in a lot of cases. [1] it's really dumb, but works well enough for an auto-complete engine I'm sure that with suhmantick analisyss one can get a good cunk of the tests (not all, but something large enough). This paired with making the thing a warning rather than an error, should provide an easy transition path.
Re: if(arr) now a warning
On Thursday, 30 April 2015 at 15:08:00 UTC, Andrei Alexandrescu wrote: On 4/30/15 4:46 AM, Daniel Murphy wrote: Vladimir Panteleev wrote in message news:ajrysqkjmlqjlmkip...@forum.dlang.org... On Wednesday, 29 April 2015 at 19:15:46 UTC, Jonathan M Davis wrote: but std.allocator is definitely not your average code OK, I'm tired of hearing this argument. It's valid though. I think we need to stop here. I'll make the PR today for reverting this language change. We can't handle D like a semester science project, because for as long as we do we won't have credibility. This trickle of teeny-bit breaking changes for the sake of touted benefits must stop. In the future please do not make breaking changes without my and Walter's approval. Thanks, Andrei OK so, please revert this one: https://github.com/D-Programming-Language/dmd/commit/2869ee9c1fb64f08b51d8d07ce72701dda4a6fae and this one: http://forum.dlang.org/thread/ibupwrwsgjvrjwabh...@forum.dlang.org
[Issue 14079] Variable templates' documentation not generated.
https://issues.dlang.org/show_bug.cgi?id=14079 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --
Re: ARM Cortex-M Microcontroller startup files
On Thursday, 30 April 2015 at 23:03:48 UTC, Mike wrote: On Thursday, 30 April 2015 at 20:45:28 UTC, Martin Nowak wrote: * Is data and bss initialization part of the runtime, or delegated to toolchain, silicon, and BSP vendors? We should provide appropriate linker scripts and do the initialization. The linker script can give the location of the data and bss segments. My question is really about whether or not the druntime implementation should assume responsibility for loading the data segment from flash and zeroing bss. I suppose that should be left to the vendor's BSP, not part of druntime itself. How about providing functions for copying data and zeroing bss ? -In my startup file, I use functions for that, because they're optimized pretty well. The code is very similar to my optimized #define in C. Most Cortex-M microcontrollers allow you to set the clock frequency. It's a good idea to do this before you start copying a large block of data, because that means the startup time is quicker. The drawback is that ... CMSIS wants to write in the BSS (the CoreClockFrequency variable, for instance), and that's just erased when BSS is cleared - I wish they had just reserved a hardware register for these 4 variables. Anyway, personally, I like the startup file to contain the data/bss init, because I might want to customize it. My startup files allow you to override Reset_Handler and each exception, which means you don't even have to modify the startup file. That means one less template-file to copy to every project. I guess what I'm trying to articulate is that currently when you download an MCU toolchain, it contains a collection of things from many different vendors (GCC, binutils, newlib, startup files, linker scripts, multilibs, etc...), all in one package. I recommend, not doing that with this druntime. druntime should just be the implementation of D language features for microcontrollers. Agree. Once a minimal druntime is created, some other effort can take that druntime and package it with a compiler, linker, startup files, linker scripts, c standard library, debugger, flash programmer, etc... and make a convenient downloadable/installable package for immediate use. Agree. Linker-scripts can usually be written so they work well with multiple devices from the same vendor. I'm not talking about specific RAM and Flash settings, but the main body of the linker script. Small 3 .. 8 line scripts can then include the body, which provides all the standard stuff. So here I'm talking about a body linker-script could be provided for each vendor (not each device family or each device). If each device family or device requires different attention, then I suggest something like Vendor:DeviceFamily:DeviceSpecific. Thus it would not be overwhelming writing one linker script per vendor and it would be fairly straight-forward for the casual user to add a new device or even a device family if needed. I'd also prefer having the linker-script in a location, outside each project (because I have many projects and I hate duplicates and updating each duplicate each time I find something that needs to be changed). Assuming that is an appropriate strategy, what does the first druntime release look like. * For example: What will `assert` do? Is that just a stub to be implemented by the programmer? Most asserts on microcontrollers I've seen are just implemented as while(1){} -But one could probably also trigger the debugger (BKPT), HardFault or RESET if necessary. Perhaps the default could be while(1){} and then version(ASSERT_BKPT) could be used to add a breakpoint before that while(1){}. Thus --version=ASSERT_BKPT could be specified on the command-line. Would it be possible to 'extend' an existing assert; eg. the user might want to be notified via the U(S)ART ?