And by the way how can I submit F# code snippets here? As you can see from my F# code above some characters are lost

By on 3/28/2009 8:45 PM ()

Constraints are in section 5 of the F# spec. Specifically you want the constraint "not struct".

1
2
3
4
5
6
7
8
9
10
 

> type Foo<'a when 'a : not struct>(a:'a) =  member x.test = a ;;

type Foo<'a when 'a : not struct> =
  class
    new : a:'a -> Foo<'a>
    member test : 'a
  end

The easiest way to insert code is to go to your profile preferences and change the editbox to be for "Developers". Then it'll give you icons to do it. Alternatively, click quote or reply to a message with proper code and see how they do the square bracket code tags.

By on 3/28/2009 8:55 PM ()

Will it not be enough doing this:

1
2
let DoSomething<'a when 'a : null>(value : 'a) = ...

Since it can be null - it's not a structure :). WDYT?

Since in some cases you would like to match input parameter against null:

1
2
3
4
5
6
match value with

| null -> ...

| _ -> ...

which will not be possible with just 'not struct' constraint. I'm not sure if it's a small bug in F#, but I think that 'not struct' implies that value can automatically be null. Please correct me if I'm wrong.

By on 6/9/2011 4:43 PM ()

I've also got a question what is this tag for "abstract class MyClass "

Thanks,

Edwina - weight loss programs

By on 7/2/2011 3:55 AM ()

The use of type except for your base-interface approach and There is no syntax to mean "any interface".
use an abstract class inseted.

By on 9/29/2011 5:28 AM ()

Thank you Michael!

By on 3/28/2009 11:10 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