You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let jd = JulianDay(year: 2018, month: 1, day: 1) // Could be any date
let jupiter = Jupiter(julianDay: jd)
let saturn = Saturn(julianDay: jd)
let uranus = Uranus(julianDay: jd)
let neptune = Neptune(julianDay: jd)
let gasGiants = [jupiter, saturn, uranus, neptune]
print(saturn.magnitude.value) // Prints 0.479, as expected
print(gasGiants[1].magnitude.value) // Prints nan !!!
This is one of the very few cases where Swift language itself falls short. Saturn's object is both Planet and Saturn. Planet has it's own magnitude as default implementation of IlluminatedFraction protocol. Saturn has it's own magnitude as computed property. Due to static dispatch Swift calls wrong implementation for magnitude in some cases. More info in SR-103.
The text was updated successfully, but these errors were encountered:
Thanks Alexander, you're really up-to-date with these issues I have a hard time to follow. I remember wondering whether a "filling-empty-space" default implementation would be a good idea or not. It is not. I am focused on other things right now. If you have an idea on how to get around this problem... well, of course, I'm sure you'll submit it here. Thanks again!
Saturn magnitude is still buggy in some cases:
This is one of the very few cases where Swift language itself falls short. Saturn's object is both
Planet
andSaturn
. Planet has it's ownmagnitude
as default implementation ofIlluminatedFraction
protocol. Saturn has it's ownmagnitude
as computed property. Due to static dispatch Swift calls wrong implementation formagnitude
in some cases. More info in SR-103.The text was updated successfully, but these errors were encountered: