Hacker News new | past | comments | ask | show | jobs | submit login

> As an example, if I was to invoke your function f with a floating point number, would Julia not happily specialize it for that too (assuming factorial was defined for floating points or taken out of the equation)?

Yes, but I could then define

    bar(x::Int64) = x^2 - 1
and this would create a method which only operates on 64 bit integers.

Now I want to be clear that I'm not saying Julia is a static language, I'm just saying that once specialization occurs, things are much more like a static language than one might expect, and indeed it's quite possible add mechanisms for instance to make a function error if it can't statically infer it's return type at compile time.

Here's a hacky proof of concept implementation, but one could get much more sophisticated: https://stackoverflow.com/questions/58071564/how-can-i-write...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: