Re: Help me decide D or C

2019-08-02 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 18:38:02 UTC, Alexandre wrote: Hi everyone, I would like an honest opinion. I have a beginner level (able to do very small programs) in a few languages such as python, go, C, guile(scheme) and common lisp. I want to pick a language and go deep with it and focus

Why same pointer type for GC and manual memory?

2019-11-13 Thread IGotD- via Digitalmars-d-learn
I'm trying to find the rationale why GC pointers (should be names managed pointers) are using the exact same type as any other pointer. Doesn't this limit the ability to change the default GC type? Doesn't this confusion make GC pointers just as unsafe as raw pointers? Has there been any

Re: Why same pointer type for GC and manual memory?

2019-11-13 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 13 November 2019 at 15:30:33 UTC, Dukc wrote: I'm not 100% sure what managed pointers mean -Are they so that you can't pass them to unregistered memory? A library solution would likely do -wrap the pointer in a struct and make it @system to extract it's pointer as "raw". So you

Re: Why same pointer type for GC and manual memory?

2019-11-15 Thread IGotD- via Digitalmars-d-learn
On Friday, 15 November 2019 at 08:58:43 UTC, user1234 wrote: On Wednesday, 13 November 2019 at 11:07:12 UTC, IGotD- wrote: I'm trying to find the rationale why GC pointers (should be names managed pointers) are using the exact same type as any other pointer. Doesn't this limit the ability to

Final necessary for inline optimization?

2019-10-19 Thread IGotD- via Digitalmars-d-learn
When I'm playing around with different D compilers I get different results regarding class method inlining. According most information I have seen, you must declare a class method final for the compiler to be able inline the method otherwise it will be a virtual table call. Take this simple

Special integer operations

2019-10-28 Thread IGotD- via Digitalmars-d-learn
I'm trying to find if D has any built in special integer operations like bit reverse, population count, count leading zeroes, count trailing zeroes. Many ISAs have dedicated instructions for these kinds of operations. I haven't found any of these in the documentation, either implemented as

Re: About the in expression, Why can't use with array.

2019-10-25 Thread IGotD- via Digitalmars-d-learn
On Friday, 25 October 2019 at 20:44:18 UTC, Dennis wrote: On Friday, 25 October 2019 at 19:49:05 UTC, Ali Çehreli wrote: I'm still not completely sold on the whole idea though because it's not a clear win. Do others see other advantages in other places like templates? For example, could

Re: About the in expression, Why can't use with array.

2019-10-25 Thread IGotD- via Digitalmars-d-learn
On Thursday, 24 October 2019 at 12:58:11 UTC, lili wrote: Hi: In Dlang where is strange design. The in expression can only use to associative array, why array can not use in expression. I don't see much of a problem why this couldn't be implemented as long as the user understands the

Re: Leak-detection of references to scoped class instances

2019-11-29 Thread IGotD- via Digitalmars-d-learn
On Thursday, 28 November 2019 at 21:49:09 UTC, Per Also, what happens if `C` doesn't fit on the stack? This is OS specific I think. For example on Linux at the end of the stack there is a guard page and when you hit it the process will segfault.

Re: Why same pointer type for GC and manual memory?

2019-11-19 Thread IGotD- via Digitalmars-d-learn
On Friday, 15 November 2019 at 11:32:07 UTC, Basile B. wrote: TBH I see your point but D is a system programming language. Even if there's a GC you can also do Manual Memory Mangement (sometimes you'll see "MMM "to refer to that in the forums), RC, and you can also write custom machine code

Re: How to simulate Window's "Press any key to continue..."

2019-11-22 Thread IGotD- via Digitalmars-d-learn
On Friday, 22 November 2019 at 04:45:21 UTC, Mike Parker wrote: On Friday, 22 November 2019 at 04:22:07 UTC, FireController#1847 wrote: Right, but readln will only wait until the user presses the delimiter (by default Enter/Return). I want it to wait until ANY key is pressed, not a specific

Re: Why is the fPIC switch missing?

2019-09-23 Thread IGotD- via Digitalmars-d-learn
On Monday, 23 September 2019 at 08:19:35 UTC, Boris Carvajal wrote: On Monday, 23 September 2019 at 01:31:03 UTC, Emmanuelle wrote: Hello. My problem is exactly what it says on the title: my dmd (windows 7, x64) doesn't seem to have -fPIC: I think it's not needed. The generated code on

Re: Dynamic Arrays as Stack and/or Queue

2019-10-07 Thread IGotD- via Digitalmars-d-learn
On Monday, 7 October 2019 at 17:36:09 UTC, Ferhat Kurtulmuş wrote: I'm not talking about memory deletion. I'm talking about push, pop, enqueue, and dequeue behavior. I'd assume in a garbage collected language letting the reference float off should be picked up by the GC. I'm sorry. Writing

Re: How does D distnguish managed pointers from raw pointers?

2019-10-04 Thread IGotD- via Digitalmars-d-learn
On Friday, 4 October 2019 at 15:03:04 UTC, Johan Engelen wrote: On Thursday, 3 October 2019 at 14:21:37 UTC, Andrea Fontana wrote: In D arrays are fat pointer instead: int[10] my_array; my_array is actually a pair ptr+length. ``` int[10] my_static_array; int[] my_dynamic_array; ```

How does D distnguish managed pointers from raw pointers?

2019-10-03 Thread IGotD- via Digitalmars-d-learn
According to the GC documentation this code snippet char* p = new char[10]; char* q = p + 6; // ok q = p + 11; // error: undefined behavior q = p - 1; // error: undefined behavior suggests that char *p is really a "fat pointer" with size information. However, if get some memory

Re: selective tests

2019-10-12 Thread IGotD- via Digitalmars-d-learn
On Saturday, 12 October 2019 at 09:52:59 UTC, Jonathan M Davis wrote: On Saturday, October 12, 2019 2:18:02 AM MDT Martin Brezeln via Digitalmars- d-learn wrote: Is it possible to execute only certain modules or tests which are defined in certain directories? For example, in go one can run

Porting D to custom OS

2020-02-22 Thread IGotD- via Digitalmars-d-learn
I'm trying to find information how to port D, especially the D runtime to a proprietary OS. The OS support seems to be scattered around several files with a lot version (OS) switches. This makes kind of hard to understand what you have to implement. Also, what happens if you only have partial

Re: Porting D to custom OS

2020-02-22 Thread IGotD- via Digitalmars-d-learn
On Saturday, 22 February 2020 at 15:18:09 UTC, kinke wrote: I'd suggest to first hack the compiler, so that it doesn't predefine the host OS, but a new version for your OS (and check whether predefining `version (Posix)` is appropriate or not). That way, you'll hit static asserts when

Re: books for learning D

2020-01-13 Thread IGotD- via Digitalmars-d-learn
On Monday, 13 January 2020 at 10:28:48 UTC, mark wrote: I'm just starting out learning D. Andrei Alexandrescu's "The D Programming Language" is 10 years old, so is it still worth getting? (I don't know how much D has changed in 10 years.) Andrei Alexandrescu's is still a good read for those

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-24 Thread IGotD- via Digitalmars-d-learn
On Sunday, 22 December 2019 at 17:20:51 UTC, BoQsc wrote: There are lots of editors/IDE's that support D language: https://wiki.dlang.org/Editors What kind of editor/IDE are you using and which one do you like the most? I use VisualStudio with VisualD. The IDE is ok and debugging

Re: Compililng C++ and D together without going mad

2020-04-29 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 10:25:31 UTC, Jan Hönig wrote: In my pet project, I am using some C++ libraries. The main file/function is also C++. All of it successfully compiles with cmake. Now I want to add some functionality by calling my own D functions (which use some other

OR in version conditional compilation

2020-03-18 Thread IGotD- via Digitalmars-d-learn
I have not seen any example where version has several OR matches. Example idiom: version(X86_64 || X86) { } else version(ARM || Thumb) { }... you get the idea. So is this possible at all or do you have to duplicate the code for each version identifier despite they are equal for many

Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 21:37:23 UTC, kinke wrote: You're welcome. If you do come across an ABI issue, make sure to file an LDC issue. While I have no interest in MinGW, I want at least a working ABI. When you mention the ABI, is there something particular you have in mind or just in

Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 23:08:53 UTC, IGotD- wrote: On Wednesday, 20 May 2020 at 21:37:23 UTC, kinke wrote: You're welcome. If you do come across an ABI issue, make sure to file an LDC issue. While I have no interest in MinGW, I want at least a working ABI. When you mention the ABI,

Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 23:28:09 UTC, kinke wrote: The ABI for MinGW targets in general. - Judging by https://forum.dlang.org/post/anfwqjjsteeyelbdh...@forum.dlang.org, you apparently use a very different definition of 'ABI'. See http://uclibc.org/docs/psABI-x86_64.pdf or

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.

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]:

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

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

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

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

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: 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

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

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?

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: 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

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

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

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-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

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

Re: Garbage Collection Issue

2020-06-01 Thread IGotD- via Digitalmars-d-learn
On Sunday, 31 May 2020 at 16:57:06 UTC, Steven Schveighoffer wrote: I can't imagine much of druntime working at all without TLS. Indeed, it is a requirement these days. I believe that's where these roots are being stored. -Steve I would really like if druntime could remove its TLS

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: 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: 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.

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: 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

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

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,

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

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

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

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

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 ) { 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 will

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

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

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

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); } }

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

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

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

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

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*

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,

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

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

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

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

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

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

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

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

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.²

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

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 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 ];

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

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

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

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

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: 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 =

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?

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

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 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: 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

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,

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).

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.

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

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

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: 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

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: 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

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

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: 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

  1   2   >