May 26, 2021
On 5/26/2021 8:06 PM, Walter Bright wrote:
> On 5/25/2021 6:25 PM, Nicholas Wilson wrote:
>> ...Illusions of Progress provide no actual utility, hence illusions.
>> Packaging DMD otoh, provides _lots_ of utility: exploration and navigation is greatly eased, moreso for people who are less familiar with the codebase.
> 
> Creating a FILES.md file, the content of which is each source file with a brief description, will accomplish the same thing.

I see this has already been done:

https://github.com/dlang/dmd/blob/master/src/dmd/README.md

It's a bit out of date, files like typesem.d are missing.
May 26, 2021
On 5/24/2021 4:24 AM, Alexandru Ermicioi wrote:
> Please limit use of abbreviations to minimum, and those that are used, should be documented.

  grep -w aa *.d

yields:

argtypes_aarch64.d: * https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst.
clone.d:             * int[S] aa;   // Currently AA key uses bitwise comparison
dinterpret.d:                 *     aa[i][j] op= newval;
dinterpret.d:                 *     aa = [i:[j:T.init]];
dinterpret.d:                 *     aa[j] op= newval;
dinterpret.d:            // Create a CTFE pointer &aa[index]
dinterpret.d:private Expression interpret_aaApply(UnionExp* pue, InterState* istate, Expression aa, Expression deleg)
dinterpret.d:    aa = interpret(aa, istate);
dinterpret.d:    if (exceptionOrCantInterpret(aa))
dinterpret.d:        return aa;
dinterpret.d:    if (aa.op != TOK.assocArrayLiteral)
dinterpret.d:    AssocArrayLiteralExp ae = cast(AssocArrayLiteralExp)aa;
dmangle.d:    private extern(D) bool backrefImpl(T)(ref AssocArray!(T, size_t) aa, T key)
dmangle.d:        auto p = aa.getLvalue(key);
dsymbol.d:        AliasAssign aa = new AliasAssign(loc, ident,
dsymbol.d:        return aa;
e2ir.d:            elem *aa = toElem(ie.e2, irs);
e2ir.d:            // aaInX(aa, keyti, key);
e2ir.d:            elem *ep = el_params(key, keyti, aa, null);
e2ir.d:                //      *aaGetY(aa, aati, valuesize, &key);
e2ir.d:                //      *aaGetRvalueX(aa, keyti, valuesize, &key);
expression.d:         *     aa[k1][k2][k3] op= val;
expression.d:         *     auto ref __aatmp = aa;
expressionsem.d:                 *  aa.remove(arg) into delete aa[arg]
expressionsem.d:                    ce.error("expected key as argument to `aa.remove()`");
expressionsem.d:                     *      aa[key] = e2;
expressionsem.d:                     *      ref __aatmp = aa;
sideeffect.d:             *  S[int] aa;
sideeffect.d:             *  aa[1] = 0;
sideeffect.d:             *  1 in aa ? aa[1].value = 0 : (aa[1] = 0, aa[1].this(0)).value;
sideeffect.d:             *  int value = (aa[1] = 0);    // value = aa[1].value

which is not perfect, but very helpful. It usually means "Associative Array", but sometimes "AliasAssign". grep is very, very handy at this sort of thing. I use it constantly.


> Yet there is no official guidance on where to start. Also, please note that not all volunteers prefer reading source code, and invest hours at understanding the architecture and inner workings, starting from lexer or parser, some of them just want to fix a small bug, and be done with it. It is extremely hard to do that now.

Start here:

  https://github.com/dlang/dmd/blob/master/src/dmd/README.md

Each source file has handy links at the start. For example, dsymbol.d:

  https://github.com/dlang/dmd/blob/master/src/dmd/dsymbol.d

has a link to its documentation generated from Ddoc:

  https://dlang.org/phobos/dmd_dsymbol.html

May 27, 2021
On Thursday, 27 May 2021 at 05:08:41 UTC, Walter Bright wrote:
> On 5/24/2021 4:24 AM, Alexandru Ermicioi wrote:
>> Please limit use of abbreviations to minimum, and those that are used, should be documented.
>
>   grep -w aa *.d

We have good articles, good posts.
But no system rearragement. So, you said again and again, but others still don't know.
We need open another section to rearrange the good post/infomation.
We need good organization on man/info/code/....

May 27, 2021
On Thursday, 27 May 2021 at 05:08:41 UTC, Walter Bright wrote:
> grep is very,  very handy at this sort of thing. I use it constantly.

We are stuck in a 70s mainframe.
May 27, 2021
On Thursday, 27 May 2021 at 05:22:26 UTC, zjh wrote:
> On Thursday, 27 May 2021 at 05:08:41 UTC, Walter Bright wrote:
>> On 5/24/2021 4:24 AM, Alexandru Ermicioi wrote:
>>> Please limit use of abbreviations to minimum, and those that are used, should be documented.
>>
>>   grep -w aa *.d
>
> We have good articles, good posts.
> But no system rearragement. So, you said again and again, but others still don't know.
> We need open another section to rearrange the good post/infomation.
> We need good organization on man/info/code/....

No need, just do this:

# cat *.d > allfiles.d

May 27, 2021
On Thursday, 27 May 2021 at 04:53:12 UTC, Walter Bright wrote:
> On 5/26/2021 8:06 PM, Walter Bright wrote:
>> On 5/25/2021 6:25 PM, Nicholas Wilson wrote:
>>> ...Illusions of Progress provide no actual utility, hence illusions.
>>> Packaging DMD otoh, provides _lots_ of utility: exploration and navigation is greatly eased, moreso for people who are less familiar with the codebase.
>> 
>> Creating a FILES.md file, the content of which is each source file with a brief description, will accomplish the same thing.
>
> I see this has already been done:
>
> https://github.com/dlang/dmd/blob/master/src/dmd/README.md
>
> It's a bit out of date, files like typesem.d are missing.

I know, I wrote the equivalent for the backend. And no that does not accomplish the _same_ thing, not even remotely close. The fact you only just found out about it shows that:
a) you have never used the README, and
b) know your way around well enough to not need it, which shows the implication that
c) you have no perspective from those who would have use for either a README or better structured files and know nothing about the relative benefits of either of them.

Yes, a README is strictly better than nothing. It does not substitute for having organised files. Neither does well organised files substitute for a lack of README.
May 27, 2021
On Thursday, 27 May 2021 at 05:36:55 UTC, Nicholas Wilson wrote:
> The fact you only just found out about it shows that:
> a) you have never used the README, and
> b) know your way around well enough to not need it, which shows the implication that
> c) you have no perspective from those who would have use for either a README or better structured files and know nothing about the relative benefits of either of them.

d) See no value in spending effort on designing an architecture.

e) Does not see the value of having others add new features.

So basically the project is following this structure:

On person runs ahead adding features faster than they are completed.
Helping out means walking around grepping for things to fix.

If that is it, then we might as well close the thread and conclude that dmd is a hobby project.

Which is fair enough. Just don't pretend it aspires to be more than that, because that takes reorganization and restructuring.





May 27, 2021

On Thursday, 27 May 2021 at 05:22:26 UTC, zjh wrote:

>

On Thursday,

Stability is very important.
And a good architecture/organization can fix problems as quickly as possible.
D can not only rely on 1/2 man, or continue adding features and bugfixing.
What D needs is good organization on code/people/information.
D needs people to participate. Good organization is very important.Good organization gets twice the result with half the effort.
Well organized, people are naturally willing to participate. And errors can be quickly fixed.
Change the organization doesn't mean change implemention.So errors may not be too much.

May 27, 2021
On Thursday, 27 May 2021 at 05:36:55 UTC, Nicholas Wilson wrote:
> On Thursday, 27 May 2021 at 04:53:12 UTC, Walter Bright wrote:
>> On 5/26/2021 8:06 PM, Walter Bright wrote:
>>> [...]
>>
>> I see this has already been done:
>>
>> https://github.com/dlang/dmd/blob/master/src/dmd/README.md
>>
>> It's a bit out of date, files like typesem.d are missing.
>
> I know, I wrote the equivalent for the backend. And no that does not accomplish the _same_ thing, not even remotely close. The fact you only just found out about it shows that:
> a) you have never used the README, and
> b) know your way around well enough to not need it, which shows the implication that
> c) you have no perspective from those who would have use for either a README or better structured files and know nothing about the relative benefits of either of them.
>
> Yes, a README is strictly better than nothing. It does not substitute for having organised files. Neither does well organised files substitute for a lack of README.

and adding to that by citing Walters message "It's a bit out of date, files like typesem.d are missing." shows the inherent problem of a separate README file. Organized files are self documenting, readme's are not.
May 27, 2021

On Thursday, 27 May 2021 at 06:08:53 UTC, Ola Fosheim Grostad wrote:

>

If that is it, then we might as well close the thread and conclude that dmd is a hobby project.

Which is fair enough. Just don't pretend it aspires to be more than that, because that takes reorganization and restructuring.

Don't forget about the many contributors that have invested thousands of hours to understand and improve the code base :)

While I disagree with many of Walter's arguments here, a refactoring has a lower barrier of entry than a bugfix, and is more prone to be subjective.

It isn't always subjective, as, just like a bug fix, a refactoring can come with a test case. For example, if someone writes a tool that uses DMD as a library, it will be a solid ground to push a change that could otherwise be perceived as subjective. We had work done on trying to make DMD work as a library before, and all we ended up with was a massive amount of duplication. But when such refactoring are driven by use case (e.g. VisualD's usage of DMD), they are easy to justify and accept.

Now to talk about what can be done to improve the DMD codebase, it's fairly obvious: ELIMINATE ALL CASTS. But not by replacing cast(XXX)e with e.isXXX(), but by actually using proper encapsulation.

What I mean is that instead of switching on types, like this:

if (auto tf = t.isTypeFunction())
    (cast(FunctionDeclaration)t.sym).something();
else if (auto td = t.isTypeDelegate())
    (cast(FunctionDeclaration)(cast(TypeFunction)t).sym).something();
else
    // Something else

We should switch on capabilities. We currently "suffer" from abstraction: almost everything is a Type, Dsymbol, Expression, etc... but then when we do semantic we have to cast or isXXX it all over the place. Functions that are only supposed to accept CallExp or BinExp end up accepting an Expression because somewhere, a field that should be CallExp or BinExp is stored as an Expression, or because we don't have the proper return type on a function, etc...

There are simple areas where one can start, for example making all aggregate have the most specialized type possible: TypeDelegate.nextOf() should return a TypeFunction, not a Type. FunctionDeclaration.type() should be a property that gives you a TypeFunction, not a Type, etc...