Re: [crystal] Re: Utilizing Bound But Undefined as a kind of type/class

115 views
Skip to first unread message
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Ary Borenszweig

unread,
Oct 19, 2016, 3:25:22 PM10/19/16
to Crystal
We are reading, but I usually dislike too much magic or implicit stuff.

I think:

x = ""
x = 0
x = 0_u8

is better and shorter than

x = x : String
x = x : Int32
x = x : UInt8

On Wed, Oct 19, 2016 at 3:35 PM TR NS <tran...@gmail.com> wrote:
I'm not sure anyone is reading this, but just the same...

I have an better way to handle it that doesn't require that `x : String` return anything (looking at Crystal source is seems like it would be either a TypeDeclaration or an UndefinedVar, btw, but I'm not sure), nor do we need the slight adjustment to the behavior of `=` if the right hand side is such a thing.

Instead we simply make an exception to the usual `{method}=`  expansion rule (e.g. `+=`). We make this exception because `:` is an built-in operator and not a method. So,
 
     x := String

is simply syntax sugar for

     x : String = String.new

Can't get any simpler than that.


--
You received this message because you are subscribed to the Google Groups "Crystal" group.
To unsubscribe from this group and stop receiving emails from it, send an email to crystal-lang...@googlegroups.com.
To post to this group, send email to crysta...@googlegroups.com.
Visit this group at https://groups.google.com/group/crystal-lang.
To view this discussion on the web visit https://groups.google.com/d/msgid/crystal-lang/5b5990ca-c74b-477a-9db5-1ede8d1fa3a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages