option/Some/None is not perfect solution, because this properies used in C# module.

I'm not sure I understand... aren't let-bindings in a class private? If so, how are you going to use them in C# context, anyway?

By on 6/25/2009 2:54 PM ()

Oh, one other thing, regarding attributes. Sometimes, you find yourself adding a lot of attributes, and it looks really ugly having big long names. In this case, you can use F#'s type aliases:

1
2
3
4
type DV = DefaultValueAttribute
type Bla = 
    [<DV>]
    val mutable id : int


That reduces the visual noise a bit.

By on 6/25/2009 1:56 PM ()

// MichaelGG

thank you for the helpful tips,

they rescue me a lot :)

// int19h

yes, let is private,

to access let definition from C# or outside of class,

bunch of annoying properties are needed :(

but, I does not complain this,

let is private, it's good, it's right,

We just need some helper like C# automatic property,

or DefaultValue-attr-less, initializeable val,

it will be enough,

By on 6/26/2009 12:14 AM ()

Hi!

Yes, sometimes F# interop can require a bit more work to figure out. We are also using ASP.NET MVC, and there were a few things we had to deal with. However, I think you will see that overall, F# is a major win, even with a bit of extra work for certain interop. The amount of extra code you type is less than all the extra type definitions you'd need in C# anyways ;).

Looking at your code, it seems you have a problem with setting an F# class to null. I would recommend not setting it to null, but if you must, then what you want is this:

1
 let mutable SomeFSharpValue = Unchecked.defaultof<_>

Notice you don't always need to specify the type. It will figure it out from constraints later on (like, if you pass the value to a function).

But, I agree that it can be a pain to declare a bunch of "C#-normal", default value properties. C# 3 has automatic properties -- I think F# would benefit from something like that to let us quickly make class types that fit a certain schema.

On my site I just wrote about how to make ASP.NET MVC bind to F# records: [link:www.atrevido.net] -- Maybe that will help you in other places.

By on 6/25/2009 1:52 PM ()
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