lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Jun 18, 2015 at 1:07 PM, Javier Guerra Giraldez <javier@guerrag.com> wrote:
On Thu, Jun 18, 2015 at 2:54 PM, Brigham Toskin <brighamtoskin@gmail.com> wrote:
> Yeah, that's why I mentioned Go. you can do
>
> foo := 25
> foo := "I'm a foo!"
> foo = 25 // ERROR! foo is type string!


sure?  AFAIR, in Go redefinition is an error... (unless in the same
statement you define another variable for the first time)

Oh, you're right. Idiomatic go error handling depends on being able to redefine variables, to avoid making a huge number of redundant variables. But it'll complain if you don't have a new variable defined with it. http://play.golang.org/p/mX3EaRrEYw

Nonetheless, it does allow redefining variables within a single scope, if with restrictions.

--
Brigham Toskin