Wiki

Ticket #149 (accepted enhancement)

Opened 16 years ago

Last modified 16 years ago

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?

Change History

Changed 16 years ago by jonathandavid

I think I screwed it up, the part after "layer is not added." should not be there.

Chuck, isn't it possible to edit tickets?

Changed 16 years ago by jonathandavid

  • status changed from new to accepted

Changed 16 years ago by Chuck

I haven't seen anything to edit tickets or edit replies. And yes, that's annoying. You just have to "fix" with comments.

Changed 16 years ago by jonathandavid

I just found this:  http://trac-hacks.org/wiki/TicketChangePlugin

I don't know how much work it'll be to get that working, though.

Changed 16 years ago by Chuck

If you want, you can make a new ticket for this with component "Cobra Web Site: Trac". I don't know how much work it is either.

Note: See TracTickets for help on using tickets.