Skip to content

Allow @call to call private functions #8779

@david-vanderson

Description

@david-vanderson

Sometimes you find the exact function you need in the standard library, but it's not public. There should be a way to override that and call the function anyway.

In the zig project I'm working on, it works well to:

  1. std.net.tcpConnectToHost (blocking)
  2. std.os.setSockFlags to switch socket to nonblocking
  3. read/write to socket (nonblocking)

The problem is that std.os.setSockFlags is private. This sucks as a user. You either have to copy-paste the function into your project or edit the standard library file.

Options:

  1. Change @call to work on private functions as is
  2. Change @call to work on private functions with a new CallOptions modifier .override_private

This would balance the desire to have private functions with giving users an escape hatch and satisfy zig's commitment to "Communicate intent precisely" while serving users well.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions