erg icon indicating copy to clipboard operation
erg copied to clipboard

Add string interpolation syntax

Open mtshiba opened this issue 3 years ago • 0 comments

The specification of String interpolation is the same as Python's F-string. However, Erg does not require f.

Erg:

"{x}, y, {z}!"

Python:

f'{x}, y, {z}!'

these will be compiled to

1           0 LOAD_NAME                0 (x)
              2 FORMAT_VALUE             0
              4 LOAD_CONST               0 (', y, ')
              6 LOAD_NAME                1 (z)
              8 FORMAT_VALUE             0
             10 LOAD_CONST               1 ('!')
             12 BUILD_STRING             4
             14 RETURN_VALUE

However, this syntax affects lexer, type checker, and code generator. The implementation is not easy.

mtshiba avatar Sep 18 '22 16:09 mtshiba