Ticket #149 (accepted enhancement)
Simplifying internal class VariType
Reported by: | jonathandavid | Owned by: | jonathandavid |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | Cobra Compiler | Version: | 0.8.0 |
Keywords: | vari, compiler | Cc: |
Description
Right now, objects of VariType read from a CLR DLL have the following structure.
VariType[T] = NilableType[ArrayType?[T]]
The Class[T] notation I've just made up means that Class inherits from WrappedType, and has T as its _wrappedType instance var.
(Note that native Cobra vari params don't have this problem, as they are created with the much more logical structure VaryType?[T] = T)
I see one problem with the structure above, namely that ArrayType? layer is redundant; it should be implicit from the fact that we are dealing with a vari parameter.
In a previous ticket I objected to the NilableType part as well, but once we remove the ArrayType? layer we will be left with:
VariType[T] = NilableType[T]
Now I think that this makes sense, since the arguments passed as vari parameters can be nil. For example:
"1 2".split(@[1, nil])
The goal of this ticket, thus, is to change the way vari params are read from CLR DLLs, so that the ArrayType? layer is not added.
2) The NilableType part is mislocated
As you can imagine, the code to extract the T from a VariType31 gets quite convoluted. Why not have VariType32 as VariType33[T] = WrappedType34[T]? If case some of the functionality of ArrayType??35 is needed, why not have VariType36 inherit from ArrayType??37? And most important, why put that Nilable layer in the middle?