Hi Daniel,

This all looks great. Don't have any comment on the coding style but was wondering if you could dynmically load the dll once created. I believe CodeDom has some features to this. This would mean you would need to create overloads (or more easly different versions of the xmlLoad and xmlSave) that receive a type object rather than a type parameter. This might be easier for folks that want to use it from a program rather than from F# interactive.

Also this looks like it might make a nice base for a Sourceforge/CodePlex project. Have you considered registering it on one of these sites.

Cheers,
Rob

By on 12/7/2007 8:54 AM ()

Hi Robert,

I had similar thoughts concerning the dynamic loading of the dll. Loading an assembly is simple. As you suggest an amendment to xmlLoad is required:

1
2
3
4
5
6
7
8
9
let xmlLoadDyn (ty :Type) file =
  if File.Exists(file) = false then failwithf "Error: %s does not exist." file
  let xs = new XmlSerializer(ty)
  let xtr = new XmlTextReader(file)
  xs.Deserialize(xtr)

let asm = Assembly.LoadFrom(@"KalmanPredictions.dll")
let kal = asm.CreateInstance("Kalman.Predictions")
let kalobj = xmlLoadDyn <| kal.GetType() <| @"kalpred1.xml"

This works to load the assembly and correctly deserializes the file, but it does not load the Assembly into the FSharp namespace (my terminology is no doubt wrong here.) I'm not sure if it is possible to cast kalobj into a object of type Kalman.Preditions.

I was actually wondering whether dynamic loading could be supported in the VsAddin (as opposed to VsFsi), so not only #r STRING_LITERAL, but #r LET_BOUND_VALUE_OF_PATH_TO_ASSEMBLY might be possible .Using #r STRING_LITERAL gives you immediate Intellisense and type inference, and supporting this in a programmatic way would be awesome.

The behaviour I'm interested in supporting is similar the the R environment, where I can point a reader to a csv file. It reads the file then allows immediate programmatic access to an object representation of it, with statistics, querying and visualization. This is no doubt done with dynamic typing in R, but perhaps using the dynamic compilation I showed above (or something far smarter as is Don's way) F# could do this with static typing.

Regards,

Daniel

By on 12/7/2007 10:48 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper