Re: D is nice whats really wrong with gc??

2023-12-23 Thread IGotD- via Digitalmars-d-learn
On Monday, 18 December 2023 at 16:44:11 UTC, Bkoie wrote: just look at this i know this is overdesign im just trying to get a visual on how a api can be design im still new though but the fact you can build an api like this and it not break it is amazing. but what is with these ppl and the gc

Re: Request help on allocator.

2023-12-02 Thread IGotD- via Digitalmars-d-learn
On Saturday, 2 December 2023 at 19:13:18 UTC, Vino B wrote: Hi All, Request your help in understanding the below program, with the below program I can allocate 8589934592(8GB) it prints the length 8589934592(8GB) where as my laptop has only 4 GB so the confusion is that how can this program

Re: Single-thread processes

2023-06-29 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 28 June 2023 at 23:46:17 UTC, Cecil Ward wrote: If your program is such that one process will never ever involve multiple threads, because it simply doesn’t apply in your situation, then would it be worthwhile to have a "version (D_SingleThread)" which would get rid of the all-sta

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-04-01 Thread IGotD- via Digitalmars-d-learn
On Saturday, 1 April 2023 at 15:02:12 UTC, Ali Çehreli wrote: Does anyone have documentation on why Rust and Zip does not do thread local by default? I wonder what experience it was based on. I think that would hard to get documentation on the rationale for that decision. Maybe you can ge

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-04-01 Thread IGotD- via Digitalmars-d-learn
On Sunday, 26 March 2023 at 18:25:54 UTC, Richard (Rikki) Andrew Cattermole wrote: Having TLS by default is actually quite desirable if you like your code to be safe without having to do anything extra. As soon as you go into global to the process memory, you are responsible for synchronizatio

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-04-01 Thread IGotD- via Digitalmars-d-learn
On Sunday, 26 March 2023 at 18:25:54 UTC, Richard (Rikki) Andrew Cattermole wrote: Having TLS by default is actually quite desirable if you like your code to be safe without having to do anything extra. As soon as you go into global to the process memory, you are responsible for synchronizatio

Re: Is there such concept of a list in D?

2022-12-19 Thread IGotD- via Digitalmars-d-learn
On Saturday, 10 December 2022 at 15:59:07 UTC, Ali Çehreli wrote: There isn't a single point in favor of linked lists. Yes there is, there are still special cases where linked lists can be a better alternative. Especially a version with intrusive members (with next/prev pointers as members i

Re: Passing a string by reference

2022-11-09 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 8 November 2022 at 12:43:47 UTC, Adam D Ruppe wrote: In fact, ref in general in D is a lot more rare than in languages like C++. The main reason to use it for arrays is when you need changes to the length to be visible to the caller... which is fairly rare. In general many par

Re: Programs in D are huge

2022-08-19 Thread IGotD- via Digitalmars-d-learn
On Friday, 19 August 2022 at 11:18:48 UTC, bauss wrote: It's one thing D really misses, but is really hard to implement when it wasn't thought of to begin with. It should have been implemented alongside functions that may change between languages and cultures. I guess we have another task f

Re: Programs in D are huge

2022-08-19 Thread IGotD- via Digitalmars-d-learn
On Thursday, 18 August 2022 at 17:15:12 UTC, rikki cattermole wrote: Unicode support in Full D isn't complete. There is nothing in phobos to even change case correctly! Both are limited if you care about certain stuff like non-latin based languages like Turkic. I think full D is fine for te

Re: Programs in D are huge

2022-08-18 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 17 August 2022 at 17:25:51 UTC, Ali Çehreli wrote: On 8/17/22 09:28, Diego wrote: > I'm writing a little terminal tool, so i think `-betterC` is the best > and simple solution in my case. It depends on what you mean with terminal tool bun in general, no, full features of D is the

Re: vectorization of a simple loop -- not in DMD?

2022-07-11 Thread IGotD- via Digitalmars-d-learn
On Monday, 11 July 2022 at 18:19:41 UTC, max haughton wrote: The dmd backend is ancient, it isn't really capable of these kinds of loop optimizations. I've said it several times before. Just depreciate the the DMD backend, it's just not up to the task anymore. This is not criticism against

Re: Why are structs and classes so different?

2022-05-16 Thread IGotD- via Digitalmars-d-learn
On Sunday, 15 May 2022 at 16:08:01 UTC, Mike Parker wrote: `scope` in a class variable declaration will cause it to the class to be allocated on the stack. Common practice is that a class has class members itself. So where are they allocated? Most likely is only the top class that is on t

Re: decimal type in d

2022-05-16 Thread IGotD- via Digitalmars-d-learn
On Sunday, 15 May 2022 at 13:26:30 UTC, vit wrote: Hello, I want read decimal type from sql db, do some arithmetic operations inside D program and write it back to DB. Result need to be close to result as if this operations was performed in sql DB. Something like C# decimal. Exists this kind of

Re: How to get an IP address from network interfaces

2022-04-22 Thread IGotD- via Digitalmars-d-learn
On Friday, 22 April 2022 at 12:58:24 UTC, H. S. Teoh wrote: Why would you not want to use OS APIs? 1. Portability 2. Language APIs are usually much better to use that the OS APIs, like Berkeley sockets for example.

Re: How to get an IP address from network interfaces

2022-04-22 Thread IGotD- via Digitalmars-d-learn
On Thursday, 21 April 2022 at 07:20:30 UTC, dangbinghoo wrote: [... Berkley sockets network code ...] It really makes me sad when I see this. D has some native networking API but unfortunately you have go to the OS API to have this basic functionality. D should really expand its own API so

Re: Why do immutable variables need reference counting?

2022-04-11 Thread IGotD- via Digitalmars-d-learn
On Sunday, 10 April 2022 at 23:19:47 UTC, rikki cattermole wrote: immutable isn't tied to lifetime semantics. It only says that this memory will never be modified by anyone during its lifetime. Anyway, the real problem is with const. Both mutable and immutable become it automatically. I w

Re: I like dlang but i don't like dub

2022-03-22 Thread IGotD- via Digitalmars-d-learn
On Friday, 18 March 2022 at 18:16:51 UTC, Ali Çehreli wrote: The first time I learned about pulling in dependencies terrified me. (This is the part I realize I am very different from most other programmers.) I am still terrified that my dependency system will pull in a tree of code that I hav

Re: Is there an equivavlent to C# boxing in D?

2022-02-12 Thread IGotD- via Digitalmars-d-learn
On Saturday, 12 February 2022 at 00:41:22 UTC, H. S. Teoh wrote: How about this? final class Boxed(T) { T payload; alias payload this; // caveat: probably not a good idea in general this(T val) { payload = val; } } Boxed!int i = new Boxed!int(123); int j = i; // hoo

Is there an equivavlent to C# boxing in D?

2022-02-11 Thread IGotD- via Digitalmars-d-learn
If you want to store a value type on the heap in D you just use "new" and a pointer to the type. The same thing in C# would be to wrap the value type into an object. However when you do that automatic conversion without a cast seems not to be possible (C# also have a dynamic type that might sol

Re: How to loop through characters of a string in D language?

2021-12-10 Thread IGotD- via Digitalmars-d-learn
On Friday, 10 December 2021 at 06:24:27 UTC, Rumbu wrote: Since it seems there is a contest here: ```d "abc;def;ghi".split(';').join(); ``` :) Would that become two for loops or not?

Re: How to test if a string is pointing into read-only memory?

2021-10-12 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 12 October 2021 at 09:20:42 UTC, Elronnd wrote: There is no good way. Can't it be done using function overloading?

Re: Reference Counted Class

2021-07-14 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 17:52:16 UTC, sclytrack wrote: Would reference counted classes by default be too much of a change? Is it a bad idea? Currently there a changes in the language where you can avoid the reference count, right? Combination both the rc and the stop-the-world gc, for the

Re: Are D classes proper reference types?

2021-06-27 Thread IGotD- via Digitalmars-d-learn
On Sunday, 27 June 2021 at 07:48:22 UTC, Ola Fosheim Grøstad wrote: Which languages use fat pointers? C++ may use it (but is not required to). Probably about all managed languages. One common method is a that it is actually an identifier it is used in a hash table. Then you can find all so

Re: Are D classes proper reference types?

2021-06-25 Thread IGotD- via Digitalmars-d-learn
On Friday, 25 June 2021 at 20:22:24 UTC, Ola Fosheim Grøstad wrote: Hm. Not sure if I follow, I think we are talking about stuffing bits into the counter and not the address? Then I misunderstood. If it's a counter it should be fine. But fat pointers are 16 bytes, so quite expensive. Yes

Re: Are D classes proper reference types?

2021-06-25 Thread IGotD- via Digitalmars-d-learn
On Friday, 25 June 2021 at 17:37:13 UTC, IGotD- wrote: You cannot use the most significant bit as it will not work with some 32-bit systems. Linux with a 3G kernel position for example. Better to use the least significant bit as all allocated memory is guaranteed to be aligned. Regardless thi

Re: Are D classes proper reference types?

2021-06-25 Thread IGotD- via Digitalmars-d-learn
On Friday, 25 June 2021 at 07:17:20 UTC, kinke wrote: Wrt. manual non-heap allocations (stack/data segment/emplace etc.), you could e.g. reserve the most significant bit of the counter to denote such instances and prevent them from being free'd (and possibly finalization/destruction too; this w

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 16:20:19 UTC, Ola Fosheim Grøstad wrote: I don't really agree with this, most of the interesting things for specifying UIs are happening in web-frameworks/web-standards nowadays. But it doesn't matter... If I were to make a desktop application in D today then I wou

Re: How long does the context of a delegate exist?

2021-05-27 Thread IGotD- via Digitalmars-d-learn
On Thursday, 27 May 2021 at 18:13:17 UTC, Adam D. Ruppe wrote: If the delegate is created by the GC and stored it will still be managed by the GC, along with its captured vars. As long as the GC can see the delegate in your example you should be OK. But if it is held on to by a C or OS lib,

Re: Remove own post from forum

2021-05-10 Thread IGotD- via Digitalmars-d-learn
On Monday, 10 May 2021 at 03:36:02 UTC, Виталий Фадеев wrote: I have missformated post in thread: https://forum.dlang.org/thread/kwpqyzwgczdpzgsvo...@forum.dlang.org Say, please, how to remove own post from this forum ? Welcome to the 90s, this forum is essentially a front end to a news grou

Re: Initializing D runtime and executing module and TLS ctors for D libraries

2021-01-30 Thread IGotD- via Digitalmars-d-learn
On Saturday, 30 January 2021 at 12:28:16 UTC, Ali Çehreli wrote: I wonder whether doing something in the runtime is possible. For example, it may be more resilient and not crash when suspending a thread fails because the thread may be dead already. However, studying the runtime code around

Re: is core Mutex lock "fast"?

2021-01-26 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 21:09:34 UTC, Steven Schveighoffer wrote: The only item that is read without being locked is owner. If you change that to an atomic read and write, it should be fine (and is likely fine on x86* without atomics anyway). All the other data is protected by the act

Re: is core Mutex lock "fast"?

2021-01-26 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 18:07:06 UTC, ludo wrote: Hi guys, still working on old D1 code, to be updated to D2. At some point the previous dev wrote a FastLock class. The top comment is from the dev himself, not me. My question is after the code. --- class FastLock { protected

Re: Initializing D runtime and executing module and TLS ctors for D libraries

2021-01-24 Thread IGotD- via Digitalmars-d-learn
On Sunday, 24 January 2021 at 03:59:26 UTC, Ali Çehreli wrote: That must be the case for threads started by D runtime, right? It sounds like I must call rt_moduleTlsCtor explicitly for foreign threads. It's still not clear to me which modules' TLS variables are initialized (copied over). Only

Re: Initializing D runtime and executing module and TLS ctors for D libraries

2021-01-23 Thread IGotD- via Digitalmars-d-learn
On Sunday, 24 January 2021 at 00:24:55 UTC, Ali Çehreli wrote: One question I have is, does rt_init already do thread_attachThis? I ask because I have a library that is loaded by Python and things work even *without* calling thread_attachThis. During rt_init in the main thread, thread_att

Re: opIndex negative index?

2021-01-21 Thread IGotD- via Digitalmars-d-learn
On Thursday, 21 January 2021 at 15:49:02 UTC, IGotD- wrote: On Thursday, 21 January 2021 at 14:47:38 UTC, cerjones wrote: ohreally? I thought you were talking about the built in arrays. Since you create your own implementation just as you showed you are basically free to do anything. That

Re: opIndex negative index?

2021-01-21 Thread IGotD- via Digitalmars-d-learn
On Thursday, 21 January 2021 at 14:47:38 UTC, cerjones wrote: ohreally? I thought you were talking about the built in arrays.

Re: opIndex negative index?

2021-01-21 Thread IGotD- via Digitalmars-d-learn
On Thursday, 21 January 2021 at 14:00:28 UTC, cerjones wrote: I have an iterator that steps along a 2D vector path command by command and uses opIndex to give access to the points for the current command. The issue is that there's a shared point between commands, so when the iterator is on a gi

Re: Why many programmers don't like GC?

2021-01-15 Thread IGotD- via Digitalmars-d-learn
On Friday, 15 January 2021 at 15:50:50 UTC, H. S. Teoh wrote: DMD *never* frees anything. *That's* part of why it's so fast; it completely drops the complexity of tracking free lists and all of that jazz. That's also why it's a gigantic memory hog that can be a big embarrassment when run o

Re: Why many programmers don't like GC?

2021-01-15 Thread IGotD- via Digitalmars-d-learn
On Friday, 15 January 2021 at 14:24:40 UTC, welkam wrote: No. And it will never will. Currently DMD uses custom allocator for almost everything. It works as follows. Allocate a big chunk(1MB) of memory using malloc. Have a internal pointer that points to the beginning of unallocated memory. W

Re: Why many programmers don't like GC?

2021-01-14 Thread IGotD- via Digitalmars-d-learn
On Thursday, 14 January 2021 at 15:18:28 UTC, ddcovery wrote: I understand perfectly the D community people that needs to work without GC: **it is not snobbish**: it is a real need. But not only a "need"... sometimes it is basically the way a team wants to work: explicit memory management

Re: properly passing strings to functions? (C++ vs D)

2021-01-12 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 12 January 2021 at 18:12:14 UTC, Q. Schroll wrote: Did you consider `in`? It will do that in some time and do it now with -preview=in. If you're using `const`, in almost all cases, `in` will work, too, and be better (and shorter). Has the redesignation of "in" like in the preview

Re: properly passing strings to functions? (C++ vs D)

2021-01-11 Thread IGotD- via Digitalmars-d-learn
On Monday, 11 January 2021 at 14:12:57 UTC, zack wrote: D: void myPrint(string text){ ... } void myPrintRef(ref string text) { ... } In D strings are immutable so there will be no copying when passing as function parameters. Strings are essentially like slices when passing them. I usually

Re: Avoid deallocate empty arrays?

2020-12-17 Thread IGotD- via Digitalmars-d-learn
On Thursday, 17 December 2020 at 18:42:54 UTC, H. S. Teoh wrote: Are you sure? My understanding is that capacity is always set to 0 when you shrink an array, in order to force reallocation when you append a new element. The reason is this: int[] data = [ 1, 2, 3, 4, 5 ]; int

Re: Avoid deallocate empty arrays?

2020-12-17 Thread IGotD- via Digitalmars-d-learn
On Thursday, 17 December 2020 at 17:46:59 UTC, Steven Schveighoffer wrote: This isn’t correct. Can you post the code that led you to believe this? -Steve Sure. import std.algorithm; import std.typecons; import std.stdio; struct Buffer { this(size_t size) {

Re: Avoid deallocate empty arrays?

2020-12-17 Thread IGotD- via Digitalmars-d-learn
On Thursday, 17 December 2020 at 16:46:47 UTC, Q. Schroll wrote: On Thursday, 17 December 2020 at 16:11:37 UTC, IGotD- wrote: It's common using arrays for buffering Outside of CTFE, use an Appender.¹ Unless you're having a const/immutable element type, Appender can shrink and reuse space.² I

Avoid deallocate empty arrays?

2020-12-17 Thread IGotD- via Digitalmars-d-learn
It's common using arrays for buffering, that means constantly adding elements and empty the elements. I have seen that when the number of elements is zero, the array implementation deallocates the array which is shown with capacity is zero. This of course leads to constant allocation and deallo

Re: low-latency GC

2020-12-06 Thread IGotD- via Digitalmars-d-learn
On Sunday, 6 December 2020 at 15:44:32 UTC, Ola Fosheim Grøstad wrote: It was more a hypothetical, as read barriers are too expensive. But write barriers should be ok, so a single-threaded incremental collector could work well if D takes a principled stance on objects not being 'shared' not b

Re: low-latency GC

2020-12-06 Thread IGotD- via Digitalmars-d-learn
On Sunday, 6 December 2020 at 11:07:50 UTC, Ola Fosheim Grostad wrote: ARC can be done incrementally, we can do it as a library first and use a modified version existing GC for detecting failed borrows at runtime during testing. But all libraries that use owning pointers need ownership to be

Re: converting D's string to use with C API with unicode

2020-12-05 Thread IGotD- via Digitalmars-d-learn
On Saturday, 5 December 2020 at 20:12:52 UTC, IGotD- wrote: On Saturday, 5 December 2020 at 19:51:14 UTC, Jack wrote: So in D I have a struct like this: struct ProcessResult { string[] output; bool ok; } in order to use output from C WINAPI with unicode, I need to convert ea

Re: converting D's string to use with C API with unicode

2020-12-05 Thread IGotD- via Digitalmars-d-learn
On Saturday, 5 December 2020 at 19:51:14 UTC, Jack wrote: So in D I have a struct like this: struct ProcessResult { string[] output; bool ok; } in order to use output from C WINAPI with unicode, I need to convert each string to wchar* so that i can acess it from C with wchar

Re: Development: Work vs Lazy Programmers... How do you keep sanity?

2020-12-03 Thread IGotD- via Digitalmars-d-learn
On Thursday, 3 December 2020 at 15:18:31 UTC, matheus wrote: Hi, I didn't know where to post this and I hope this is a good place. I'm a lurker in this community and I read a lot of discussions on this forum and I think there a lot of smart people around here. So I'd like to know if any o

Re: Druntime undefined references

2020-11-02 Thread IGotD- via Digitalmars-d-learn
On Monday, 2 November 2020 at 10:50:06 UTC, Severin Teona wrote: Hi guys! I build the druntime for an ARM Cortex-M based microcontroller and I trying to create an application and link it with the druntime. I am also using TockOS[1], which does not implement POSIX thread calls and other OS-dep

Re: Looking for a Simple Doubly Linked List Implementation

2020-10-29 Thread IGotD- via Digitalmars-d-learn
On Thursday, 29 October 2020 at 22:02:52 UTC, Paul Backus wrote: I'm pretty sure the post you replied to is spam. Yes, when I read the post again it is kind of hollow.

Re: Looking for a Simple Doubly Linked List Implementation

2020-10-29 Thread IGotD- via Digitalmars-d-learn
On Thursday, 29 October 2020 at 18:06:55 UTC, xpaceeight wrote: https://forum.dlang.org/post/bpixuevxzzltiybdr...@forum.dlang.org It contains the data and a pointer to the next and previous linked list node. This is given as follows. struct Node { int data; struct Node *prev; struct Node *next

Re: What is the difference between enum and shared immutable?

2020-10-29 Thread IGotD- via Digitalmars-d-learn
On Thursday, 29 October 2020 at 16:45:51 UTC, Ali Çehreli wrote: import std; immutable string p; shared static this() { p = environment["PATH"]; // <-- Run time } Just to clarify, immutable is allowed to be initialized in ctors but not anything later than that? Moving p = environment["P

Re: What is the difference between enum and shared immutable?

2020-10-29 Thread IGotD- via Digitalmars-d-learn
On Thursday, 29 October 2020 at 12:21:19 UTC, Ola Fosheim Grøstad wrote: You can test this with is(TYPE1==TYPE2) is(shared(immutable(int))==immutable(int)) So I got that to true, which means that shared immutable is exactly the same as immutable. Shared is implicit for immutable which makes

Re: What is the difference between enum and shared immutable?

2020-10-28 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 21:54:19 UTC, Jan Hönig wrote: shared immutable x = 1; Is there a point to add shared to an immutable? Aren't immutable implicitly also shared?

Unexpected behaviour using remove on char[]

2020-10-25 Thread IGotD- via Digitalmars-d-learn
I have a part in my code that use remove buffer.remove(tuple(0, size)); with char[] buffer What I discovered is that remove doesn't really remove size number of bytes but also removed entire multibyte characters and consider that one step. The result was of course that I got out of bounds e

Re: More elaborate asserts in unittests?

2020-10-21 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 21 October 2020 at 23:54:41 UTC, bachmeier wrote: Click the "Improve this page" link in the upper right corner and add what you think needs to be there. Those PRs usually get a fast response. Will do, thank you for the direction.

Re: More elaborate asserts in unittests?

2020-10-21 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 21 October 2020 at 22:41:42 UTC, Adam D. Ruppe wrote: try compiling with dmd -checkaction=context Thanks, that was simple and it worked. Speaking of this, shouldn't this be documented here for example. https://dlang.org/spec/unittest.html Just adding a friendly tip that -chec

More elaborate asserts in unittests?

2020-10-21 Thread IGotD- via Digitalmars-d-learn
When an assert fails in a unittest, I only get which line that failed. However, it would be very useful to see what the values are on either side of the unary boolean expression. Is this possible?

Re: Druntime without pthreads?

2020-10-20 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 20 October 2020 at 16:58:12 UTC, Severin Teona wrote: Hi guys. I have a curiosity, regarding [1] - I had encountered some "undefined reference" errors when trying to link the druntime (compiled for an embedded architecture) without some implementation of the POSIX thread calls (an

Re: Undefined references in Druntime for microcontrollers

2020-10-19 Thread IGotD- via Digitalmars-d-learn
On Monday, 19 October 2020 at 06:25:17 UTC, Severin Teona wrote: - 'munmap' - 'clock_gettime' - `pthread_mutex_trylock' etc. These are typically calls found in a Unix system, Linux for example. In a microcontroller you will likely not support these at all except clock_gettime. You need to

Re: why do i need an extern(C): here?

2020-10-15 Thread IGotD- via Digitalmars-d-learn
On Thursday, 15 October 2020 at 21:29:59 UTC, WhatMeWorry wrote: I've go a small DLL and a test module both written in D. Why do I need to use the extern(C)? Shouldn't both sides be using D name wrangling? You have answered your own question. If you're not using extern(C), D just like C+

Re: Link Time Optimization Bitcode File Format

2020-10-06 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 6 October 2020 at 16:46:28 UTC, Severin Teona wrote: Hi all, I am trying to build the druntime with the 'ldc-build-runtime' tool for microcontrollers (using the arm-none-eabi-gcc compiler) and therefore the size of the druntime should be as little as possible. One solution I had w

Re: Taking arguments by value or by reference

2020-10-04 Thread IGotD- via Digitalmars-d-learn
On Saturday, 3 October 2020 at 23:00:46 UTC, Anonymouse wrote: I'm passing structs around (collections of strings) whose .sizeof returns 432. The readme for 2.094.0 includes the following: This release reworks the meaning of in to properly support all those use cases. in parameters will now b

Re: What classification should shared objects in qeued thread pools have?

2020-10-01 Thread IGotD- via Digitalmars-d-learn
On Thursday, 1 October 2020 at 14:12:24 UTC, Ola Fosheim Grøstad wrote: Also, atomic operations on members do not ensure the integrity of the struct. For that you need something more powerful (complicated static analysis or transactional memory). I'm very wary of being able to cast away shar

Re: What classification should shared objects in qeued thread pools have?

2020-09-30 Thread IGotD- via Digitalmars-d-learn
On Thursday, 1 October 2020 at 00:00:06 UTC, mw wrote: I think using `shared` is the D's encouraged way. If there is a better way do this in D, I'd want to know it too. I think that the shared in shared structs should not be transitive to members of the struct. The compiler should not enfo

What classification should shared objects in qeued thread pools have?

2020-09-30 Thread IGotD- via Digitalmars-d-learn
I have a system that heavily relies on thread pools. Typically this is used with items that are put on a queue and then a thread pool system process this queue. The thread pool can be configured to process the items in whatever parallel fashion it wants but usually it is set to one, that means

Re: Memory management

2020-09-29 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 29 September 2020 at 15:47:09 UTC, Ali Çehreli wrote: I am not a language expert but I can't imagine how the compiler knows whether an event will happen at runtime. Imagine a server program allocates memory for a client. Let's say, that memory will be deallocated when the client l

Cmake dependency scanning

2020-09-27 Thread IGotD- via Digitalmars-d-learn
Do we have any D dependency scanning available for D in Cmake, just like the built in C/C++ dependency scanner which is handy, or do you have to use the option to compile everything into one module (--deps=full)? I have some problems when there is a mix of inlining and calling the separately

Re: Methods for expanding class in another class/struct

2020-09-27 Thread IGotD- via Digitalmars-d-learn
On Saturday, 26 September 2020 at 11:30:23 UTC, k2aj wrote: It does work, the problem is that scoped returns a Voldemort type, so you have to use typeof(scoped!SomeClass(someConstructorArgs)) to declare a field. Gets really annoying when doing it with any class that doesn't have a zero-argum

Re: Methods for expanding class in another class/struct

2020-09-26 Thread IGotD- via Digitalmars-d-learn
One thing that struck me looking at the source code of scoped, would scoped work inside a class and not only for stack allocations?

Methods for expanding class in another class/struct

2020-09-26 Thread IGotD- via Digitalmars-d-learn
We know that classes are all reference typed so that classes must be allocated on the heap. However, this memory could be taken from anywhere so basically this memory could be a static array inside the class. This is pretty much what the scoped template does when allocating a class on the stack

Re: Building LDC runtime for a microcontroller

2020-09-19 Thread IGotD- via Digitalmars-d-learn
On Friday, 18 September 2020 at 07:44:50 UTC, Dylan Graham wrote: I use D in an automotive environment (it controls parts of the powertrain, so yeah there are cars running around on D) on various types of ARM Cortex M CPUs, I think this will be the best way to extend D to those platforms.

Re: vibe.d: How to get the conent of a file upload ?

2020-09-19 Thread IGotD- via Digitalmars-d-learn
On Saturday, 19 September 2020 at 19:27:40 UTC, Steven Schveighoffer wrote: I used Kai's book, and yeah, you have to do things the vibe way. But most web frameworks are that way I think. Do you have a reference to this book (web link, ISBN)?

Re: Proper way to exit with specific exit code?

2020-09-18 Thread IGotD- via Digitalmars-d-learn
On Friday, 18 September 2020 at 05:02:21 UTC, H. S. Teoh wrote: That's the obvious solution, except that actually implementing it is not so simple. When you have multiple threads listening for each other and/or doing work, there is no 100% guaranteed way of cleanly shutting all of them down

Re: Proper way to exit with specific exit code?

2020-09-17 Thread IGotD- via Digitalmars-d-learn
On Thursday, 17 September 2020 at 14:58:48 UTC, drathier wrote: What's the proper way to exit with a specific exit code? I found a bunch of old threads discussing this, making sure destructors run and the runtime terminates properly, all of which seemingly concluding that it's sad that there i

Re: Building LDC runtime for a microcontroller

2020-09-07 Thread IGotD- via Digitalmars-d-learn
On Monday, 7 September 2020 at 19:12:59 UTC, aberba wrote: How about an alternative runtime + standard library for embedded systems...with a least bare minimum. I've seen a number of efforts to get D to run in those environments but almost none of them is packaged for others to consume. Ada

Re: Building LDC runtime for a microcontroller

2020-09-07 Thread IGotD- via Digitalmars-d-learn
On Monday, 7 September 2020 at 15:23:28 UTC, Severin Teona wrote: I would also appreciate any advice regarding ways to build or create a small runtime for microcontrollers (runtime that can fit in the memory of a microcontroller). Thank you very much, Teona [1]: https://wiki.dlang.org/Buildi

Re: miscellaneous array questions...

2020-07-21 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 13:23:32 UTC, Adam D. Ruppe wrote: But the array isn't initialized in the justification scenario. It is accessed through a null pointer and the type system thinks it is fine because it is still inside the static limit. At run time, the cpu just sees access to memo

Re: miscellaneous array questions...

2020-07-21 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 12:34:14 UTC, Adam D. Ruppe wrote: With the null `a`, the offset to the static array is just 0 + whatever and the @safe mechanism can't trace that. So the arbitrary limit was put in place to make it more likely that such a situation will hit a protected page and s

Re: miscellaneous array questions...

2020-07-21 Thread IGotD- via Digitalmars-d-learn
On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: 2) "The total size of a static array cannot exceed 16Mb" What limits this? And with modern systems of 16GB and 32GB, isn't 16Mb excessively small? (an aside: shouldn't that be 16MB in the reference instead of 16Mb? that is, Doesn't

Re: Good way to send/receive UDP packets?

2020-07-18 Thread IGotD- via Digitalmars-d-learn
On Saturday, 18 July 2020 at 16:00:09 UTC, Dukc wrote: I have a project where I need to take and send UDP packets over the Internet. Only raw UDP - my application uses packets directly, with their starting `[0x5a, packet.length.to!ubyte]` included. And only communication with a single address,

Re: What's the point of static arrays ?

2020-07-09 Thread IGotD- via Digitalmars-d-learn
On Thursday, 9 July 2020 at 18:51:47 UTC, Paul Backus wrote: Note that using VLAs in C is widely considered to be bad practice, and that they were made optional in the C11 standard. If you want to allocate an array on the stack, the best way is to use a static array for size below a predeter

Re: What's the point of static arrays ?

2020-07-09 Thread IGotD- via Digitalmars-d-learn
On Thursday, 9 July 2020 at 12:12:06 UTC, wjoe wrote: ... Static arrays are great because as already mentioned, they are allocated on the stack (unless it is global variable something, then it ends up in the data segment or TLS area). As C/C++ now allows dynamically sized static arrays (for

How to ensure template function can be processed during compile time

2020-07-08 Thread IGotD- via Digitalmars-d-learn
I have the following functions in C++ template inline constexpr size_t mySize(const T &v) { return sizeof(v) + 42; } template inline constexpr size_t mySize() { return sizeof(T) + 42; } The constexpr ensures that it will be calculated to a compile time constant otherwise the build wil

Re: Template function specialization doesn't work

2020-07-07 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 20:14:19 UTC, IGotD- wrote: Thank you, that worked and now it picked the correct overloaded function. I don't understand why and it is a bit counter intuitive. Why two template arguments as I'm not even us using U? If you look at the article https://dlang.org/art

Re: Template function specialization doesn't work

2020-07-07 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 20:05:37 UTC, Steven Schveighoffer wrote: On 7/7/20 4:04 PM, Steven Schveighoffer wrote: Have you tried (T: U[], U)(ref T[] s) ? Ugh... (T: U[], U)(ref T s) -Steve Thank you, that worked and now it picked the correct overloaded function. I don't understand why a

Re: Template function specialization doesn't work

2020-07-07 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 19:53:30 UTC, IGotD- wrote: ... I also forgot to mention that the overloadedFunction is used in a variadic template function. void processAll(T...)(ref T t) { foreach(ref v; t) { overloadedFunction(v); } }

Template function specialization doesn't work

2020-07-07 Thread IGotD- via Digitalmars-d-learn
I have two template functions void overloadedFunction(T)(ref T val) { ... } void overloadedFunction(T : T[])(ref T[] s) { ... } Obviously the second should be used when the parameter is a slice of any type, and the first should be used in other cases. However this doesn't hap

Delegates and C++ FFI lifetimes

2020-07-02 Thread IGotD- via Digitalmars-d-learn
I have this runtime written in C++ that allows callbacks for various functionality. In C++ the callbacks are stored as a function pointer together with a void* that is passed as first argument. The void* can be a lot of things, for example the class pointer in C++. However, this is a bit limite

Re: Generating struct .init at run time?

2020-07-02 Thread IGotD- via Digitalmars-d-learn
On Thursday, 2 July 2020 at 07:51:29 UTC, Ali Çehreli wrote: Both asserts pass: S.init is 800M and is embedded into the compiled program. Not an answer to your problem but what on earth are those extra 800MB? The array size is 8MB so if the program would just copy the data it would just t

Re: What would be the advantage of using D to port some games?

2020-06-24 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 19:28:15 UTC, matheus wrote: To see how the game could fit/run in D, like people are porting some of those games to Rust/Go and so on. When you mention "advantage", advantage compared to what? To the original language the game was written. For example taking

Re: What would be the advantage of using D to port some games?

2020-06-24 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 18:53:34 UTC, matheus wrote: What I'd like to know from the experts is: What would be the advantage of using D to port such games? Can you elaborate your question a little bit more. Why would you want to port existing game code to another language to begin w

Re: Read to stdout doesn't trigger correct action

2020-06-22 Thread IGotD- via Digitalmars-d-learn
On Monday, 22 June 2020 at 14:27:18 UTC, Steven Schveighoffer wrote: I'm sure if there is a clib that doesn't work with this, it is a bug with druntime, and should be addressed. I don't know enough about the exact functionality to be able to write such a bug report, but you probably should if

Read to stdout doesn't trigger correct action

2020-06-22 Thread IGotD- via Digitalmars-d-learn
I've done some adaptations to druntime for another C library that isn't currently supported. Obtaining the FILE* structure of the clib is done via a function call rather than global variables. However this function call is never triggered when issuing a writeln function call. The FILE* structur

Re: Does std.net.curl: download have support for callbacks?

2020-06-21 Thread IGotD- via Digitalmars-d-learn
On Thursday, 18 June 2020 at 01:15:00 UTC, dangbinghoo wrote: Don't worry, almost ALL GUI FRAMEWORK in the world IS NOT THREAD SAFE, the wellknow Qt and Gtk, and even morden Android and the java Swing. binghoo dang You can certainly download in another thread in Qt. However, you are

Re: Garbage Collection Issue

2020-06-01 Thread IGotD- via Digitalmars-d-learn
On Monday, 1 June 2020 at 12:37:05 UTC, Steven Schveighoffer wrote: I was under the impression that TLS works by altering a global pointer during the context switch. I didn't think accessing a variable involved a system call. For sure they are slower than "normal" variables, but how much sl

  1   2   >