[feature request] String interpolation for logging

オープン
#142 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
32/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
lua, python
領域
compilers

調査の方向性

この issue では、Python の自己文書化 f-string 構文について説明し、tostring スタイルの出力または pretty printing による Yuescript 版を提案しています。まず、これらの選択肢から意図する構文と値の表現を確定してください。機能の動作と等号の周囲のスペースについて合意し、実装できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Lua
スター
620
フォーク
45
平均マージ
9時間 5分
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

IppClub/YueScript のほかの issue

IppClub/YueScript の issue をすべて見る

似ている issue

Lua の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。