Hacker News new | ask | show | jobs
by azolotko 2745 days ago
I suppose you meant boxing/unboxing. If so, yes, that's necessary for primitive types. As for regular objects, no casts are needed.

Regarding TCO, that's a well known limitation of the current Scala compiler. Hardly a "horror story".

Let me assure you, there are plenty of platforms where F# is nowhere to be seen. Thus, "can run on any platform [I care about]", which is a different set for different people anyway. For example, F# does not run on JVM, does it?

1 comments

Dude, JVM is not a platform but a runtime. Why is it relevant to run F# on JVM? The important thing is to run F# in any hardware/OS, that's my point.

> As for regular objects, no casts are needed.

Are you sure? See https://stackoverflow.com/a/10126425/544947

> Hardly a "horror story".

F# doesn't have this limitation and F# does tailcalls by default instead of having to explicitly remember to decorate it with the @tailrec attribute.

You have a pretty narrow definition of a platform. Consider https://en.m.wikipedia.org/wiki/Computing_platform

Yes, you are right, I didn't consider the checkcast instruction.

Yes, F# does not have this particular limitation, but has few of its own in different places. Most notably, it lacks HKT (arguably, because of CLR awareness of generics).

BTW, alternative approaches to stack-safe recursion do exist in Scala. For example, https://github.com/slamdata/matryoshka

> Yes, F# does not have this particular limitation

And guess what? it doesn't have it because F# doesn't run on the JVM! If it run in the JVM, it would have it. So your obsession with "runtime" as a platform not only not useful, it's asking for trouble! ;)

Sounds like you are confused about what @tailrec does.

@tailrec is not necessary to enable tailcalls.

All the annotation does is error if a function is not able to be optimized for tail calls.

The (attempt at) optimization takes place either way, you don't need the annotation unless there's some doubt in your mind.