Skip to content

[RFC] strformat.% should be gone #7078

@yglukhov

Description

@yglukhov

The new strformat.% operator introduces unnecessary friction. Not only it collides with json.%, it doesn't have any visual meaning, nor it is introduced to the newcomers as some almost-built-in operator like & and $ for working with strings.

The problem of collision with json module is underestimated, imo. import smth except % is not a nice solution when copying code from a file where stformat.% used to work, to a file where json.% used to work. Since both modules are stdlib, they should play nicely with each other.

As a solution to this problem I would recommend introducing the $ macro overloaded by nkStrLit, while reducing existing $(s: string) to match only against non-literal values. As a next step, new $ interpolating macro could be brought to system.nim.

Reasoning:

  1. It is extremely unlikely that anyone is currently using $ with a string literal.
  2. $ is already known to be a stringification operator, so $"myInterpolatedString" would make much more sense visually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions