VB 10 thoughts (part 9)

Posted Tue, Oct 16 2007 23:16 by bill


31. Templates for anonymous types

It'd be nice if you could change the template used for anonymous types, such as to include INotifyPropertyChanged or other functionality. If you add a template to your project, you could then specify which template to use, e:g

Dim customer = New With{.FirstName="Fred", .LastName="Flintstone"} BasedOn mytemplate


Dim projection = From c in Customers _
                            Where c.LastName="Flintstone" _
                            Select New {c.LastName, c.FirstName} BasedOn mytemplate


32. Scripting support

Runtime features like creating new types on the fly (including support for templates as per #31), an Eval function, and general ease of dynamic interaction.


33. Support for parallel programming

Full support and possible language enhancements around multiprocessor architecture and parallel programming.


34. Lean and Mean option

Ability to turn off, or make it a warning anytime any VB helper functions are used, as well as make the assembly as light weight as possible.  For example, if I had Option LeanAndMean On, a If string1 = string2 statement would use String.Equals rather than any VB helper library functions.

Filed under: , ,


# re: VB 10 thoughts (part 9)

Tuesday, October 16, 2007 3:31 PM by tom

I vote for scripting support.  

The MSScriptControl is somewhat useable, but it uses COM.  It would be nice to have a .NET solution.


# re: VB 10 thoughts (part 9)

Tuesday, October 16, 2007 3:33 PM by Morgan

#31 BasedOn, do you mean like Inherits ?

# re: VB 10 thoughts (part 9)

Tuesday, October 16, 2007 8:13 PM by Bill

Hi Morgan,

Nope, I mean a replacement template.  The template in this case would have to include the class definition, and as such could dictate what the inheritance chain is.


# Begin Template

Class $uniquename$

  Implements INotifyPropertyChanged

  Private backingValues As New Hashtable


  Public Property $PropertyName$ As $PropertyType$


       return CType(backingValues($PropertyName$),$PropertyType$)

     End Get

     Set(ByVal value as $PropertyType$)

       If Not $PropertyName$.Equals(value) Then

       backingValues($PropertyName$) = value


     End Set

End Property


Private Sub OnPropertyChanged(name as string)

 RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(name))

End Sub

End Class

# End Template

# re: VB 10 thoughts (part 9)

Tuesday, October 16, 2007 8:21 PM by bill

oh, I should add that's a simplified syntax.  Because VB has both Key'ed and non keyed Properties in anonymous types, the replacement blocks would probably need to be idenitified as "Key" and "Non key"

# Power5: Custom anonymous types

Wednesday, February 03, 2010 1:36 AM by VB Feeds

[This post is part of a series, " wish-list for future versions of VB "] IDEA: Custom anonymous