f# - Why do I see the Program+ prefix when printfn tries to print an object? -
i have object of class created, printing object %a format specifier, see typename program+myclass instead of myclass ? why that?
someone might programme namespace, if how come not able next ?
let o = program+myclass()
here total code
open scheme type myclass() = fellow member val x = 3 get,set [<entrypoint>] allow main argv = allow o = myclass() o |> printfn "here myclass object %a" console.readkey() 0 // homecoming integer exit code
as john correctly explains, part before +
in program+myclass
there because code compiled program
module. f# modules compiled nested classes , myclass
nested class within program
(which static class) , +
comes standard .net naming of nested classes.
you can avoid putting class in namespace (but you'll still need have main
function in module):
namespace myprogram open scheme type myclass() = fellow member val x = 3 get,set module main = [<entrypoint>] allow main argv = allow o = myclass() o |> printfn "here myclass object %a" console.readkey() 0 // homecoming integer exit code
now, myclass
straight in namespace (not nested class) , print without program+
prefix.
f# c#-to-f#
No comments:
Post a Comment