IppClub / IppClub/YueScript

[feature request] String interpolation for logging

Open
#142 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
613
Forks
45
PR merge metrics
No merged PRs in 30d

Description

In Python, there's a useful little feature that allows writing something like the following:

foo = "bar"
print(f"{foo = }")

which prints:

foo = 'bar'

Notice how it preserved the spaces before and after the equals sign as written in the f-string.

I think this feature would be a very nice addition to Yuescript, although it may need some simplification. In Python, the code actually translates to printing the repr of foo, not the string conversion; an equivalent would be to write print("foo = " + repr(foo)). But of course that doesn't exist in Lua. My suggestion would be to either just print the value's tostring(), or maybe using a library function to pretty print it. While Yuescript seems to generally prefer inlining things to prevent being dependent on any libraries, I believe it would be fine here, because this is a pure development/debugging feature, so it's pretty safe to expect someone to have Yuescript installed if their code makes use of it.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue describes Python's self-documenting f-string syntax and proposes a Yuescript equivalent with either tostring-style output or pretty printing. Start by resolving the intended syntax and value representation from these alternatives; done means the feature's behavior and spacing around the equals sign are agreed and implemented.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, python
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.