1. you need not mark the class as abstract. However, if your class contanis one or more abstract members, the compiler will warn you. Likewise, if you inherit from a class with abstract members, and if you don't provide the child with an implementation for all abstract members (ie if some abstract members from the parent are not implemented by the child), the compiler will warn you too.

2. val are not hidden. They're equivalent to plain member with get, set.You can have private members using let bindings instead of val, as in :

1
2
3
4
 
type foo() =
  let x = 5
  member x.run() = print_int x

For your value that depends on other values, it depends on whether it depends on member values or on values passed to the constructor... An example fo what you want could help.

3. the following syntax does what you want (ie dispose the stream when you're done with it)

1
2
3
4
5
6
try
  use stream = File.OpenWrite("...")
  use writer = new StreamWriter(stream)
  ...
with
  _ -> print_string e.Message
By on 11/8/2007 6:56 AM ()

1. I think, a warning is a somewhat weak thing in this regard, because a missing implementation for something abstract inherited is an error. If there is no need for marking a class as abstract, it is not possible to see if a class is abstract if it implements an interface that's code is currently not visible.
What about the interface-abstract class-concrete class chain? What I wish to achieve is the equivalent to the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public interface IMyStuff
{
    public string MyProperty { get; set; }
    public void MyMethod();
}

public abstract class MyStuff : IMyStuff
{
    private string _myProperty = "";
    public string MyProperty { get { return _myProperty; } set { _myProperty = value; } }
    public abstract void MyMethod();
}

public class VerySpecialStuff
{
    public override void MyMethod() { do something ... }
}

2. The let bindings don't work out that well in classes, it would seem. I am referred to implicit construction sequences instead, where it is not implemented yet to have vals declared. Also, I prefer the ides of having the constructor parameters left with the constructors instead of putting them directly to the class definition. That avoids name clashes and gives more flexibility to the constructors. Why can't we just either have all vals be private (one can still write properties for those to be visible publicly) or at least the possibility to declare them likewise?

3. Ah cool. So the runtime takes care for that. How nice.

5. Calling .NET APIs
Naturally, much of the code being written in F# is making calls to the .NET API. I read somewhere that the arguments can be passed as tuples or in "normal" space separated style. This doesn't seem to be the case. When I try to call methods with more that one parameter, I am forced to use the tuple-style parameter passing. Is that true and why is it like that?

6. Light indentation problems
I like the #light option very much. But I have to admit that I sometimes wish for a bit more flexibility there. For example, when writing methods, that use pattern matching, I often would rather write

1
2
3
member this.DoSomethingWith parameter = match parameter with
 | whatever -> ...
 | _ -> ...

instead of having to put the "match parameter with" on the new line. When writing constructors with a then clause it will sometimes (not always) even force me to write everything up to the "then" on one line. When I changed a member writing a "private" in front of it, it had me indenting the method body two levels further without reason.
I don't know how much more flexibility could be provided there but I shall appreciate every improvement.

7. Calling constructors within constructors
Is it possible to call another constructor of the same class from a constructor? Currently, I find myself being forced to copy large "then" clauses of constructors to all of them or have them factored into a method. By the way: why is the syntax for constructors so "C#-ish" with needing parentheses, enclosing braces and semicola?

By on 11/9/2007 7:44 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