Hello, folks! Newbie to D, have some questions!

timmyjose via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Feb 18 13:23:03 PST 2017


Thanks for the very comprehensive response! I think most of my 
doubts are cleared now. You're right though that I'm probably 
worrying too much about GC with my current use case. Also thanks 
for the links - they should also come in very handy indeed.

I managed to find some book recommendations as well on the site. 
I've decided to start out with what appears to be the most 
approachable of them - Programming in D by Ceherli.

>D doesn't have macros. D has templates like C++, string mixins 
>(insert a statically >know/generated string as D code), and CTFE 
>(Compile Time Function Evaluation, to >programmatically generate 
>static stuff).

Ah, I see! Thanks for clarifying that although CTFE as you 
mentioned it seems to match my specific interest.

I look forward to learning D and being able to contribute some 
day! :-)

On Saturday, 18 February 2017 at 21:09:20 UTC, ag0aep6g wrote:
> On Saturday, 18 February 2017 at 20:15:55 UTC, timmyjose wrote:
>> [...]
>
> There is a GC, but you can avoid the features that use it. 
> There's a function attribute for that: @nogc [1]. It forbids 
> GC-manages allocations. The GC is still there, but it won't do 
> anything because you're not triggering it.
>
> You can also turn automatic collections off (GC.disable [2]). 
> There's no need for that when all your code is @nogc, though, 
> because collections are triggered by allocations.
>
> As for getting rid of the GC entirely (for saving space, I 
> guess), I think that's more involved. May require changes to 
> druntime. Shouldn't be necessary most of the time.
>
>> [...]
>
> Yes. Whenever a std function returns a new string or some such 
> it's going to be GC-allocated. There's an experimental module 
> for custom allocators [3], but the rest of the library doesn't 
> make use of it, yet. When a std function uses the GC, the 
> compiler won't let you call it from @nogc code.
>
>> [...]
>
> I don't think you're going to run into much trouble when making 
> "grep-scale tools".
>
> [...]
>> [...]
>
> D doesn't have macros. D has templates like C++, string mixins 
> (insert a statically know/generated string as D code), and CTFE 
> (Compile Time Function Evaluation, to programmatically generate 
> static stuff).
>
>> [...]
>
> Can't answer this, because I'm not familiar enough with those 
> languages.
>
>> [...]
>
> Absolutely. Anyone is welcome to contribute. D is very much a 
> volunteer effort. Also don't hesitate to point out (or even 
> fix) any stumbling blocks you may encounter when starting out.
>
> [1] https://dlang.org/spec/attribute.html#nogc
> [2] https://dlang.org/phobos/core_memory.html#.GC.disable
> [3] https://dlang.org/phobos/std_experimental_allocator.html
> [4] http://ddili.org/ders/d.en/index.html
> [5] https://tour.dlang.org/



More information about the Digitalmars-d-learn mailing list