amber-lang / amber-lang/amber

[Feature] Declaring empty variables

オープン
#420 コメント 5 件 リアクション 1 件 担当者 1 名 @b1ek が担当を希望しています GitHub で見る
enhancement
主要言語
Rust
スター
5.2k
フォーク
145
平均マージ
5日 3時間
マージ済み PR(30日)
7

説明

**Is your feature request related to a problem? Please describe.**

In bash, it is possible to declare an empty variable, like so:

#!/usr/bin/env bash

declare foo
foo="bar"
echo "$foo"

Outputs:

bar

However, this functionality is not present in Amber:

main {
let foo
foo = "bar"
echo foo
}

Outputs:

ERROR Expected '=' after variable name 'foo'
at empty.ab:3:6

2| let foo
3| foo = "bar"
4| echo foo

**Describe the solution you’d like**

Simply, compile `let foo` to `declare foo`.

Additionally, `declare` is useful for enforcing variable type, as demonstrated in [this](https://unix.stackexchange.com/a/510342) stackexchange answer. This could be written in Amber as `let foo = Text`.

**Describe alternatives you’ve considered**

I *suppose* writing `let foo = ""` would suffice, but my proposed solution implements more bash functionality and allows for cleaner Amber code.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

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

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