#1359 Generics docs and docs in general.

vkuzkokov Thu 9 Dec 2010

While it may be considered overly pedantic, I'd suggest to clarify some things in the docs:

  1. is semantics. E.g. Int[] is not Obj[] from LSP point of view but Int[]#.fits(Obj[]#) is true.
  2. Generics throw CoerceErr and NullErr when take arguments that don't fit runtime type arguments. That might be worth being reflected in docs.

Also indexing operator docs weren't fixed after the introduction of @Operator facet.

helium Fri 10 Dec 2010

E.g. Int[] is not Obj[] from LSP point of view but Int[]#.fits(Obj[]#) is true.

That would mean I can use a mutable list of Ints whenever I need a mutable list of Objs.

Void addAString(Obj[] list)
{
  list.add("text")   // OK, since it's a list ob objs and a str is an obj
}

...

listOfInts := [1, 2, 3]
addAString(listOfInts)   // should be allowed according to your idea

It only makes sense for immutable lists, but you can't enforce immutability at compile time in Fantom.

vkuzkokov Fri 10 Dec 2010

addAString(listOfInts) // should be allowed according to your idea

It is allowed. I'm just pointing out how it works today and that docs on this matter are incomplete.

brian Sun 2 Jan 2011

I agree - we were missing a section which covered the subtype substitution rules used by the compiler and the is family of operators. I added a new section to the Type System chapter.

Login or Signup to reply.