May 24, 2018
On Wednesday, 23 May 2018 at 14:25:44 UTC, Steven Schveighoffer wrote:

> How do I know I'm in a function?

I don't think you're ever actually "in a function". The code is just data passing through the compiler.  I think what your may be asking is "How do I know I'm working on a function?". That depends on what stage in the the code->binary translation process your at (parsing, semantic, {not sure about others}).  Usually this is done with a `visit(` method.  grep for `visit(FuncDeclaration` or `visit(FuncExp`.  You may be deep in the body of a function, processing some other expression, though.  For that, you'll want to turn on the logging features in DMD when you do a build so you can see output each time an expression is visited; grep for `LOGSEMANTIC`.


> How do I know I'm in a template?

Same principle as above.  grep for `visit(TemplateInstance` or `visit(TemplateDeclaration`.

> What module am I in?

grep `visit(Module`, maybe?

I think for all of my answers above, you can also navigate up the AST using the `.parent` property of a symbol; see the dmd.dsymbol.Dsybmol class.

> How do I know what has been run?

I'd say by turning on logging in the various source files.

> What is the proper way to generate lowered code?

You're basically writing D code with D code.  The `Expression` class and it's derived classes are where its at.  See my failed attempt at lowering array literals to template here:  https://github.com/dlang/dmd/pull/8245/files

Also my Binary Assignment Operators PR is an exemplary exercise in lowering:  https://github.com/dlang/dmd/pull/7079/files

Hope that helps at least a little.  It'll probably just generate more questions, but keep them coming.

Mike
May 24, 2018
On Thursday, 24 May 2018 at 02:07:28 UTC, Mike Franklin wrote:

> Hope that helps at least a little.  It'll probably just generate more questions, but keep them coming.

This is all great, but nobody is going to be able to find the answers here in the forum. I recommend a Markdown document in the "docs" directory in the DMD project [1] and a link in the readme to that document.

[1] https://github.com/dlang/dmd/tree/master/docs

--
/Jacob Carlborg
May 24, 2018
On 5/24/18 5:13 AM, Jacob Carlborg wrote:
> On Thursday, 24 May 2018 at 02:07:28 UTC, Mike Franklin wrote:
> 
>> Hope that helps at least a little.  It'll probably just generate more questions, but keep them coming.
> 
> This is all great, but nobody is going to be able to find the answers here in the forum. I recommend a Markdown document in the "docs" directory in the DMD project [1] and a link in the readme to that document.
> 
> [1] https://github.com/dlang/dmd/tree/master/docs

Honestly, we need this somewhere on the web site, like in a nice tutorial/FAQ. Even stuffing it in the wiki is going to get lost, it should really be linked from the front page.

I think we should have contribution guides for Phobos, Druntime, and DMD all right on the front page.

-Steve
May 24, 2018
On Wednesday, 23 May 2018 at 01:33:19 UTC, Mike Franklin wrote:
> On Tuesday, 22 May 2018 at 16:27:05 UTC, Eduard Staniloiu wrote:
>
>> Let the brainstorming begin!
>
> I would like to see a dependency-less Phobos-like library that can be used by the DMD compiler, druntime, -betterC, and other runtime-less/phobos-less use cases.  It would have no dependencies whatsoever.
>
>
> As a contrived illustration, take a look at the code in https://github.com/dlang/druntime/blob/master/src/core/internal/string.d  Those same features are also in Phobos.

OT, numberDigits enters an infinite loop if radix == 1.


May 24, 2018
On Thursday, 24 May 2018 at 18:07:53 UTC, Patrick Schluter wrote:
> On Wednesday, 23 May 2018 at 01:33:19 UTC, Mike Franklin wrote:
>> On Tuesday, 22 May 2018 at 16:27:05 UTC, Eduard Staniloiu wrote:
>>
>>> Let the brainstorming begin!
>>
>> I would like to see a dependency-less Phobos-like library that can be used by the DMD compiler, druntime, -betterC, and other runtime-less/phobos-less use cases.  It would have no dependencies whatsoever.
>>
>>
>> As a contrived illustration, take a look at the code in https://github.com/dlang/druntime/blob/master/src/core/internal/string.d  Those same features are also in Phobos.
>
> OT, numberDigits enters an infinite loop if radix == 1.

and crashes for radix == 0
May 24, 2018
On Thursday, 24 May 2018 at 18:08:35 UTC, Patrick Schluter wrote:

>>> As a contrived illustration, take a look at the code in https://github.com/dlang/druntime/blob/master/src/core/internal/string.d  Those same features are also in Phobos.
>>
>> OT, numberDigits enters an infinite loop if radix == 1.
>
> and crashes for radix == 0

All the more reason to implement my proposal.
May 24, 2018
On 5/24/18 2:21 PM, Mike Franklin wrote:
> On Thursday, 24 May 2018 at 18:08:35 UTC, Patrick Schluter wrote:
> 
>>>> As a contrived illustration, take a look at the code in https://github.com/dlang/druntime/blob/master/src/core/internal/string.d  Those same features are also in Phobos.
>>>
>>> OT, numberDigits enters an infinite loop if radix == 1.
>>
>> and crashes for radix == 0
> 
> All the more reason to implement my proposal.

Why? they are just bugs.

https://github.com/dlang/druntime/pull/2192

-Steve
May 25, 2018
On Wednesday, 23 May 2018 at 03:56:32 UTC, Mike Franklin wrote:
> On Tuesday, 22 May 2018 at 16:27:05 UTC, Eduard Staniloiu wrote:
>
>> Let the brainstorming begin!
>
> Building and running the DMD test suite on vanilla Windows is a pain.  I never succeeded but it appears to require the user to first set up a posix environment and then battle environment configuration, and other vague dependencies such as whether you are building for 32-bit or 64-bit and whether Visual Studio 2017 is installed.
>
> I believe most contribute to D with a Linux development machine, but sometimes there are Windows-only issues that need to be solved.  For that we need to be able to build and test our changes on Windows without hassle.
>
> I'd like to see the requirement for a posix environment lifted by porting all makefiles to D, so the same code (with appropriate `version`ing of course) could be used to compile and build dlang repositories on all platforms without a lot of environment setup and configuration.  All that would be required a recent D compiler in one's PATH.
>
> See https://github.com/dlang/dmd/pull/8162 for some working moving in that direction.
>
> Mike

Yep, `test/run.d` is a first step in this direction and apart from the few shell tests, it should allow running the DMD testsuite without the prior hassles. Though for the shell tests, just using the shell shipped with the Windows version of Git is enough.

I just gave converting the DMD Make build script to D a quick shot and it doesn't look too complicated:

https://github.com/dlang/dmd/pull/8293
May 25, 2018
On Friday, 25 May 2018 at 12:23:35 UTC, Seb wrote:

> I just gave converting the DMD Make build script to D a quick shot and it doesn't look too complicated:

Very Nice!  Many thumbs up!  And, welcome back!

Mike


May 25, 2018
On Wednesday, 23 May 2018 at 01:51:35 UTC, Mike Franklin wrote:
> On Tuesday, 22 May 2018 at 16:27:05 UTC, Eduard Staniloiu wrote:
>
>> Let the brainstorming begin!
>
> Make WebAssembly a thing in D.
>
> See https://forum.dlang.org/post/ejplfelcqsvjmdvxtsnq@forum.dlang.org
>
> Currently C++ and Rust dominate that domain.  D could kick some web asm there too.
>
> Mike

I am curious about binary size of microservies on webpages. D-binaries tend to be bigger and the D garbage collector needs to be within them. Then we would have to rely on LLVM drastically reducing the binary size of static compiled apps.

If we say "its only for betterc" or "its only for bigger webapps and nodejs-webassembly", it would be half assed - and in my humble opinion too much of a disadvantage compared to rust. I might be wrong of course