dlang / project-ideas

Collection of impactful projects in the D ecosystem
36 stars 12 forks source link

Implement named arguments (DIP 1030) #76

Closed andre2007 closed 1 year ago

andre2007 commented 4 years ago

Description

The DIP [1] for named arguments has been accepted, however it has not been implemented.

In a nutshell, implementing named arguments means adding the compiler code so that this function:

void snoopy(T t, int i, S s);

that can currently be called by

snoopty(T_object, 2, S_object);

will also be callable as:

snoopy(t:T_object, 2, s:S_object);
snoopy(s:S_object, t:T_object, 2);
snoopy(s:S_object, t:T_object, i:2);

[1] https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1030.md

What are rough milestones of this project?

  1. Read and understand the mentioned DIP
  2. Familiarize with the compiler code
  3. Implement the parsing of named arguments
  4. Implement the semantic analysis of named arguments
  5. Develop a thorough testing module

Expected outcome

A pull request to the compiler that implements the named arguments feature, containing all the deliverables from the above mentioned milestones.

How does this project help the D community?

Named arguments is a long awaited feature by both the D community and the language users. Implementing this feature does not only improve the language, but also it also helps D from an image standpoint.

Recommended skills

D\C++, OOP, Compilers

What can students expect to get out of doing this project?

Learn compiler internals

Rating

Medium-Hard

Project type

Core development

Points of contact/Potential Mentors

@RazvanN7

References

https://forum.dlang.org/thread/bizqhxszbobynrimsgai@forum.dlang.org https://forum.dlang.org/thread/bnubytbrlutpnhjgvlfy@forum.dlang.org

rjkilpatrick commented 3 years ago

It looks like parseArguments is using parseAssignExp. I think you'll need to get the argument names of the function you are 'in', look ahead and ensure there's a TOK.colon, then look ahead to get the value of the variable and somehow match it up.

Hopefully, this is enough to help someone start :grinning:.

maxhaton commented 2 years ago

The issue with this is the semantic analysis. Parsing can be implemented in minutes

ntrel commented 1 year ago

Some work from October: https://github.com/dlang/dmd/pull/14575

mdparker commented 1 year ago

Dennis Korpel has been working on this with multiple PRs and is nearing completion. I'm going to go ahead and close the issue.

https://github.com/dlang/dmd/pulls?q=named+arguments