Re: Why many programmers don't like GC?

2021-01-15 Thread welkam via Digitalmars-d-learn
On Friday, 15 January 2021 at 07:35:00 UTC, H. S. Teoh wrote: (1) Refactored one function called from an inner loop to reuse a buffer instead of allocating a new one each time, thus eliminating a large amount of garbage from small allocations; <...> The result was about 40-50% reduction in

Re: Why many programmers don't like GC?

2021-01-15 Thread welkam via Digitalmars-d-learn
On Wednesday, 13 January 2021 at 18:58:56 UTC, Marcone wrote: I've always heard programmers complain about Garbage Collector GC. But I never understood why they complain. What's bad about GC? Most people get to know GC trough Java or C#. Those languages promote the use of OOP and they say

Re: Why many programmers don't like GC?

2021-01-15 Thread welkam via Digitalmars-d-learn
On Friday, 15 January 2021 at 15:18:31 UTC, IGotD- wrote: I have a feeling that bump the pointer is not the complete algorithm that D uses because of that was the only one, D would waste a lot of memory. Freeing memory is for loosers :D https://issues.dlang.org/show_bug.cgi?id=21248 DMD

Re: Why many programmers don't like GC?

2021-01-15 Thread welkam via Digitalmars-d-learn
On Friday, 15 January 2021 at 14:35:55 UTC, Ola Fosheim Grøstad wrote: On Friday, 15 January 2021 at 14:24:40 UTC, welkam wrote: You can use GC with D compiler by passing -lowmem flag. I didnt measure but I heard it can increase compilation time by 3x. Thanks for the info. 3x is a lot Take

Re: Why many programmers don't like GC?

2021-01-15 Thread welkam via Digitalmars-d-learn
On Thursday, 14 January 2021 at 18:51:16 UTC, Ola Fosheim Grøstad wrote: One can follow the same kind of reasoning for D. It makes no sense for people who want to stay high level and do batch programming. Which is why this disconnect exists in the community... I think. The reasoning of why

Re: Why many programmers don't like GC?

2021-01-15 Thread welkam via Digitalmars-d-learn
On Friday, 15 January 2021 at 11:28:55 UTC, Ola Fosheim Grøstad wrote: On Friday, 15 January 2021 at 11:11:14 UTC, Mike Parker wrote: That's the whole point of being able to mix and match. Anyone avoiding the GC completely is missing it (unless they really, really, must be GC-less). Has DMD

Re: Should a parser type be a struct or class?

2020-06-18 Thread welkam via Digitalmars-d-learn
Oh an also https://github.com/dlang/dmd/pull/9899

Re: Should a parser type be a struct or class?

2020-06-18 Thread welkam via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 14:32:09 UTC, Adam D. Ruppe wrote: On Wednesday, 17 June 2020 at 14:24:01 UTC, Stefan Koch wrote: Parser in dmd does even inherit from Lexer. why would a parser ever inherit from a lexer? So you can write nextToken() instead of lexer.nextToken()

32 bit phobos

2020-06-09 Thread welkam via Digitalmars-d-learn
I tried to compile a 32 bit executable but my system does not have 32 bit phobos. How do I get 32 bit phobos? I am using Manjaro. dmd -m32 source/test2.d /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/../../../libphobos2.a when searching for -lphobos2 /usr/bin/ld:

Re: I want Sublime 3 D auto import !

2020-06-02 Thread welkam via Digitalmars-d-learn
On Tuesday, 2 June 2020 at 06:00:10 UTC, Виталий Фадеев wrote: On Monday, 1 June 2020 at 18:55:03 UTC, Paul Backus wrote: On Monday, 1 June 2020 at 16:18:44 UTC, Виталий Фадеев wrote: I do it! https://github.com/vitalfadeev/SublimeDlangAutoImport Cool. I dont use classe but I see how this

Re: Mir Slice Column or Row Major

2020-05-28 Thread welkam via Digitalmars-d-learn
On Wednesday, 27 May 2020 at 16:53:37 UTC, jmh530 wrote: Not always true...many languages support column-major order (Fortran, most obviously). if your column major matrix is implemented as matrix[row_index][column_index] then ok no puppies will be hurt. But I dont see much value in such

Re: Mir Slice Column or Row Major

2020-05-27 Thread welkam via Digitalmars-d-learn
On Wednesday, 27 May 2020 at 01:31:23 UTC, data pulverizer wrote: column major Cute puppies die when people access their arrays in column major.

Re: How to get the pointer of "this" ?

2020-05-25 Thread welkam via Digitalmars-d-learn
On Sunday, 24 May 2020 at 17:05:16 UTC, Vinod K Chandran wrote: cast(DWORD_PTR) this); Where is DWORD_PTR defined? I cant find it in docs. If its an alias of long then you have to cast to a pointer like this cast(long*) this; you need to specify that you want to cast to a pointer of type T.

Re: How to allocate/free memory under @nogc

2020-05-22 Thread welkam via Digitalmars-d-learn
There is automem to help with manual memory management https://code.dlang.org/packages/automem

Re: How to use this forum ?

2020-05-20 Thread welkam via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 20:49:52 UTC, Vinod K Chandran wrote: Hi all, I have some questions about this forum. 1. How to edit a post ? 2. How to edit a reply ? 3. How to add some code(mostly D code) in posts & replies. 4. How to add an image in posts & replies. 5. Is there a feature to mark

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

2020-05-20 Thread welkam via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 18:53:01 UTC, NonNull wrote: Which D compiler should be used to be ABI compatible with mingw32? And which to be ABI compatible with mingw64? I am not expert here but doesnt all C compilers have the same ABI? If yes then compile your code in 32 bits for 32 bit C obj

Re: Is it possible to write some class members in another module ?

2020-05-20 Thread welkam via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 17:29:47 UTC, Vinod K Chandran wrote: I am very sad that i delayed to start learning D only because of semicolons and curly braces. Walter(creator of this language) said that redundant grammar is a good thing because it allows compiler to emit better error

Re: Is it possible to write some class members in another module ?

2020-05-20 Thread welkam via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 09:45:48 UTC, Vinod K Chandran wrote: // Now, we need to use like this auto form= new Window(); form.event.click = bla_bla; // I really want to use like this auto form= new Window(); form.click = bla_bla; ``` Then you want alias this. class Window : Control{

Re: Beginner's Comparison Benchmark

2020-05-06 Thread welkam via Digitalmars-d-learn
On Tuesday, 5 May 2020 at 20:29:13 UTC, Steven Schveighoffer wrote: the optimizer recognizes what you are doing and changes your code to: writeln(1_000_000_001); Oh yes a classic constant folding. The other thing to worry about is dead code elimination. Walter has a nice story where he sent

Re: How can I open a Binary EXE with Hexadecimal?

2020-05-02 Thread welkam via Digitalmars-d-learn
On Saturday, 2 May 2020 at 21:05:32 UTC, Baby Beaker wrote: I need open a Binary EXE, it can be using "rb" mode and convert it to Hexadecimal for me make some changes and save as "rb" again. How can I make it? Thank you. You dont convert binary data to hexadecimal. You display it as

Re: Newbie linker errors - still missing _fltused _tls_index _tls_used localtime tzset mainCRTStartup

2020-04-26 Thread welkam via Digitalmars-d-learn
If I remember correctly VS studio has different release and debug configurations for both compiler and linker. If release works but debug doesnt make sure that when you add things to one to also add to another

Re: Using shared memory and thread

2019-11-05 Thread welkam via Digitalmars-d-learn
On Monday, 4 November 2019 at 19:53:29 UTC, bioinfornatics wrote: 3/ variable flagged as `shared` does at mean the variable is put into L2 cache ? First caching is controlled by CPU not programmer. Second not all architectures share L2 between cores. 4 jaguar cores share L2 cache in consoles

Re: Eliding of slice range checking

2019-10-25 Thread welkam via Digitalmars-d-learn
On Thursday, 24 October 2019 at 21:02:03 UTC, Per Nordlöw wrote: On Thursday, 24 October 2019 at 18:37:05 UTC, welkam wrote: I remember in some video Chandler Carruth said that value range propagation across function boundary was implemented in llvm but later removed because it produced no

Re: Eliding of slice range checking

2019-10-24 Thread welkam via Digitalmars-d-learn
On Wednesday, 23 October 2019 at 11:20:59 UTC, Per Nordlöw wrote: Does DMD/LDC avoid range-checking in slice-expressions such as the one in my array-overload of `startsWith` defined as bool startsWith(T)(scope const(T)[] haystack, scope const(T)[] needle) { if

Re: Remove unwanted ' \r ' from an Array ... by reading a *.txt file.

2019-10-24 Thread welkam via Digitalmars-d-learn
On Thursday, 24 October 2019 at 16:49:09 UTC, Mil58 wrote: On Thursday, 24 October 2019 at 16:21:47 UTC, welkam wrote: On Thursday, 24 October 2019 at 15:27:05 UTC, Mil58 wrote: [...] void main() { File("data.txt", "r+") .byLineCopy() .array() .each!writeln; }

Re: [DTrace probe] is there a [portable] way to add section to elf executable?

2019-10-24 Thread welkam via Digitalmars-d-learn
On Wednesday, 23 October 2019 at 15:24:13 UTC, drug wrote: I'd like to add (and modify) section to ELF executable to implement DTrace probes. DTrace does it in probe assembly: ``` __asm__ __volatile__ ( "990: nop .pushsection .note.stapsdt,\"?\",\"note\" .balign 4

Re: dub build doesn't work

2019-10-24 Thread welkam via Digitalmars-d-learn
On Thursday, 24 October 2019 at 01:17:24 UTC, OiseuKodeur wrote: BTW if you prefer using optlink and the digitalmars C runtime, you can instruct dub to do so with: --arch=x86 how can i add --arch=x86 flag to the dub.json so it do it automatically ? "dflags": [ "--arch=x86" ]

Re: Converting a ulong to a byte array and constructing a ulong from it

2019-10-24 Thread welkam via Digitalmars-d-learn
On Thursday, 24 October 2019 at 14:08:36 UTC, 9898287 wrote: Does this contain any undefined behavior? It is in C as far as I knew. immutable int number = 1; auto bad_idea = (cast(ubyte*) )[0 .. number.sizeof]; bad_idea[0] = 2; writeln(number); //1 writeln(*(cast(int*)bad_idea.ptr)); //2 Cast

Re: Remove unwanted ' \r ' from an Array ... by reading a *.txt file.

2019-10-24 Thread welkam via Digitalmars-d-learn
On Thursday, 24 October 2019 at 15:27:05 UTC, Mil58 wrote: Hi all It's me again ;-) (because you're very strong in Dlang, here...) In want a result as i write in a comment, with remove unwanted '\r' >> import std.stdio; import std.file; import std.conv; import std.process : executeShell; /*

Re: gcc 9 vs. dmd?

2018-11-30 Thread welkam via Digitalmars-d-learn
On Friday, 30 November 2018 at 04:47:26 UTC, Andrew Pennebaker wrote: gcc is currently required for dmd on FreeBSD, as dmd links to libstdc++. Parts of dmd are still written in C++ but most of it was converted recently. More on that here: "DMD backend now in D"

Re: D is supposed to compile fast.

2018-11-26 Thread welkam via Digitalmars-d-learn
On Sunday, 25 November 2018 at 22:00:21 UTC, Chris Katko wrote:. So 1) I have to compile manually, then link. Except that also runs the files every time even if they're up-to-date. Is that normal behavior for C/C++? Well you dont have to use separate commands but yes compiling and linking

Re: D is supposed to compile fast.

2018-11-24 Thread welkam via Digitalmars-d-learn
On Friday, 23 November 2018 at 08:57:57 UTC, Chris Katko wrote: D is supposed to compile fast. You didnt read the fine print. It compiles simple code fast. Also compilation is separate step from linking and your program might spend half of "compilation" time in link phase.

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-21 Thread welkam via Digitalmars-d-learn
On Wednesday, 21 November 2018 at 09:20:01 UTC, NoMoreBugs wrote: On Tuesday, 20 November 2018 at 15:46:35 UTC, Adam D. Ruppe wrote: On Tuesday, 20 November 2018 at 13:27:28 UTC, welkam wrote: Because the more you learn about D the less you want to use classes. classes rock. You just

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-20 Thread welkam via Digitalmars-d-learn
On Monday, 19 November 2018 at 21:23:31 UTC, Jordi Gutiérrez Hermoso wrote: Why does nobody seem to think that `null` is a serious problem in D? Because the more you learn about D the less you want to use classes. I view class as compatibility feature when you want to port Java code to D.

Re: What is best way to read and interpret binary files?

2018-11-20 Thread welkam via Digitalmars-d-learn
On Tuesday, 20 November 2018 at 12:01:49 UTC, Stanislav Blinov wrote: On Tuesday, 20 November 2018 at 11:54:59 UTC, welkam wrote: On Monday, 19 November 2018 at 22:14:25 UTC, Neia Neutuladh wrote: Nothing stops you from writing: SomeStruct myStruct;

Re: What is best way to read and interpret binary files?

2018-11-20 Thread welkam via Digitalmars-d-learn
On Monday, 19 November 2018 at 22:14:25 UTC, Neia Neutuladh wrote: Nothing stops you from writing: SomeStruct myStruct; fd.rawRead((cast(ubyte*))[0..SomeStruct.sizeof]); Standard caveats about byte order and alignment. Never would I thought about casting struct to static array. If I

What is best way to read and interpret binary files?

2018-11-19 Thread welkam via Digitalmars-d-learn
So my question is in subject/title. I want to parse binary file into D structs and cant really find any good way of doing it. What I try to do now is something like this byte[4] fake_integer; auto fd = File("binary.data", "r"); fd.rawRead(fake_integer); int real_integer = *(cast(int*)

Re: Can opApply be made @nogc?

2018-10-21 Thread welkam via Digitalmars-d-learn
DIP 1000 says: Delegates currently defensively allocate closures with the GC. Few actually escape, and with scope only those that actually escape need to have the closures allocated. https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md#benefits

Re: What does -vtls compiler flag does and ...

2018-10-04 Thread welkam via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 21:50:49 UTC, Stanislav Blinov wrote: Thread-local storage is memory allocated for each thread. Only static non-immutable variables go there. Regular variables on the stack aren't explicitly placed in any TLS, they're, well, on the stack as it is. Oh so its

Re: What does -vtls compiler flag does and ...

2018-10-03 Thread welkam via Digitalmars-d-learn
string a = "test"; is a variable that mutates so it should be thread local. Also ASM output shows that these variables are not optimized away so compiler should output something but it doesnt. Or I dont understand thread local storage.

Re: What does -vtls compiler flag does and ...

2018-10-03 Thread welkam via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 20:58:01 UTC, Stanislav Blinov wrote: No, all *static non-immutable* variables are thread-local by default, not just "all variables". I misspoke but this should write something https://run.dlang.io/is/3u1wFp If you look at asm output there are "call

What does -vtls compiler flag does and ...

2018-10-03 Thread welkam via Digitalmars-d-learn
I was playing around with dmd`s make file trying to see if I can compile dmd with different compilers and different compilation flags. By playing around I found that some dmd files are compiled with -vtls flag unconditionally and that ldc do not support this flag. First I dont know what -vtls

Setting up DMD on windows

2018-02-03 Thread welkam via Digitalmars-d-learn
Tried to use DMD compiler that I built from source by following these instructions https://wiki.dlang.org/Building_under_Windows They are outdated but I managed to compile it but I get this error when I tried to compile some code. dmdm -run Main.d

Re: How to proceed with learning to code Windows desktop applications?

2018-01-29 Thread welkam via Digitalmars-d-learn
On Monday, 29 January 2018 at 22:55:12 UTC, I Lindström wrote: The other way I've been thinking is to do the thing browser-based, but for some reason that doesn't feel right. Well it didnt felt wrong for Microsoft to use modified internet explorer to make calculator. You can read more on

Re: Looks like wrong error message

2018-01-28 Thread welkam via Digitalmars-d-learn
On Sunday, 28 January 2018 at 20:42:52 UTC, Jonathan M Davis wrote: There is nothing incorrect about the error message. The compiler looked at all of the functions in the overload set, and it found none that matched. The reason that it found none that matched was because it couldn't find any

Looks like wrong error message

2018-01-28 Thread welkam via Digitalmars-d-learn
Error says that it cant deduce function from argument types but in reality it fails to meet function template constraints. In this case !is(CommonType!(staticMap!(ElementType, staticMap!(Unqual, Ranges))) == void) In human terms it means that arguments are not the same type. Is this require

Re: D generates large assembly for simple function

2018-01-28 Thread welkam via Digitalmars-d-learn
On Sunday, 28 January 2018 at 14:33:04 UTC, Johan Engelen wrote: Careful with these comparisons guys. Know what you are looking at. Wise words

Re: Writing a screen saver in D what libraries will help?

2015-10-12 Thread welkam via Digitalmars-d-learn
On Monday, 12 October 2015 at 19:16:10 UTC, Gary Willoughby wrote: If I was writing a screensaver in D what libraries are available for opening a window and drawing sprites, etc on it. GPU accelerated if possible. I'm using Ubuntu 14.04 and latest DMD compiler. You will need to interface to

Re: How To: Passing curried functions around

2015-09-06 Thread welkam via Digitalmars-d-learn
Now its clearer to me. You want delegates http://wiki.dlang.org/Function_literals

Re: How to use ranges?

2015-08-23 Thread welkam via Digitalmars-d-learn
There was a talk on ranges in Dconf 2015 https://www.youtube.com/watch?v=A8Btr8TPJ8clist=PLEDeq48KhndP-mlE-0Bfb_qPIMA4RrrKoindex=10