There is a problem in current hg tip with naming variable it even though it does not redefine its implicit meaning.
list := ["alpha", "bravo", "charlie", "delta", "echo", "foxtrot"]
list.each { echo(it.size) } // ok
list.each |Str whatever| { echo(whatever.size) // ok
list.each |Str it| { echo(it.size) } // compile ERROR(12): Unexpected type literal
The problem is that Fantom manual mentions this construct as "long hand for above". We should either allow this construct (if the new it is bound to the same object as the implicit it) or remove these examples from the manual.
If feasible I'd rather allow it because one does not have to rename it in the whole body when adding parameters to a closure.
tacticsFri 1 Jan 2010
I'd rather keep it as a reserved identifier. It has special semantic meaning in code, and even though it wouldn't cause confusion for the compiler to allow a variable named it, it would cause confusion to someone down the line. If you need to rename a bunch of variables, use search-and-replace or refactoring tools to do it.
brianSat 2 Jan 2010
You cannot use it as an explicit parameter name just like you can't use this as an explicit parameter name.
I only saw two cases in the Expressions chapter where we showed |Foo it| and I added a note.
katox Fri 1 Jan 2010
There is a problem in current hg tip with naming variable
it
even though it does not redefine its implicit meaning.The problem is that Fantom manual mentions this construct as "long hand for above". We should either allow this construct (if the new
it
is bound to the same object as the implicitit
) or remove these examples from the manual.If feasible I'd rather allow it because one does not have to rename
it
in the whole body when adding parameters to a closure.tactics Fri 1 Jan 2010
I'd rather keep
it
as a reserved identifier. It has special semantic meaning in code, and even though it wouldn't cause confusion for the compiler to allow a variable namedit
, it would cause confusion to someone down the line. If you need to rename a bunch of variables, use search-and-replace or refactoring tools to do it.brian Sat 2 Jan 2010
You cannot use
it
as an explicit parameter name just like you can't usethis
as an explicit parameter name.I only saw two cases in the Expressions chapter where we showed
|Foo it|
and I added a note.