exercism / exercism/problem-specifications

two-fer: Consistency of the empty string

Đang mở
#290 12 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Ruby
Star
358
Fork
563
Merge trung bình
18 giờ 41 phút
Pull request đã merge (30 ngày)
2

Mô tả

In some languages we are able to define functions with the same name and different aritys. Those languages will automatically treat `hello()` different to `hello("")`.

Other languages do not have this luxury or do allow to use default values for arguments.

So in the C track I realized, the empty string is used to signal “nothing given”, while `NULL` might be more appropriate.

Other languages have similar (perhaps more noisy) ways to differ between an empty string and “nothing given” by `Maybe` or `Option` style types.

Therefore I wanted to start a discussion about treatement of the empty string.
1. Treat it as if we had called without a name, so we create `"Hello, World!"` as output
2. Treat it as proper name and return `"Hello, !"`
3. Leave it open to language maintainers

I tried to look up at least the tracks I already solved `hello-world` in:
- Different functions by arity: Erlang, Elixir
- empty string is nothing: C
- empty string is proper name: Rust (`Option`-type)
- testsuite is unclear about the meaning of the empty string: Scala (default mechanisms used based on NULL-references), Crystal (as Scala), Scheme (as Scala), PHP (default mechanisms based on PHP stuff I deny to delve into)

Especially in the last group, it mostly depends on the student how he implements the handling of the default value. I've seen solutions in such exercises that check default `name` to `NULL` (or similar) or `""` and then do a conditional reassignment in the functions body (which in my opinion defeats the purpose of default values for argument).

Especially this wild growing stuff is in my opinion dangerous. In many tracks there are not many people who actually review, and even after `hello-world` is not hidden any more, many reviewers seem to just skip it.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.