Neat, seems a little like

[link:amazedsaint.blogspot.com]

but better-suited to F#. I would be interested to play around with this if I could find the time :)

By on 3/8/2010 8:28 AM ()

S-expression in F#, nice.

I have a question for the ? and ?<- construct though.

What happens if I accidentally use it in a format not covered by your static member definition ? Would it be silently ignored or be a compilation error ?

Another side note, would it be visually cleaner to use Map construct for the attributes and List construct for child nodes ? That said, I don't know if there is a special construct for Map in F# as it is not considered as a primitive data structure as in python for example ?

By on 3/8/2010 12:29 PM ()

S-expression in F#, nice.

I have a question for the ? and ?<- construct though.

What happens if I accidentally use it in a format not covered by your static member definition ? Would it be silently ignored or be a compilation error ?

Depends on whether or not it's a list.This sort of thing is a compile-time error:

1
2
3
4
5
type Tnx() = class end

let exampleWithSomethingThatDoesntCompile =
  let f = h?table <- Tnx()  // Compile error here
  ()

However, if you feed <- a list, it'll compile but die at runtime:

1
2
3
4
5
type Tnx() = class end

let exampleWithSomethingThatDoesntCompile =
  let f = h?table <- [Tnx()]  // No compile error here
  ()

The ?<- operator overloads include one that takes a List<obj>, so [Tnx()] is accepted.

Another side note, would it be visually cleaner to use Map construct for the attributes and List construct for child nodes ? That said, I don't know if there is a special construct for Map in F# as it is not considered as a primitive data structure as in python for example ?

There's nothing like Ruby or Python's map syntax in F# that I know about. Maps are just libraries.

If someone has a better idea for syntax for how to differentiate between attributes and children, I'd be perfectly happy to come up with an implementation. I'm not really satisfied with the current scheme, but haven't thought of anything better.

By on 3/8/2010 1:59 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