goby-lang / goby

Goby - Yet another programming language written in Go
MIT License
3.49k stars 171 forks source link

Trailing `?` and `!` for method names #198

Closed hachi8833 closed 7 years ago

hachi8833 commented 7 years ago

I should've noticed that String#include I implemented yesterday has no ? because I couldn't do that on the current implementation.

I imagine treating ? and ! for method names like Ruby would make the parser more complicated.

Thus I suppose treating ? and ! is a future issue, or is to cut out from specification.

st0012 commented 7 years ago

I haven't decided about this yet. ? and ! is useful when people use it correctly, but this may also create more confusion when someone miss-use/forget to use them. However, I don't know what the impact to Ruby developers would be if we don't implement this.

hachi8833 commented 7 years ago

Yes, that's what I worry about a bit.

Looks like trailing ? might be pretty good for developers to indicate the method returns boolean shortly, while the usage of trailing ! is widely inconsistent.

This might be a language design and coding-style matter. I'd just say that we should not determine this too early. Gimme some time.

Alexius-Huang commented 7 years ago

I think trailing ? methods might be a good idea which indicates methods which returns boolean type (and definitely the convention in Ruby Lang). However, I think bang methods (trailing with !) are not necessarily need to be implemented in Goby Lang.

Although bang methods does warn developer that it have side-effect, but there are too many case of side-effects which might have a great chance to be misused. For example, I have a bad time misusing ActiveRecord#save! and ActiveRecord#save in Rails. (Maybe it just me lacking Rails programming experience XD)

hachi8833 commented 7 years ago

Implementing the trailing ? first looks good. We can decide adopting ! or not later.

st0012 commented 7 years ago

Result: Already supported trailing ? and not going to support !.