Re: Can't I allocate at descontructor?

2021-03-05 Thread Ali Çehreli via Digitalmars-d-learn
On 3/5/21 8:29 PM, Jack wrote: > Now about the behavior of a static destructor, like static ~this() { } > is this guaranteed to be run? I don't know any way of creating a module on the GC heap so their destruction should not be related to GC collection. I would expect all 'static ~this()'

Re: Can't I allocate at descontructor?

2021-03-05 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 6 March 2021 at 04:29:41 UTC, Jack wrote: Now about the behavior of a static destructor, like static ~this() { } is this guaranteed to be run? Yes. Some perspective: 1. During program execution, class/struct destructors on stack-allocated instances are invoked when the

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 21:24:08 UTC, tsbockman wrote: On Friday, 5 March 2021 at 21:17:24 UTC, tsbockman wrote: On Friday, 5 March 2021 at 21:02:08 UTC, H. S. Teoh wrote: class C {...} import core.memory : GC; C c = cast(C) GC.malloc(C.sizeof); ... ...

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 21:25:52 UTC, Ali Çehreli wrote: On 3/5/21 12:57 PM, Jack wrote: >> destroy() executes the destructor. > > but I would need to call it manually and only after I somewhat I've > determined I no longer need the resources, right? so destroy(c) would be > no different

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 21:02:08 UTC, H. S. Teoh wrote: On Fri, Mar 05, 2021 at 08:24:26PM +, Jack via Digitalmars-d-learn wrote: On Friday, 5 March 2021 at 20:18:44 UTC, Max Haughton wrote: > On Friday, 5 March 2021 at 20:13:54 UTC, Jack wrote: [...] > > But the ones heap may never

Re: Is there any generic iteration function that stops at first match?

2021-03-05 Thread Jesse Phillips via Digitalmars-d-learn
On Friday, 5 March 2021 at 02:13:39 UTC, Jack wrote: something like filter[1] but that stops at first match? are there any native functions for this in D or I have to write one? just making sure to not reinvent the wheel [1]: https://devdocs.io/d/std_algorithm_iteration#filter

Re: D's Continous Changing

2021-03-05 Thread harakim via Digitalmars-d-learn
On Friday, 5 March 2021 at 07:51:24 UTC, Siemargl wrote: On Friday, 5 March 2021 at 03:32:35 UTC, harakim wrote: I want this almost every week at work. When I run into some trivial statement that I need to know for sure how it works, it's rarely worth it to create a whole new file and make a

Re: How to get output of piped process?

2021-03-05 Thread Jesse Phillips via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 06:58:55 UTC, Jedi wrote: I an using pipeShell, I have redirected stdout, stderr, and stdin. I am trying to read from the output and display it in my app. I have followed this code almost exactly except I use try wait and flush because the app is

Re: Broken examples

2021-03-05 Thread MoonlightSentinel via Digitalmars-d-learn
On Friday, 5 March 2021 at 22:01:37 UTC, Imperatorn wrote: Any idea why? The examples are compiled using an older host compiler (__VERSION__ is 2.093) but use features introduced in a later version. This will be fixed by upgrading the compiler (the examples are checked using current master

Re: Broken examples

2021-03-05 Thread NonNull via Digitalmars-d-learn
On Friday, 5 March 2021 at 22:59:09 UTC, H. S. Teoh wrote: On Fri, Mar 05, 2021 at 10:01:37PM +, Imperatorn via Digitalmars-d-learn wrote: Basically none of the examples on here compile: https://dlang.org/library/std/conv/parse.html Any idea why? File a bug. T Sad that there's such

Re: Broken examples

2021-03-05 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 05, 2021 at 10:01:37PM +, Imperatorn via Digitalmars-d-learn wrote: > Basically none of the examples on here compile: > https://dlang.org/library/std/conv/parse.html > > Any idea why? File a bug. T -- By understanding a machine-oriented language, the programmer will tend to

Broken examples

2021-03-05 Thread Imperatorn via Digitalmars-d-learn
Basically none of the examples on here compile: https://dlang.org/library/std/conv/parse.html Any idea why?

Re: Broken examples

2021-03-05 Thread Imperatorn via Digitalmars-d-learn
On Friday, 5 March 2021 at 22:01:37 UTC, Imperatorn wrote: Basically none of the examples on here compile: https://dlang.org/library/std/conv/parse.html Any idea why? Output: onlineapp.d(10): Error: template `std.conv.parse` cannot deduce function from argument types `!(bool, string,

Re: Using YMM registers causes an undefined label error

2021-03-05 Thread z via Digitalmars-d-learn
On Friday, 5 March 2021 at 16:10:02 UTC, Rumbu wrote: First of all, in 64 bit ABI, parameters are not passed on stack, therefore a[RBP] is a nonsense. void complement32(simdbytes* a, simdbytes* b) a is in RCX, b is in RDX on Windows a is in RDI, b is in RSI on Linux I'm confused, with your

Re: Can't I allocate at descontructor?

2021-03-05 Thread Ali Çehreli via Digitalmars-d-learn
On 3/5/21 12:57 PM, Jack wrote: >> destroy() executes the destructor. > > but I would need to call it manually and only after I somewhat I've > determined I no longer need the resources, right? so destroy(c) would be > no different from calling my own finalize-like method like freeResources()?

Re: Can't I allocate at descontructor?

2021-03-05 Thread tsbockman via Digitalmars-d-learn
On Friday, 5 March 2021 at 21:17:24 UTC, tsbockman wrote: On Friday, 5 March 2021 at 21:02:08 UTC, H. S. Teoh wrote: class C {...} import core.memory : GC; C c = cast(C) GC.malloc(C.sizeof); ... ... import core.memory : GC; C c = cast(C)

Re: Can't I allocate at descontructor?

2021-03-05 Thread tsbockman via Digitalmars-d-learn
On Friday, 5 March 2021 at 21:02:08 UTC, H. S. Teoh wrote: If you know when you can deallocate something, that means you don't need the GC to collect it, so you could just allocate it on the malloc heap instead, and call destroy/free once you're done. You could use the C version of

Re: tiny alternative to std library

2021-03-05 Thread Siemargl via Digitalmars-d-learn
On Friday, 5 March 2021 at 16:54:48 UTC, Kagamin wrote: On Wednesday, 3 March 2021 at 20:54:43 UTC, Anthony Quizon wrote: I'm having some success pulling out small bits of code from other libraries and keeping things minimal and c-style-ish. If you're really ok with minimalism, I'm writing

Re: Can't I allocate at descontructor?

2021-03-05 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 05, 2021 at 08:24:26PM +, Jack via Digitalmars-d-learn wrote: > On Friday, 5 March 2021 at 20:18:44 UTC, Max Haughton wrote: > > On Friday, 5 March 2021 at 20:13:54 UTC, Jack wrote: [...] > > > But the ones heap may never run at all, is that right? > > > > You can't rely on the

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 20:28:58 UTC, Ali Çehreli wrote: On 3/5/21 12:24 PM, Jack wrote: Are there some kind of replacement or I have to make my own finalize-like method, once I determine somewhat the application no longer need those resources? destroy() executes the destructor. but I

Re: Can't I allocate at descontructor?

2021-03-05 Thread Ali Çehreli via Digitalmars-d-learn
On 3/5/21 12:24 PM, Jack wrote: Are there some kind of replacement or I have to make my own finalize-like method, once I determine somewhat the application no longer need those resources? destroy() executes the destructor. To my surprise, even though 'c' is not null below, the destructor is

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 20:18:44 UTC, Max Haughton wrote: On Friday, 5 March 2021 at 20:13:54 UTC, Jack wrote: On Friday, 5 March 2021 at 20:10:39 UTC, Max Haughton wrote: On Friday, 5 March 2021 at 20:03:58 UTC, Jack wrote: On Friday, 5 March 2021 at 09:23:29 UTC, Mike Parker wrote: On

Re: Can't I allocate at descontructor?

2021-03-05 Thread Max Haughton via Digitalmars-d-learn
On Friday, 5 March 2021 at 20:13:54 UTC, Jack wrote: On Friday, 5 March 2021 at 20:10:39 UTC, Max Haughton wrote: On Friday, 5 March 2021 at 20:03:58 UTC, Jack wrote: On Friday, 5 March 2021 at 09:23:29 UTC, Mike Parker wrote: On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: [...]

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 20:10:39 UTC, Max Haughton wrote: On Friday, 5 March 2021 at 20:03:58 UTC, Jack wrote: On Friday, 5 March 2021 at 09:23:29 UTC, Mike Parker wrote: On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: The following code returns a memory error. I did notice it did

Re: Can't I allocate at descontructor?

2021-03-05 Thread Max Haughton via Digitalmars-d-learn
On Friday, 5 March 2021 at 20:03:58 UTC, Jack wrote: On Friday, 5 March 2021 at 09:23:29 UTC, Mike Parker wrote: On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: The following code returns a memory error. I did notice it did happens whenever I did a memory allocation. Is this not possible

Re: Can't I allocate at descontructor?

2021-03-05 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 05, 2021 at 08:03:58PM +, Jack via Digitalmars-d-learn wrote: > On Friday, 5 March 2021 at 09:23:29 UTC, Mike Parker wrote: > > On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: > > > The following code returns a memory error. I did notice it did > > > happens whenever I did a

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 09:23:29 UTC, Mike Parker wrote: On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: The following code returns a memory error. I did notice it did happens whenever I did a memory allocation. Is this not possible in the descontrutor? if so, why?

Re: lockstep works with .each, but fails with .map

2021-03-05 Thread realhet via Digitalmars-d-learn
On Friday, 5 March 2021 at 19:26:38 UTC, Jacob Carlborg wrote: On 2021-03-05 19:49, realhet wrote: Why it works with each (or foreach), but not with map? o.O `lockstep` is specifically designed to work with `foreach`. I think `each` has a special case to work with `lockstep`. If you want

Re: lockstep works with .each, but fails with .map

2021-03-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-03-05 19:49, realhet wrote: Why it works with each (or foreach), but not with map? o.O `lockstep` is specifically designed to work with `foreach`. I think `each` has a special case to work with `lockstep`. If you want to use other range functions, you should use `zip` instead of

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 05:42:03 UTC, evilrat wrote: On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: The following code returns a memory error. I did notice it did happens whenever I did a memory allocation. Is this not possible in the descontrutor? if so, why? GC prohibits

lockstep works with .each, but fails with .map

2021-03-05 Thread realhet via Digitalmars-d-learn
Hi What am I doing wrong here? import std.stdio, std.range, std.algorithm, std.uni, std.utf, std.conv, std.typecons, std.array; auto SE(A, B)(in A a, in B b){ return (a-b)^^2; } void main(){ auto a = [1, 2, 3], b = [1, 1, 1]; lockstep(a, b,

Re: dub support for Mac M1?

2021-03-05 Thread tastyminerals via Digitalmars-d-learn
On Thursday, 4 March 2021 at 23:57:25 UTC, kinke wrote: On Thursday, 4 March 2021 at 22:30:17 UTC, tastyminerals wrote: I got a company MacBook with M1 chip and gradually migrate all the stuff from Linux machine. I got precompiled ldc binary installed without any problem now is the time for

Re: tiny alternative to std library

2021-03-05 Thread ryuukk_ via Digitalmars-d-learn
On Friday, 5 March 2021 at 16:54:48 UTC, Kagamin wrote: On Wednesday, 3 March 2021 at 20:54:43 UTC, Anthony Quizon wrote: I'm having some success pulling out small bits of code from other libraries and keeping things minimal and c-style-ish. If you're really ok with minimalism, I'm writing

Re: tiny alternative to std library

2021-03-05 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 3 March 2021 at 20:54:43 UTC, Anthony Quizon wrote: I'm having some success pulling out small bits of code from other libraries and keeping things minimal and c-style-ish. If you're really ok with minimalism, I'm writing such a library https://filebin.net/7gtyh5j01gk1ofly I

Re: Using YMM registers causes an undefined label error

2021-03-05 Thread Rumbu via Digitalmars-d-learn
On Friday, 5 March 2021 at 12:57:43 UTC, z wrote: XMM registers work, but as soon as they are changed into YMM DMD outputs "bad type/size of operands %s" and LDC outputs an "label YMM0 is undefined" error. Are they not supported? To illutrate : https://run.dlang.io/is/IqDHlK By the way, how

Re: D's Continous Changing

2021-03-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 5 March 2021 at 15:54:37 UTC, Paul Backus wrote: The website is *supposed* to keep documentation for old versions around, and allow you to select them using the drop-down menu at the top-right: note that in some cases my website lets you pull old versions too:

Re: D's Continous Changing

2021-03-05 Thread Paul Backus via Digitalmars-d-learn
On Friday, 5 March 2021 at 03:32:35 UTC, harakim wrote: That was pretty sweet. However, it kind of goes to the point of my post. A one-revision difference means the documentation is not accurate for my compiler. I'm not saying the language shouldn't evolve, I'm just saying it might make

Re: Checking for manifest constants

2021-03-05 Thread Petar via Digitalmars-d-learn
On Friday, 5 March 2021 at 08:23:09 UTC, Bogdan wrote: I was using a trick with dmd to check for manifest constants which worked until dmd v2.094. Yesterday I tried it on the latest compiler and it failed with: source/introspection/manifestConstant.d(37,28): Error: need this for name of

Using YMM registers causes an undefined label error

2021-03-05 Thread z via Digitalmars-d-learn
XMM registers work, but as soon as they are changed into YMM DMD outputs "bad type/size of operands %s" and LDC outputs an "label YMM0 is undefined" error. Are they not supported? To illutrate : https://run.dlang.io/is/IqDHlK By the way, how can i use instructions that are not listed in

Re: Checking for manifest constants

2021-03-05 Thread Basile B. via Digitalmars-d-learn
On Friday, 5 March 2021 at 08:23:09 UTC, Bogdan wrote: I was using a trick with dmd to check for manifest constants which worked until dmd v2.094. Yesterday I tried it on the latest compiler and it failed with: source/introspection/manifestConstant.d(37,28): Error: need this for name of

Re: Can't I allocate at descontructor?

2021-03-05 Thread Mike Parker via Digitalmars-d-learn
On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: The following code returns a memory error. I did notice it did happens whenever I did a memory allocation. Is this not possible in the descontrutor? if so, why?

Checking for manifest constants

2021-03-05 Thread Bogdan via Digitalmars-d-learn
I was using a trick with dmd to check for manifest constants which worked until dmd v2.094. Yesterday I tried it on the latest compiler and it failed with: source/introspection/manifestConstant.d(37,28): Error: need this for name of type string source/introspection/type.d(156,13): Error: