Skip to content

[Proposal]: [call local static functions in base constructor] #3980

@mstaros

Description

@mstaros

call local static functions in base constructor

  • Proposed
  • Prototype: Not Started
  • Implementation: Not Started
  • Specification: Not Started

Summary

Today to calculate parameters to be sent from derived class constructor to base constructor one has to define additional static method in derived class. It would be nice to use local static function instead.

Motivation

Not to litter class members scope with functions that should be encapsulated as local ones.

Example



class A
 {
     public A(int x)
    {
        ...
    }
}
class B:A {
   public B(int z):base(Local(z))
   {
            static int Local(int h)
            {
                 ...
            }
   }
}


Drawbacks

Alternatives

Unresolved questions

Design meetings

https://github.com/dotnet/csharplang/blob/master/meetings/2020/LDM-2020-10-26.md#static-local-functions-in-base-calls
https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-09-28.md#ungrouped

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions