thoughtcoder 167 Junior Poster

Static Polymorphism (the compile-time) means basically those language structure which will cause the compiler to produce code at the compile-time. That is, the compiler is well aware that what code is to be generated at the compile-time itself. The example includes: specifically overloading of operators, functions.

And template metaprogramming.

As you know, the Shape.h will be compiled differently, hence the compiler won't know what code should be generated when someone calls Shape->Draw().

Uh, no, the compiler knows exactly what code to generate: something that looks up a function pointer specified by the object and calls that function.

Hence , he delays(whence the name Late Binding) the code generation.

Uh, no. Code isn't generated at runtime when calling virtual functions.

I guess you were under emotional pressure when making that post.

iamthwee commented: Your grammar is much better than the person below you. And you're from Bangalore too Sammy! +20
thoughtcoder 167 Junior Poster

I fail to understand why this thread is named what it is. No one's interested in Rashakil Fol anymore I guess.

I am very interested in him.* He is the reason I joined this forum.

You should unban him! I bet you are just jealous of the size of his Young modulus.

* Not in the way in which I am interested in Serkan.

Nick Evan commented: It's kinda funny how much the two of you have in common. It's like you're one and the same person ;) +17
iamthwee commented: I would agree with niek_e's observation. +19
thoughtcoder 167 Junior Poster

No.

thoughtcoder 167 Junior Poster

Well I guess if you're Turkish then you can't be blamed for inheriting some of its stalker culture.

jephthah commented: aha +8
thoughtcoder 167 Junior Poster

The language versions are called C# 2 and C# 3. It's perfectly fine to start with C# 2.

thoughtcoder 167 Junior Poster

Wouldn't this advice depend on your location? Reveal that information to us. I'm guessing by your hair color and sun-exposure level that you're Canadian or Alaskan.

Edit: on the other hand, the lipstick makes me think you must be some kind of english dandy.

jbennet commented: thats not very nice -7
ahihihi... commented: ek-ek.. :) +1
jephthah commented: if you're going to be a jerk, at least have a reason +6
thoughtcoder 167 Junior Poster

You people are so sexually repressed. There's nothing so cathartic as seeing a well-animated tentacle monster trapping a 12-year-old virgin in a library and challenging her to a Boggle contest, where the winner gets tickets to the next Jonas Brothers concert.

Nick Evan commented: Haha :) +15
~s.o.s~ commented: Wha..? I thought the monster intended to film his next fairness cream ad! ;-) +27
ddanbe commented: He seems I love the Jonas Brothers as much as you do. +4
thoughtcoder 167 Junior Poster

//if list is not empty and n is not zero then create two branches. Both these branches will have a list of length one less and n one less than before. This keeps happening till the stopping condition above is fulfilled
createTree ([x],n) = Node ([x],n) (createTree (removeOne ([x],n))) (createTree (removeOne ([x],n)))

This is where you're wrong. The pattern "[x]" matches only lists of length 1. The element in the list gets bound to the variable x.

If you want the pattern to match any list, use "createTree (xs, n) = ...".

Or just "createTree pair = ..."

Your createTree function still seems a little funky so we'll see if you have more questions.

artemis_f commented: very helpful about haskell! thanks +1
thoughtcoder 167 Junior Poster

Ok, the only problem with that is that it is (i believe) not a usual way to do this. I might forget that the project used functions for conversion, and if someone else did need to use libraries written by me, they might not even think about the possibility that functions were used for conversion. Am I right?

No. I would expect people to use plain old functions. There are large downsides to explicit conversion operators -- mainly that using them makes it hard to identify the places where you're using run-time casts, because they look the same. Implicit conversion operators make it difficult to read code outside of the IDE. Which we do at my workplace, in code reviews and when we don't want to open up a file from another branch in a whole new IDE instance. Using plain old functions, calling them with x.ToBar() or Bar.FromFoo(x) or possibly new Bar(x) doesn't have either disadvantage. Since using plain old functions reduces the probability of making an error, it makes sense to use them.

On the other hand, there might be advantages to using the TypeConverter framework that I'm not familiar with. But converting between equivalent types isn't exactly a hard problem.

thoughtcoder 167 Junior Poster

I normally program in Java and Haskell to me seems completely alien and weird.

That's because it is. I normally program in Haskell and Java seems deficient and limiting. I don't think you really get a benefit out of learning Haskell until you learn more about type classes. But the benefit is huge.

All I want to do is read the contents of a file into a big string

Note that there is a function, readFile :: FilePath -> IO String , that does the opening and closing for you.

then be able to do stuff with that string ... Apparently I cannot convert an IO String to a String? But then how am I ever going to be able to use the functions I have written that need an input String?

He he he he he he he.

If I want to read a file and pass it to a function that needs a String, it's as simple as this:

countSpaces :: String -> Int
countSpaces s = length (filter (== ' ') s)

countSpacesInFile :: String -> IO Int
countSpacesInFile fileName = do
  text <- readFile fileName
  return (countSpaces text)

-- our program counts the number of spaces in input.txt
main :: IO ()
main = do
  n <- countSpacesInFile "input.txt"
  print n

In fact, you were already doing that, no? You were reading the contents of the file and passing it to the function storeReadFile, which happened to be doing nothing to it.

thoughtcoder 167 Junior Poster

C++ doesn't have automatic memory management, which is a very big deal. This means it takes a lot of knowledge to use the language efficiently. The language might be tolerable to people who have this knowledge, but not to those who lack it.

thoughtcoder 167 Junior Poster

You should learn modern HTML before trying to teach PHP.

Comatose commented: Taste It KHess! +12
SeanOBrian commented: good thought. clearly stated +0