[Issue 17766] New: Wrong choice of generic mutable/const/immutable methods
https://issues.dlang.org/show_bug.cgi?id=17766 Issue ID: 17766 Summary: Wrong choice of generic mutable/const/immutable methods Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: ilyayaroshe...@gmail.com static struct Foo() { char opIndex(Indexes...)(Indexes indexes) immutable { return 'i'; } char opIndex()() const { return 'c'; } char opIndex(Indexes...)(Indexes indexes) { return 'm'; } } pragma(msg, Foo!()()[]); pragma(msg, (cast(const) Foo!()())[]); pragma(msg, (cast(immutable) Foo!()())[]); Prints 'c' 'c' 'c' But shuold be 'm' 'c' 'i' Type qualifier should have priority. --
Re: real simple delegate question.
On Saturday, 19 August 2017 at 18:33:37 UTC, WhatMeWorry wrote: Or maybe another approach would be to ask, what type is the compiler replacing auto with. If you want to find out compile with `-vcg-ast`
Re: @safe(bool)
On Sunday, 20 August 2017 at 02:53:14 UTC, jmh530 wrote: On Sunday, 20 August 2017 at 00:55:41 UTC, Nicholas Wilson wrote: Sorry, I was referring to preconfigurations in druntime like https://github.com/dlang/DIPs/pull/89/files#diff-26bf588c0174e6cd0fe3d4af615bebdaL60 So modifying core.attribute.defaultAttributeSet in the runtime is the only way to change the default attribute set, Yes, whether that be a custom runtime or through version conditions that define core.attribute.defaultAttributeSet. but one could create a custom attribute that they just use as needed. So one could just look at the top of the file to see if the code has something like @myDefaultAttributeSet. Yes. Hopefully a bit more descriptive though ;)
Re: @safe(bool)
On Sunday, 20 August 2017 at 00:55:41 UTC, Nicholas Wilson wrote: Sorry, I was referring to preconfigurations in druntime like https://github.com/dlang/DIPs/pull/89/files#diff-26bf588c0174e6cd0fe3d4af615bebdaL60 So modifying core.attribute.defaultAttributeSet in the runtime is the only way to change the default attribute set, but one could create a custom attribute that they just use as needed. So one could just look at the top of the file to see if the code has something like @myDefaultAttributeSet.
Re: Quora
On Saturday, August 19, 2017 15:17:52 Ecstatic Coder via Digitalmars-d wrote: > > Its called necro-posting. > > I'm surprised that post isn't read-only. > > Call it like you want, but I ee people putting new > answers/comments to years old posts all the times, as it's > perfectly legitimate on many blogs and websites. > > What was the best answer 10 years ago is often completely wrong > nowadays. > > Forbidding people to suggest what can easily solve the problem > *right now* is what would be silly IMHO. IIRC, there's even a badge for necro-posting. I don't think that I've ever done it though. If I answer a question, it's generally because I specifically went to SO to answer questions, in which case, I'm just looking at the latest ones. I haven't been doing even that much lately though, and answering D questions is pretty much the only reason that I've done much with SO in years. I've rarely found it to be useful for asking the sorts of questions that I have - if nothing else, because anything easy enough to find the answer for by digging around online, I'll find, and anything that's harder is likely to be esoteric enough that no one's going to have the answer for you on SO. As far as old posts being wrong goes though, it wouldn't surprise me if several of the older answers for D are wrong at this point - or at least could and should be improved - given how much the language and libraries have changed over time. - Jonathan M Davis
Re: @safe(bool)
On Sunday, 20 August 2017 at 01:05:39 UTC, bitwise wrote: This is indeed, a nice solution. I am a _bit_ worried about abuse, and loss of modularity, but aside from that, I think it's a better solution overall. All features in the style of "I know what I'm doing, just let me do it!" (=void, @trusted ect.) are open to abuse but I don't think we've ever had problems with them. They tend to be used sparingly and only when absolutely necessary. I'm not quite sure how this would lead to a loss of modularity? The only downside is that the second form leaves itself open to Easily fixed with a template constraint, right? True, too early in the morning. zzz. This could potentially render a large portion of the projects on code.dlang.org broken though. What would be nice, is if code.dlang.org regularly built all the projects, and notified the authors of the breakage, possibly sending a list of recent compiler changes as well. I don' think It would break too much, but we have @future to mitigate all potential breakages from this DIP. Autotesting is obviously desirable.
Re: jai-like CTFE string formating
On Sunday, 13 August 2017 at 19:51:31 UTC, Stefan Koch wrote: On Sunday, 13 August 2017 at 19:47:37 UTC, Jerry wrote: Seems like it'd be a good idea to pre compute all of phobos for compile time computations, as they should be changing. That would drastically reduce using any of phobos for compile time computation. You cannot do that. The point of template code is that the user can change it from the outside. There is no way to precompute the reaction to things that are yet to be realized. The way compile time is saved here is by limiting the flexibility. There are ways to do it, not having to parse the code would make it faster on its own. Compiling 500 source files individually that starts and stops DMD is drastically slower than putting the 500 source files together and running DMD once. The tests that are run for DMD for example could be made to run much faster.
Re: void init of out variables
On Saturday, 19 August 2017 at 23:05:26 UTC, Walter Bright wrote: On 8/18/2017 11:24 PM, Nicholas Wilson wrote: Hmm, I could, but ref doesn't signal intention like out does. True. Please file an enhancement request. https://issues.dlang.org/show_bug.cgi?id=17765 I also realised that ref won't error on reads from the parameter, whereas out does.
[Issue 17765] New: void initialisation of out parameters
https://issues.dlang.org/show_bug.cgi?id=17765 Issue ID: 17765 Summary: void initialisation of out parameters Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: iamthewilsona...@hotmail.com Out variables are always initialised, but when they are large static arrays this incurs a performance penalty. For declaration of regular variables we have = void to stop default initialisation. This does not work for out variables. This ER suggests to make `i` valid syntax to suppress initialisation of the out variable. enum M = 2600; void f() { float[M] mean = void; // works as expected, mean is left uninitialised } void g(out float[M][M] corr) // works but assigns twice { corr[] = float.init; // compiler inserted // assign to each value of corr } // only assigns once but does not signal intention like out does // also is valid to read from `corr` as opposed to write only like `g` void h(ref float[M][M] corr) { // assign to each value of corr } //Error: found ')' when expecting '.' following void void i(out float[M][M] corr = void) { // assign to each value of corr } --
Re: @safe(bool)
On Sunday, 20 August 2017 at 00:49:28 UTC, Nicholas Wilson wrote: [...] With DIP 1012 you should be able to go struct Container(T, bool safetyOn = true) { static if(safe) RefCounted!(T[]) data; else T[] data; auto opSlice() @safeIf!safetyOn { return Range(data, 0, data.length); } } template safeIf(bool cond) { static if (cond) alias safeIf = AliasSeq!(safe); else alias safeIf = AliasSeq!(); } or even just struct Container(T, FunctionSafety safetyOn = safe) { static if(safe) RefCounted!(T[]) data; else T[] data; auto opSlice() @safetyOn { return Range(data, 0, data.length); } } Container!int foo; // Container!(int, safe) Container!(int, system) bar; This is indeed, a nice solution. I am a _bit_ worried about abuse, and loss of modularity, but aside from that, I think it's a better solution overall. The only downside is that the second form leaves itself open to Easily fixed with a template constraint, right? This could potentially render a large portion of the projects on code.dlang.org broken though. What would be nice, is if code.dlang.org regularly built all the projects, and notified the authors of the breakage, possibly sending a list of recent compiler changes as well.
Re: @safe(bool)
On Saturday, 19 August 2017 at 20:39:07 UTC, jmh530 wrote: On Saturday, 19 August 2017 at 13:09:41 UTC, Nicholas Wilson wrote: Hacking the runtime is certainly one way to achieve changing the default attributes. However having them as regular attributes means that is is possible to do configuration by version statements, which is a) much easier than hacking the runtime and b) causes much less fragmentation. This may not be so elegant...but what if one could only take an alias of these in core.attributes or in a package.d file? At least that way people would know where to look if widespread changes are made? Sorry, I was referring to preconfigurations in druntime like https://github.com/dlang/DIPs/pull/89/files#diff-26bf588c0174e6cd0fe3d4af615bebdaL60
Re: @safe(bool)
On Saturday, 19 August 2017 at 19:15:25 UTC, bitwise wrote: On Saturday, 19 August 2017 at 18:22:58 UTC, Guillaume Boucher wrote: On Thursday, 17 August 2017 at 16:32:20 UTC, bitwise wrote: In a high-performance context though, the performance hit may be unacceptable. Well in those super rare situations, there's always the workaround with mixins: Those situations are not rare. mixin template funcWithAttr(string decl, string attributes, string code) { pragma(msg, "<<<" ~ code ~ ">>>"); mixin(decl ~ attributes ~ "{" ~ code ~" }"); } struct Container(T, bool safetyOn = true) { static if(safe) RefCounted!(T[]) data; else T[] data; mixin funcWithAttr!("auto opSlice()", safetyOn ? "@safe" : "", q{ return Range(data, 0, data.length); }); } Really? With DIP 1012 you should be able to go struct Container(T, bool safetyOn = true) { static if(safe) RefCounted!(T[]) data; else T[] data; auto opSlice() @safeIf!safetyOn { return Range(data, 0, data.length); } } template safeIf(bool cond) { static if (cond) alias safeIf = AliasSeq!(safe); else alias safeIf = AliasSeq!(); } or even just struct Container(T, FunctionSafety safetyOn = safe) { static if(safe) RefCounted!(T[]) data; else T[] data; auto opSlice() @safetyOn { return Range(data, 0, data.length); } } Container!int foo; // Container!(int, safe) Container!(int, system) bar; The only downside is that the second form leaves itself open to Container!(int, trusted) quux; which is probably undesirable.
Re: @safe(bool)
On Saturday, 19 August 2017 at 17:10:54 UTC, bitwise wrote: I'm still concerned about having to read code that's laced full of custom attributes, the resolution of which may span several files, templates, etc. I also think this type of thing could have a detrimental effect on modularity when you end up having to include "myAttribs.d" in every single file you want to work on. I would much rather have a flexible in-language solution, or a solution that didn't require me to define my own attributes. Having worked on a project with a lot of attributes, my suggestion would be to import it via a package.d, you'll be importing that anyway.
[Issue 10523] Don't call array op functions for short vector ops
https://issues.dlang.org/show_bug.cgi?id=10523 --- Comment #1 from github-bugzi...@puremagic.com --- Commit pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/80513b41f815b4cc77fa279f63ea0feaad358041 convert array ops to library calls - capture expression tree as reverse polish notation - pass scalar subtrees as single argument - fixes Issue 10523 - don't call array op functions for short vector ops --
Re: void init of out variables
On 8/18/2017 11:24 PM, Nicholas Wilson wrote: On Saturday, 19 August 2017 at 06:23:10 UTC, Igor Shirkalin wrote: On Saturday, 19 August 2017 at 06:20:28 UTC, Nicholas Wilson wrote: I have a function that takes a large matrix as an out parameter. Is there a way to do `=void` for an out parameter like there is for is for a plain declaration? enum M = 2600; void f() { float[M] mean = void; // works as expected, mean is left uninitialised } void g(out float[M][M] corr) // works but assigns twice { corr[] = float.init; // compiler inserted // assign to each value of corr } //Error: found ')' when expecting '.' following void void h(out float[M][M] corr = void) { } is there a way to not assign to out variables? Try 'ref' instead of 'out'. Hmm, I could, but ref doesn't signal intention like out does. True. Please file an enhancement request.
[Issue 17764] [scope][DIP1000] Escape checker defeated by composition transformations
https://issues.dlang.org/show_bug.cgi?id=17764 ZombineDevchanged: What|Removed |Added Keywords||accepts-invalid, ||rejects-valid, safe --- Comment #1 from ZombineDev --- Typo: the last lines were meant to be: $ dmd -dip1000 scope_bug2.d $ echo $? 0 $ dmd --version DMD64 D Compiler v2.076.0-b1-master-32bb4ed --
[Issue 17764] New: [scope][DIP1000] Escape checker defeated by composition transformations
https://issues.dlang.org/show_bug.cgi?id=17764 Issue ID: 17764 Summary: [scope][DIP1000] Escape checker defeated by composition transformations Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: petar.p.ki...@gmail.com At first I was about to name this issue "The compiler treats 'scope ref T' and 'scope ref T[1]' differently" (see `use0x3()` and `use0x4()`), but then I decided to dig a little more, so here's what I've found so far: $ cat > scope_bug.d << DBUG @safe: struct Context0x0 { char[] str; } struct Parent0x1 { Context0x0 c; } struct Parent0x2 { Context0x0[1] csa; } struct Parent0x3 { Context0x0[] csl; } struct Parent0x4 { Context0x0*cp; } struct Parent0x5 { Parent0x1 p1; } struct Parent0x6 { Parent0x5 p5; } struct Parent0x7 { Parent0x6 p6; } struct Parent0x8 { Parent0x2[1]* p2; } struct Parent0x9 { Parent0x8[1] p8; } struct Parent0xA { Parent0x9[1] p9; } struct Parent0xB { Parent0x4* p4; } struct Parent0xC { Parent0xB* pb; } struct Parent0xD { Parent0xC* pc; } void main() { char[16] buf; use0x0(buf); char[] charSlice = buf; use0x1(charSlice); // use0x2(); // NG - rejects valid Context0x0[1] c = Context0x0(charSlice); use0x3(c[0]); use0x4(c); use0x5(c); auto p1 = Parent0x1(c[0]); use0x6(p1); auto p2 = Parent0x2(c); use0x7(p2); Context0x0[] contextSlice = c[]; auto p3 = Parent0x3(contextSlice); use0x8(p3); auto p4 = Parent0x4([0]); use0x9(p4); auto p5 = Parent0x7(Parent0x6(Parent0x5(p1))); use0xA(p5); Parent0x2[1] p2sa = Parent0x2(c); Parent0xA p6 = Parent0xA(Parent0x9(Parent0x8())); use0xB(p6); // auto pbAttemp1 = Parent0xB(); // NG - rejects valid Parent0x4[1] p4WorkAround = Parent0x4([0]); Parent0xB[1] pb = Parent0xB([0]); Parent0xC[1] pc = Parent0xC([0]); Parent0xD[1] pd = Parent0xD([0]); use0xC(pd[0]); } char[] global; void use0x0(scope char[] arr) { // global = arr; // OK - this does not compile } void use0x1(scope ref char[] arr) { // global = arr; // OK - this does not compile } void use0x2(scope char[]* arr) { global = *arr; // NG - accepts invalid } void use0x3(scope ref Context0x0 c) { // global = c.str; // OK - this does not compile } void use0x4(scope ref Context0x0[1] c) { global = c[0].str; // NG - accepts invalid } void use0x5(scope Context0x0[] c) { global = c[0].str; // NG - accepts invalid } void use0x6(scope ref Parent0x1 p) { // global = p.c.str; // OK - this does not compile } void use0x7(scope ref Parent0x2 p) { global = p.csa[0].str; // NG - accepts invalid } void use0x8(scope ref Parent0x3 p) { global = p.csl[0].str; // NG - accepts invalid } void use0x9(scope ref Parent0x4 p) { global = p.cp.str; // NG - accepts invalid } void use0xA(scope ref Parent0x7 p) { // global = p.p6.p5.p1.c.str; // OK - this does not compile } void use0xB(scope ref Parent0xA p) { global = (*p.p9[0].p8[0].p2)[0].csa[0].str; // NG - accepts invalid } void use0xC(scope ref Parent0xD p) { global = p.pc.pb.p4.cp.str; // NG - accepts invalid } DBUG $ dmd -dip1000 scope_bug.d scope_bug.d(11): Error: cannot take address of scope local c in @safe function main $ dmd --version DMD64 D Compiler v2.076.0-b1-master-32bb4ed --
Re: Exception chaining and collectException
On Friday, 18 August 2017 at 22:51:35 UTC, Walter Bright wrote: On 8/18/2017 5:07 AM, Steven Schveighoffer wrote: If we are to remove them, what happens when exceptions would normally chain? In C++, throwing an exception while unwinding is a fatal error. Well, you still can throw it, but you're not allowed to let it escape the destructor (you need to catch them before they would chain). C++ also provides a way to inspect if you're in the middle of the stack unwinding caused by an exception, to make this a bit more controllable, and I would think we should provide the similar primitive: http://en.cppreference.com/w/cpp/error/uncaught_exception.
Re: @safe(bool)
On Saturday, 19 August 2017 at 13:09:41 UTC, Nicholas Wilson wrote: Hacking the runtime is certainly one way to achieve changing the default attributes. However having them as regular attributes means that is is possible to do configuration by version statements, which is a) much easier than hacking the runtime and b) causes much less fragmentation. This may not be so elegant...but what if one could only take an alias of these in core.attributes or in a package.d file? At least that way people would know where to look if widespread changes are made?
Re: LDC, ARM: unnecessary default initialization
On Friday, 18 August 2017 at 17:28:38 UTC, kinke wrote: On Friday, 18 August 2017 at 12:09:04 UTC, kinke wrote: On Friday, 18 August 2017 at 09:42:25 UTC, Jack Applegame wrote: For some reason, the LDC default initializes the structure, even if initialization of all its members is specified as void. I believe that this is wrong. Afaik, this has been brought up multiple times already and is so by design. Every aggregate has an init symbol, omitting that (and accordingly the default initialization of all instances) by initializing each field with void doesn't work. The initialization isn't performed fieldwise, but is a bitcopy of T.init. You can skip initialization of specific instances though - `S s = void;` - but again not if `s` is a field of another aggregate. Sorry, I forgot some workaround code: void ResetHandler() { Foo foo = void; foo.__ctor(10); // or: std.conv.emplace(, 10); } Thanks for the answer. Also I found another workaround code: test.d module test; import core.bitop : volatileStore; struct Foo { uint[64] m = void; // no default initialization static auto opCall(uint a) { Foo foo = void; foreach(ref b; foo.m) volatileStore(,a++); return foo; } } void ResetHandler() { auto foo = Foo(10); } assembly <_D4test12ResetHandlerFZv>: 0: b0c0sub sp, #256; 0x100 2: 2000movsr0, #0 4: 4669mov r1, sp 6: f100 020a add.w r2, r0, #10 a: f841 2020 str.w r2, [r1, r0, lsl #2] e: 3001addsr0, #1 10: 2a49cmp r2, #73 ; 0x49 12: d1f8bne.n 6 <_D4test12ResetHandlerFZv+0x6> 14: b040add sp, #256; 0x100 16: 4770bx lr
[Issue 17762] Cannot compile with clean DMD.
https://issues.dlang.org/show_bug.cgi?id=17762 Rainer Schuetzechanged: What|Removed |Added Severity|critical|normal --- Comment #4 from Rainer Schuetze --- BTW: I don't think there is an infected Visual D installer anywhere on the official download page https://github.com/dlang/visuald/releases If you think there is a not-falsely reported infected version please report the link. --
Re: @safe(bool)
On Saturday, 19 August 2017 at 18:22:58 UTC, Guillaume Boucher wrote: On Thursday, 17 August 2017 at 16:32:20 UTC, bitwise wrote: In a high-performance context though, the performance hit may be unacceptable. Well in those super rare situations, there's always the workaround with mixins: Those situations are not rare. mixin template funcWithAttr(string decl, string attributes, string code) { pragma(msg, "<<<" ~ code ~ ">>>"); mixin(decl ~ attributes ~ "{" ~ code ~" }"); } struct Container(T, bool safetyOn = true) { static if(safe) RefCounted!(T[]) data; else T[] data; mixin funcWithAttr!("auto opSlice()", safetyOn ? "@safe" : "", q{ return Range(data, 0, data.length); }); } Really?
[Issue 17762] Cannot compile with clean DMD.
https://issues.dlang.org/show_bug.cgi?id=17762 Rainer Schuetzechanged: What|Removed |Added CC||r.sagita...@gmx.de --- Comment #3 from Rainer Schuetze --- Please read http://rainers.github.io/visuald/visuald/BuildFromSource.html Check the appveyor.yml file in case you cannot find some dependencies. --
[Issue 17763] [scope][DIP1000] The compiler treats implicit and explicit static array slicing differently
https://issues.dlang.org/show_bug.cgi?id=17763 ZombineDevchanged: What|Removed |Added Summary|[scope][DIP1000] Error: |[scope][DIP1000] The |"cannot take address of |compiler treats implicit |scope local" while passing |and explicit static array |a slice to a scope |slicing differently |parameter | --
Re: real simple delegate question.
On Friday, 18 August 2017 at 20:39:38 UTC, angel wrote: On Friday, 18 August 2017 at 02:38:15 UTC, WhatMeForget wrote: [...] This actually appears correct ... The 1-st example: Each call to makeCalculator() increments a static (i.e. shared among all makeCalculator() instances) variable - context. In addition, makeCalculator() generates a random variable. Whereas the delegate merely captures these variables, and the displayed results reflect this. The 2-nd example: There is a single call to makeCalculator(). After this call, context == 1, randy == _apparently 2_. Now the delegate, as has already been said, merely captures these values, so consecutive calls do not change the result. Thanks. So, auto calculator = makeCalculator(); is the actual call of the delegate? "Delegate is function pointer with context" But what is ...calculator(0)); Or maybe another approach would be to ask, what type is the compiler replacing auto with.
Re: @safe(bool)
On Thursday, 17 August 2017 at 16:32:20 UTC, bitwise wrote: In a high-performance context though, the performance hit may be unacceptable. Well in those super rare situations, there's always the workaround with mixins: mixin template funcWithAttr(string decl, string attributes, string code) { pragma(msg, "<<<" ~ code ~ ">>>"); mixin(decl ~ attributes ~ "{" ~ code ~" }"); } struct Container(T, bool safetyOn = true) { static if(safe) RefCounted!(T[]) data; else T[] data; mixin funcWithAttr!("auto opSlice()", safetyOn ? "@safe" : "", q{ return Range(data, 0, data.length); }); }
Re: @safe(bool)
On Saturday, 19 August 2017 at 16:02:27 UTC, bitwise wrote: We have to consider the potential for abuse. I don't like measuring features on the potential for abuse, but this feature cries for abuse. Even in the simpler form of your proposal. Let's say there are two functions with conditional @safe f(T)(...) @safe(!hasAliasing!T) {...} g(bool B)(...) @safe(B) {...} and we combine them into another function, h(T,bool B) @safe(!hasAliasing!T && B) { f(T)(...); g(B)(...); } then in the correct @safe specification there is an additional clause for every conditionally-safe function. This doesn't scale well. So the guideline would be to use your feature very rarely and only if it's obvious from the meaning of the template arguments; if it gets too complicated, just don't specify it. Which would mean the feature should only be used in few corner cases, and is thus not worth the cost of complicating the language. You already commented on the other usage of dip 1012, the @nice and @naughty attributes. They just don't scale in a similar way. C++ has had the same feature for some time: noexcept(true) means noexcept, noexcept(false) means an exception may be thrown (of course this works with any constant expressions). I just grepped through Boost and I have found 53 uses of noexcept(expression), from 5264 total uses of noexcept (excluding the math library). And Boost is one of those libraries that are overly precise with such things to a degree that the code becomes unreadable. In code outside of Boost and the standard library, noexcept(expression) it is basically unused.
[Issue 17763] [scope][DIP1000] Error: "cannot take address of scope local" while passing a slice to a scope parameter
https://issues.dlang.org/show_bug.cgi?id=17763 ZombineDevchanged: What|Removed |Added Keywords||accepts-invalid, ||rejects-valid --- Comment #1 from ZombineDev --- While previous case was rejects-valid, here's a similar one where the compile accepts invalid code: $ cat > scope_bug2.d << DBUG @safe: struct Context { char[] str; } void main() { Context[1] c; use(c); } Context[] global; void use(scope ref Context[1] c) { // global = c[]; // OK - this does not compile. global = c; // NG - this does compile, but it should not // as it is equivalent to the one above. } DBUG $ dmd -dip1000 scope_bug2.d $ echo $? 0 --
Re: Visual Studio Code code-d serve-d beta release
On Saturday, 19 August 2017 at 13:07:41 UTC, WebFreak001 wrote: On Saturday, 19 August 2017 at 05:11:35 UTC, Soulsbane wrote: On Saturday, 19 August 2017 at 05:11:13 UTC, Soulsbane wrote: I got it working! Nice work so far except I no longer see any output in the extension Code Outline's[1] pane. It works fine in the other version of code-d. I know this functionality probably won't be a priority but in my opinion having the two extensions work together makes writing D code really sweet. Thanks again! And I forgot to link the extension: https://marketplace.visualstudio.com/items?itemName=patrys.vscode-code-outline cool, looks really useful! I added it to my dlang extension bundle https://marketplace.visualstudio.com/items?itemName=webfreak.dlang-bundle Thanks a lot!
Re: @safe(bool)
On Friday, 18 August 2017 at 23:48:05 UTC, Nicholas Wilson wrote: The only breaking changes are nothrow and pure get a leading '@'. They will go through a proper deprecation process and I will be very surprised if anything breaks. The new symbols added to core.attributes can use `@future` if need be to further reduce the likelihood of any breaking changes. While the difference in attribute style(@, or no @) isn't that hard to deal with in practice, I am definitely in favor of a more consistent scheme. The current inconsistency looks bad, and IMO, that's a big deal. It makes D look tacky, and easy to dismiss. How would you know what attributes were in effect before? It wouldn't matter if your intention was to clobber them anyways with @default. And if you only wanted to clobber @nogc, you could use @nogc(false), and it still wouldn't matter what the inferred attribute set was. I'm still concerned about having to read code that's laced full of custom attributes, the resolution of which may span several files, templates, etc. I also think this type of thing could have a detrimental effect on modularity when you end up having to include "myAttribs.d" in every single file you want to work on. I would much rather have a flexible in-language solution, or a solution that didn't require me to define my own attributes.
[Issue 17763] New: [scope][DIP1000] Error: "cannot take address of scope local" while passing a slice to a scope parameter
https://issues.dlang.org/show_bug.cgi?id=17763 Issue ID: 17763 Summary: [scope][DIP1000] Error: "cannot take address of scope local" while passing a slice to a scope parameter Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: petar.p.ki...@gmail.com The problem is that the compiler disallows explicitly slicing a static array and passing the slice to a scope parameter, while if you rely on the implicit slicing it works without a problem. To reproduce: $ cat > scope_bug.d << DBUG @safe: struct Context { char[] str; } void use(scope Context[] c) { } void main() { char[1] s = '@'; Context[1] c; c[0].str = s; // <- If this line is commented, it all works. c[0] = Context(s); // <- this has the same effect as above. use(c);// OK - this compiles. use(c[]); // NG - doesn't compile, though should be // equivalent to the statement above. } DBUG $ dmd -dip1000 scope_bug.d scope_bug.d(11): Error: cannot take address of scope local c in @safe function main $ dmd --version DMD64 D Compiler v2.076.0-b1-master-32bb4ed --
[Issue 17763] [scope][DIP1000] Error: "cannot take address of scope local" while passing a slice to a scope parameter
https://issues.dlang.org/show_bug.cgi?id=17763 ZombineDevchanged: What|Removed |Added Keywords||safe --
Re: dmd (v2.075.0): fully static linking: undefined reference to `__tls_get_addr'
On Saturday, 19 August 2017 at 14:22:21 UTC, kdevel wrote: On Saturday, 19 August 2017 at 14:07:49 UTC, kdevel wrote: src/rt/sections_elf_shared.d:(.text._D2rt19sections_elf_shared11getTLSRangeFNbNimmZAv[_D2rt19sections_elf_shared11getTLSRangeFNbNimmZAv]+0x38): undefined reference to `__tls_get_addr' https://issues.dlang.org/show_bug.cgi?id=12268 That function is supposed to be provided by the dynamic linker when running your program, but I'm guessing -static makes the linker check for all symbols at link-time, not allowing such deferred linking. It looks like dmd or druntime doesn't support such full static linking yet, as they assume that function will be there.
Re: @safe(bool)
On Friday, 18 August 2017 at 18:15:33 UTC, Timon Gehr wrote: [...] alias naughty = AliasSeq!(impure,system,throws,gc); alias nice = AliasSeq!(pure,safe,nothrow,nogc); @nice void foo(); @naughty void bar(); We have to consider the potential for abuse. For example, D's templates are great - but it doesn't mean that if you're making a math library, that you should template your matrix class on it's dimensions, just to fill it with static if's because half of the functionality only applies to a single dimension. Especially when you typically need 2-3 different versions at most(mat2, mat3, mat4). People do it though. If things did turn out to be as simple as the example you posted, then I could see it being a useful way to hide some of D's painful attribute bloat, but I've got a feeling we'd start seeing things like "nice", "nicer", "nicest", "niceInDebugModeButNotReleaseModeUnlessAssertsAreEnabled", etc.
Re: Quora
Its called necro-posting. I'm surprised that post isn't read-only. Call it like you want, but I ee people putting new answers/comments to years old posts all the times, as it's perfectly legitimate on many blogs and websites. What was the best answer 10 years ago is often completely wrong nowadays. Forbidding people to suggest what can easily solve the problem *right now* is what would be silly IMHO.
Re: Quora
On Saturday, 19 August 2017 at 15:08:41 UTC, rikki cattermole wrote: Its called necro-posting. I'm surprised that post isn't read-only. Stack Overflow (and sibling sites) explicitly encourage answering old questions (they will give you badges for it) because they get good search results and should be kept up to date.
Re: Quora
On 19/08/2017 4:02 PM, Ecstatic Coder wrote: That is 6 years old. It would not help anybody to comment. Have you noticed that when you "google" something related to programming, the first results are often pages which are several years old ? If I understand you well, you are telling me to let these pages unchanged. We shouldn't tell people about alternatives like D, because Java/C#/PHP/etc is better suited to get the job done anyway. Surprising, but interesting point of view, I admit... Its called necro-posting. I'm surprised that post isn't read-only.
Re: Quora
That is 6 years old. It would not help anybody to comment. Have you noticed that when you "google" something related to programming, the first results are often pages which are several years old ? If I understand you well, you are telling me to let these pages unchanged. We shouldn't tell people about alternatives like D, because Java/C#/PHP/etc is better suited to get the job done anyway. Surprising, but interesting point of view, I admit...
Re: Quora
On 19/08/2017 3:54 PM, Ecstatic Coder wrote: Or more likely some community members who have the privileges to remove answers, think that hype and "proof" of usage is more important than actual technical reasons. I suggest that you try to talk about D here : https://softwareengineering.stackexchange.com/questions/35890/best-programming-language-for-web-development Good luck... That is 6 years old. It would not help anybody to comment.
Re: Quora
Or more likely some community members who have the privileges to remove answers, think that hype and "proof" of usage is more important than actual technical reasons. I suggest that you try to talk about D here : https://softwareengineering.stackexchange.com/questions/35890/best-programming-language-for-web-development Good luck...
Re: Quora
On 19/08/2017 3:38 PM, Ecstatic Coder wrote: On Saturday, 19 August 2017 at 11:33:13 UTC, Joakim wrote: On Saturday, 19 August 2017 at 11:00:25 UTC, Rico Decho wrote: Here is another one : https://www.quora.com/Which-language-is-best-for-a-beginner-programmer I don't think many people here go to Quora, I know I don't. You answers were decent though. You should go on Quora more often, because it is one of the rare places where we can freely suggest D if somebody asks "what is the best...". On Stackoverflow almost all my answers have been removed at once, because they found my D suggestions were "promotional content". But I see that they have left all the other answers based on C++/Go/Dart/Java/C#/PHP/etc. Completely stupid and unfair... Obviously they don't want people to have the best solution to their problem, but only the solutions that closely match Stackoverflow's marketing business... Or more likely some community members who have the privileges to remove answers, think that hype and "proof" of usage is more important than actual technical reasons.
Re: Quora
On Saturday, 19 August 2017 at 11:33:13 UTC, Joakim wrote: On Saturday, 19 August 2017 at 11:00:25 UTC, Rico Decho wrote: Here is another one : https://www.quora.com/Which-language-is-best-for-a-beginner-programmer I don't think many people here go to Quora, I know I don't. You answers were decent though. You should go on Quora more often, because it is one of the rare places where we can freely suggest D if somebody asks "what is the best...". On Stackoverflow almost all my answers have been removed at once, because they found my D suggestions were "promotional content". But I see that they have left all the other answers based on C++/Go/Dart/Java/C#/PHP/etc. Completely stupid and unfair... Obviously they don't want people to have the best solution to their problem, but only the solutions that closely match Stackoverflow's marketing business...
Re: dmd (v2.075.0): fully static linking: undefined reference to `__tls_get_addr'
On Saturday, 19 August 2017 at 14:07:49 UTC, kdevel wrote: src/rt/sections_elf_shared.d:(.text._D2rt19sections_elf_shared11getTLSRangeFNbNimmZAv[_D2rt19sections_elf_shared11getTLSRangeFNbNimmZAv]+0x38): undefined reference to `__tls_get_addr' https://issues.dlang.org/show_bug.cgi?id=12268
Re: Different Output after each execution
On Friday, 18 August 2017 at 16:53:46 UTC, Moritz Maxeiner wrote: On Friday, 18 August 2017 at 15:46:13 UTC, Vino.B wrote: [...] Negating the filtering rule should yield you the inverse set: --- dirEntries(i, SpanMode.shallow).filter!(a => a.isDir).filter!(a => !globMatch(a.baseName, "*DND*")) --- Also I don't see a reason to use two filter invocations here, you can join the conditions to a single filter (same for the unnegated one): --- dirEntries(i, SpanMode.shallow).filter!(a => a.isDir && !globMatch(a.baseName, "*DND*")) --- Thank you very much, it resolved the issue and also update my code as advised.
Folder Size
Hi All, I have written a small program to find the size of folder's , but the output is not as expected, hence request your help and advice on any techniques to reduce the run time of the program. Requirement: The script has to scan several file system ("C:\\Temp\\TEAM","C:\\Temp\\PROD_TEAM", "C:\\Temp\\BACKUP") Display only the sub folder level 1 name whose name should not contain *DND* and size dirEntries(i, SpanMode.shallow).filter!(a => a.isDir && !globMatch(a.baseName, "*DND*")) Eg: C:\Temp\TEAM\USER_BACKUP , C:\Temp\PROD_TEAM\PROD_BACKUP , C:\Temp\BACKUP\SUPPORT_BACKUP Need the folder name and size of each folder under C:\Temp\TEAM\USER_BACKUP , C:\Temp\PROD_TEAM\PROD_BACKUP , C:\Temp\BACKUP\SUPPORT_BACKUP Program import std.file: dirEntries, isFile, SpanMode; import std.stdio: writeln; import std.algorithm: filter; import std.array: array; import std.path; auto AgedDirlst = [ "C:\\Temp\\TEAM\\USER_BACKUP" , "C:\\Temp\\PROD_TEAM\\PROD_BACKUP" , "C:\\Temp\\BACKUP\\SUPPORT_BACKUP" ]; void main () { foreach (string i; AgedDirlst[0 .. $]) { auto dFiles = dirEntries(i, SpanMode.shallow).filter!(a => a.isDir && !globMatch(a.baseName, "*DND*")).array; foreach (d; dFiles) { auto SdFiles = dirEntries(d, SpanMode.depth).array; foreach (f; SdFiles) writeln(f.dirName, "\t", f.size); } } writeln("*"); } Output: C:\Temp\TEAM\USER_BACKUP\DIR1 41129 C:\Temp\TEAM\USER_BACKUP\DIR1\dir3 68 C:\Temp\TEAM\USER_BACKUP\DIR1 0 C:\Temp\TEAM\USER_BACKUP\DIR2\dir4 3410 C:\Temp\TEAM\USER_BACKUP\DIR2\dir4 2277663 C:\Temp\TEAM\USER_BACKUP\DIR2 0 C:\Temp\TEAM\USER_BACKUP\DIR2 1156 C:\Temp\PROD_TEAM\PROD_BACKUP\dir1 41129 C:\Temp\PROD_TEAM\PROD_BACKUP\dir1\dir3 68 C:\Temp\PROD_TEAM\PROD_BACKUP\dir1 0 C:\Temp\PROD_TEAM\PROD_BACKUP\dir1\DND1 36590125 C:\Temp\PROD_TEAM\PROD_BACKUP\dir1 0 C:\Temp\PROD_TEAM\PROD_BACKUP\dir2\dir4 3410 C:\Temp\PROD_TEAM\PROD_BACKUP\dir2 0 C:\Temp\PROD_TEAM\PROD_BACKUP\dir2 1156 C:\Temp\BACKUP\SUPPORT_BACKUP\dir1\DND1 36590125 C:\Temp\BACKUP\SUPPORT_BACKUP\dir1 0 C:\Temp\BACKUP\SUPPORT_BACKUP\dir2\DND2 1156 --- Required Output --- C:\Temp\TEAM\USER_BACKUP\DIR1 41197 (41129+68) C:\Temp\TEAM\USER_BACKUP\DIR2 2282229 (3410+2277663+1156) C:\Temp\PROD_TEAM\PROD_BACKUP\dir1 36631322 (41129+68+36590125) C:\Temp\PROD_TEAM\PROD_BACKUP\dir2 4566 (3410+1156) C:\Temp\BACKUP\SUPPORT_BACKUP\dir1 36590125 C:\Temp\BACKUP\SUPPORT_BACKUP\dir2 1156 From, Vino.B
dmd (v2.075.0): fully static linking: undefined reference to `__tls_get_addr'
test.d --- void main () { } --- $ dmd -c test.d $ cc -o test test.o -L/[...]/dmd2/linux/lib64 -lphobos2 -static -lpthread -lrt /[...]/dmd2/linux/lib64/libphobos2.a(sections_elf_shared_774_420.o): In function `_D2rt19sections_elf_shared11getTLSRangeFNbNimmZAv': src/rt/sections_elf_shared.d:(.text._D2rt19sections_elf_shared11getTLSRangeFNbNimmZAv[_D2rt19sections_elf_shared11getTLSRangeFNbNimmZAv]+0x38): undefined reference to `__tls_get_addr' collect2: error: ld returned 1 exit status Found that on the net but no solution: http://www.digitalmars.com/d/archives/digitalmars/D/learn/Static_linking_on_Linux_with_dmd_or_gcc_74954.html Any hints?
[Issue 17762] Cannot compile with clean DMD.
https://issues.dlang.org/show_bug.cgi?id=17762 --- Comment #2 from Vincent--- > The official releases for Windows are signed and not infected. Unfortunately, I already had infected visuald.exe and don't want my bad experience repeat, whatever you try to convince me. In any case, it's not bad idea to compile myself; why not? > > If you distribute product in sources, it's a MUST to describe what > > additional packages should be in system > > The release binaries contain everything . Nice run make.. I talk about SOURCES. If I download sources and compile, they SHOULD compile. If they don't, author should specify what dependencies have to be installed. --
Re: Visual Studio Code code-d serve-d beta release
On Saturday, 19 August 2017 at 05:11:35 UTC, Soulsbane wrote: On Saturday, 19 August 2017 at 05:11:13 UTC, Soulsbane wrote: I got it working! Nice work so far except I no longer see any output in the extension Code Outline's[1] pane. It works fine in the other version of code-d. I know this functionality probably won't be a priority but in my opinion having the two extensions work together makes writing D code really sweet. Thanks again! And I forgot to link the extension: https://marketplace.visualstudio.com/items?itemName=patrys.vscode-code-outline cool, looks really useful! I added it to my dlang extension bundle https://marketplace.visualstudio.com/items?itemName=webfreak.dlang-bundle
Re: @safe(bool)
On Saturday, 19 August 2017 at 02:00:47 UTC, jmh530 wrote: On Saturday, 19 August 2017 at 00:37:06 UTC, Nicholas Wilson wrote: Having to change the default attributes will be a rare occurrence (embedded (nothrow, nogc final) security critical (safe). My reading of that updated DIP is that you can only change the default attributes by hacking on DRuntime. Hacking the runtime is certainly one way to achieve changing the default attributes. However having them as regular attributes means that is is possible to do configuration by version statements, which is a) much easier than hacking the runtime and b) causes much less fragmentation. I don't think we want to encourage people to change the default attributes, but I think its one of those features that we have in D for those who know what they're doing (e.g =void) and don't want to get in their way of doing so. If a project has a custom runtime, I would figure most people would mention it somewhere. I would hope so!
[Issue 17762] Cannot compile with clean DMD.
https://issues.dlang.org/show_bug.cgi?id=17762 greenifychanged: What|Removed |Added CC||greeen...@gmail.com --- Comment #1 from greenify --- > I cannot use precompiled binaries, since author already compromised himself > distributing infected DLL. What??? The official releases for Windows are signed and not infected. There was an issue with VisualD being FALSELY detected, but that was an issue on the side of the Antivirus company. > If you distribute product in sources, it's a MUST to describe what additional > packages should be in system The release binaries contain everything . Nice run make.. --
[Issue 17762] New: Cannot compile with clean DMD.
https://issues.dlang.org/show_bug.cgi?id=17762 Issue ID: 17762 Summary: Cannot compile with clean DMD. Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: critical Priority: P1 Component: visuald Assignee: nob...@puremagic.com Reporter: thor...@gmail.com I have clean DMD 2.074 installation and some old visuald version. I open visuald project in VS2015-Ent, compile and... lot of bugs due to lack of packages: Error: module completion is in file 'vsi\completion.d' which cannot be read Error: module windef is in file 'sdk\win32\windef.d' which cannot be read Error: module commctrl is in file 'sdk\win32\commctrl.d' which cannot be read If you distribute product in sources, it's a MUST to describe what additional packages should be in system (better with original URL where you get 'em). PS I cannot use precompiled binaries, since author already compromised himself distributing infected DLL. --
Re: Quora
On Saturday, 19 August 2017 at 11:00:25 UTC, Rico Decho wrote: Here is another one : https://www.quora.com/Which-language-is-best-for-a-beginner-programmer I don't think many people here go to Quora, I know I don't. You answers were decent though.
Re: Module Info error
On 19-08-17 04:07, Johnson Jones wrote: Still getting this! What I don't understand is why I can import certain libraries and they compile fine while others don't! So, moduleInfo is a "function" per module that is created at compilation, right? If one doesn't compile the module then the error results, just like standard extern functions. When I don't include the file in the project, it doesn't get compiled, even though it gets "imported"? Why? Why can't D just know, hey, module X imports module Y, module Y needs to be compiled to add moduleInfo? For example, I am trying to get ffmpeg to work. I downloaded from https://github.com/complistic-gaff/ffmpeg-d extracted, put that path in my includes(sc.ini). created a module to import the standard modules, tried to compile my project and I get a bunch of ModuleInfo errors relating to the imports I added. I use GtkD exactly the same, yet no errors. Now, the only difference is that I import the gtkD.lib. I'm assuming that all the moduleInfo's of the 1000+ gtk files are in that lib and so That is the reason I don't have the compile them all, is that correct? If so, how can I generate such a lib of moduleInfo's recursively for a directory so I can pick up all the files and just import it once? ffmpeg doesn't require compiling but I don't wanna have to include ever file in to my project just to be able to get it to work because of the moduleInfo's are missing. Looking at the build.d for gtkD, it looks like it builds a list of all the files to compile and does it recursively. I imagine it can be modified for ffmpeg too to create a utility to solve this problem. Dmd should have a mode to do this automatically, it's quite an annoying problem ;/ You need to either compile ffmpeg-d in to a library and include it when you are building your application, or pass all the ffmpeg-d source files to the compiler. It looks like ffmpeg-d only has a dub.json file for building so you will need to use dub to build it eg: `dub build` from the root of the project. -- Mike Wey
Re: GtkD on android
On 19-08-17 01:55, Johnson wrote: Hey Mike, have you put in thought or effort in to getting GtkD working on android? e.g., https://github.com/eugals/GTKAndroid/wiki/Building If I get around to it and no one has beating me before, I will try to compile something like the above and get the gtk libs required then use the new ldc to create an app for android. No, but it would be interesting to see if you can get things working. -- Mike Wey
Re: ffmpeg
On Saturday, 19 August 2017 at 02:50:44 UTC, Johnson Jones wrote: Trying to get it to work. You could just try to use/call the ffmeg executable as wrapper. For sure, not the best, but proabably the easiest solution. Afaik it also supports pipes.
Re: void init of out variables
On Saturday, 19 August 2017 at 06:20:28 UTC, Nicholas Wilson wrote: is there a way to not assign to out variables? I don't think so. Is there a good reason not to return the matrix directly (taking advantage of in-place construction)? float[M][M] f() { float[M][M] mean = void; // init return mean; }
Re: Quora
Here is another one : https://www.quora.com/Which-language-is-best-for-a-beginner-programmer
Aedi 0.3.0 released
Good day, Announcing Aedi 0.3.0 release! Aedi is a dependency injection framework, aimed at easiness of use, easiness to extend, and easiness to integrate with existing tools. Following changes are included in 0.3.0 release: 1. New version of api to register and configure components (objects/structs etc.) in di containers, that eliminates some ambiguities in previous implementation. The new version implements the ability to view the file and line where components involved in an exception during container instantiation, are registered. This allows better debugging of mis-configured components. 2. Proxy container, a container that serves proxies instead of original components. The proxy for an object will proxy any public method defined in original object. The proxy container is useful for implementing containers with narrower scope than existing ones. 3. A new decorating container (type based container), that when a component in decorated container is not found, will attempt to serve another one that is derivative of requested component, or if it implements the interface that is requested. 4. New tutorial on using annotation based component configuration. Links: code.dlang.org: http://code.dlang.org/packages/aedi tutorials: https://github.com/aermicioi/aedi/wiki api documentation: https://aermicioi.github.io/aedi/ Cheers!
Using mixin templates for operator overloading.
Let us say I want to automatically define subtraction given that addition and negation are defined. I tried the following using mixin templates. If I simply mixin the template using "mixin sub;", then it gives the error tmpmixin.d(29): Error: incompatible types for ((a) - (b)): 'A!0' and 'A!0' I found out that mixin using an identifier for template mixins and then using an alias declaration as in the code given below can be used to bring in overloads. But, this produces the error. tmpmixin.d(23): Error: alias tmpmixin.A!0.A.opBinary conflicts with template tmpmixin.A!0.A.opBinary(string op : "+")(in A other) at tmpmixin.d(14) tmpmixin.d(29): Error: template instance tmpmixin.A!0 error instantiating As you can see, there is no conflict logically. One defines addition and the mixin defines subtraction. What is the right way to do this? mixin template sub() { alias T = typeof(this); T opBinary(string op : "-")(in T other) const { return this + (-other); } } struct A(int x) { int a; A opBinary(string op : "+")(in A other) const { return A(this.a + other.a); } A opUnary(string op : "-")() const { return A(-a); } mixin sub ops; alias opBinary = ops.opBinary; } void main() { import std.stdio : writeln; auto a = A!0(5), b = A!0(6); writeln(a-b); }
Quora
May I ask to those of you who actually agree that D is a nice language to learn programming and implement many kinds of applications to vote for my answers to the following questions on Quora ? https://www.quora.com/What-is-the-best-language-to-learn-as-a-beginner-programmer https://www.quora.com/Which-is-the-best-in-scripting-languages https://www.quora.com/What-is-the-best-scripting-language-for-beginners https://www.quora.com/Which-is-the-best-scripting-language-to-learn-for-beginners https://www.quora.com/What-is-the-best-language-to-be-able-to-make-any-kind-of-development-text-file-processing-scripts-web-servers-desktop-applications-etc Thanks :)
Re: Some news from Dplug
On Friday, 18 August 2017 at 12:45:34 UTC, Guillaume Piolat wrote: Some news from the audio front! Reminder: Dplug is a convenient library for creating audio plug-ins (VST / AU) for Mac, Windows and now Linux. Thanks to the effort of Richard Andrew Cattermole and Ethan Rekker, Dplug got Linux VST support. Ethan has written down the whole story here: http://www.modernmetalproduction.com/dplug-developing-vst-plugins-for-linux/ Two audio plug-ins were released recently with Dplug: - The M4 Multiband Compressor by Cut Through Recordings http://www.modernmetalproduction.com/product/m4-multiband-compressor-vst-au/ - Graillon 2 by Auburn Sounds https://www.auburnsounds.com/products/Graillon.html If you need a high performance 1D FFT, pfft the impressive work of Jernej Krempuš has been ported to DUB: http://code.dlang.org/packages/pfft Thanks, I also liked his post about D, especially the title: http://www.modernmetalproduction.com/d-elegant-language-civilized-age/ Mike, want to post the Dplug for Linux post to proggit/HN after the weekend?
Re: void init of out variables
On Saturday, 19 August 2017 at 06:23:10 UTC, Igor Shirkalin wrote: On Saturday, 19 August 2017 at 06:20:28 UTC, Nicholas Wilson wrote: I have a function that takes a large matrix as an out parameter. Is there a way to do `=void` for an out parameter like there is for is for a plain declaration? enum M = 2600; void f() { float[M] mean = void; // works as expected, mean is left uninitialised } void g(out float[M][M] corr) // works but assigns twice { corr[] = float.init; // compiler inserted // assign to each value of corr } //Error: found ')' when expecting '.' following void void h(out float[M][M] corr = void) { } is there a way to not assign to out variables? Try 'ref' instead of 'out'. Hmm, I could, but ref doesn't signal intention like out does.
void init of out variables
I have a function that takes a large matrix as an out parameter. Is there a way to do `=void` for an out parameter like there is for is for a plain declaration? enum M = 2600; void f() { float[M] mean = void; // works as expected, mean is left uninitialised } void g(out float[M][M] corr) // works but assigns twice { corr[] = float.init; // compiler inserted // assign to each value of corr } //Error: found ')' when expecting '.' following void void h(out float[M][M] corr = void) { } is there a way to not assign to out variables?
Re: void init of out variables
On Saturday, 19 August 2017 at 06:20:28 UTC, Nicholas Wilson wrote: I have a function that takes a large matrix as an out parameter. Is there a way to do `=void` for an out parameter like there is for is for a plain declaration? enum M = 2600; void f() { float[M] mean = void; // works as expected, mean is left uninitialised } void g(out float[M][M] corr) // works but assigns twice { corr[] = float.init; // compiler inserted // assign to each value of corr } //Error: found ')' when expecting '.' following void void h(out float[M][M] corr = void) { } is there a way to not assign to out variables? Try 'ref' instead of 'out'.