[#104004] [Ruby master Feature#17883] Load bundler/setup earlier to make `bundle exec ruby -r` respect Gemfile — mame@...
Issue #17883 has been reported by mame (Yusuke Endoh).
21 messages
2021/05/24
[ruby-core:103740] [Ruby master Feature#17848] inline rbs either by rdoc comments or changing syntax
From:
matz@...
Date:
2021-05-05 13:58:34 UTC
List:
ruby-core #103740
Issue #17848 has been updated by matz (Yukihiro Matsumoto).
Status changed from Open to Closed
Ruby is not going to add new syntax for type annotation. Allowing `yard` comments in RBS syntax may be a (good) choice, but it's up to `yard` side.
Matz.
----------------------------------------
Feature #17848: inline rbs either by rdoc comments or changing syntax
https://bugs.ruby-lang.org/issues/17848#change-91835
* Author: dsisnero (Dominic Sisneros)
* Status: Closed
* Priority: Normal
----------------------------------------
I like gradual typing - I like the syntax of rbs files but for coding - convenience it would be nice if we had inline syntax for types.
I know that steep allows you to define types inline but because it is valid ruby syntax - the code is not as nice as rbs
could we change method arguments syntax to allow rbs type
def initialize(from: User | Bot = User.new, string: String = "I got your message") -> void # I know this has to be fleshed out to handle all cases (positional , keyword, default but there should be some way we can do it inline)
Either that or bless (recommend) yard style annotations so it is inline and still has easy syntax
class Message
attr_reader id: String
attr_reader string: String
attr_reader from: User | Bot # `|` means union types: `#from` can be `User` or `Bot`
attr_reader reply_to: Message? # `?` means optional type: `#reply_to` can be `nil`
def initialize: (from: User | Bot, string: String) -> void
def reply: (from: User | Bot, string: String) -> Message
end
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>