Files
hakorune/docs/development/roadmap/phases/phase-12.7/grammar-fields-consultation.txt

88 lines
2.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Nyashプログラミング言語の文法改革について深い相談です。
【現在の検討状況】
1. 予約語を30個→10個に削減済み
- box, new, me, public, if, loop, break, return, import, from
2. コンストラクタ名
- 「birth」で統一Everything is Box哲学を体現
3. 変数宣言
- := 演算子は却下localキーワードがあるため明示的
- local x = 42 の形式を維持
4. デリゲーション
- fromキーワード維持box Child from Parent
- 親メソッド呼び出しは Parent::method()
5. フィールド可視性
- デフォルト非公開privateキーワード削除
- publicで明示的に公開
6. セミコロン
- 基本的に不要Python風
- 1行複数文の場合のみ使用可
【新たな提案fields{}ブロック】
現在の書き方:
box Counter {
public { name, count }
private { cache }
birth() { }
}
提案されたfields{}ブロック:
box Counter {
fields {
IntegerBox count
public StringBox name
MapBox cache
}
birth(name) {
me.name = name
me.count = 0
}
}
【議論のポイント】
1. fields{}ブロック内だけセミコロンを使うと違和感がある
- 全体でセミコロンなしなのに、fieldsだけセミコロンは一貫性がない
2. 他の記法案:
- has{} ブロック(「箱が持つもの」)
- contains{} (「箱に含まれるもの」)
- inside{} (「箱の中身」)
【質問】
1. fields{}ブロック内のセミコロン問題をどう解決すべきか?
- セミコロンなしで統一?
- 改行で区切り?
- 別の区切り方?
2. フィールド宣言の最良の記法は?
- fields{} が最適か?
- 型名を先に書くIntegerBox countか後に書くcount: IntegerBox
- publicの位置は
3. Everything is Box哲学との整合性
- 「箱の中身を宣言する」という意味でfields{}は適切か?
- もっと箱らしい表現はあるか?
4. 全体の文法一貫性
- セミコロンなし統一でいくべきか?
- フィールド宣言だけ特別扱いすべきか?
【理想】
- 明示的(何が起きているか一目瞭然)
- 初学者フレンドリー
- Everything is Box哲学に忠実
- 書いていて楽しい文法
プログラミング言語設計の専門的視点から、深い分析と提案をお願いします。
時間制限なしでじっくり考えてください。