Wiki

Ticket #324 (closed enhancement: fixed)

Opened 12 years ago

Last modified 11 years ago

Move to .Net 4.0: Use 'var' for type inference ( cobra codegen and RTL)

Reported by: hopscc Owned by:
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.9.4
Keywords: Cc:

Description

C# .Net 4.0 supports type inference using a var keyword on a declaration.

Where necessary or useful perhaps modify cobra codegen to use it.
Modify C# native (RTL Native.cs) code to do same.

(I've a reservation for the task wrt doing this entirely in codegen because cobra does a pretty good job already without it and pushing this entirely to the backend makes porting/support for other backends dependent on them having type inference as well ( I'm looking at you Java)
Still there may be some possibilities).

Change History

Changed 12 years ago by Charles

I'm fine with doing this in Native.cs, but I'm totally against doing it in the C# code gen. If we did so then we would have the extra burden of ensuring that Cobra's type inference is exactly the same as C#'s in all cases all the time, no exceptions ever. And we will get zero benefit for it.

Plus if we ever move to generating byte code directly, we'll just have to go back to using the Cobra inferred type anyway (there is no inference in MSIL).

Changed 12 years ago by hopscc

I agree. Any effort for this (in codegen) would be underneath the typing already determined by cobra - i.e implicit local or support variables allowed to infer their type....

( probably none or minor changes for existing code, maybe less rigorous re explicit typing for any future code added).

Devolves mainly to a pass through Cobra.Core/Native?.cs to 'clean' it up.

Changed 11 years ago by Charles

  • status changed from new to closed
  • resolution set to fixed

Using var in Native.cs is done in changset:3060

Note that var won't be used in the generated C# code as explained in a previous comment.

Note: See TracTickets for help on using tickets.