Open citizen428 opened 4 years ago
I have no idea why I didn't get a notification for this, but I'm just now seeing it. Thank you so much for sharing this! As I mentioned in the README, this was my first ever project with OCaml, so there was a lot I probably did "the hard way".
This is much more elegant that what I did! If I ever find the time to get back to this, I'll definitely research modules more!
I have no idea why I didn't get a notification for this
Haha, oh well, it wasn't exactly urgent. :-)
Thanks for your book btw, it was very enjoyable!
Since I'm implementing the Ray Tracer Challenge in F#, I sometimes come to this repository for inspiration. One thing that always "bothered" me a little bit was the relation between
Shape
and its implementations, likeSphere
. So now that I learned more about OCaml functors, I played around a bit and came up with an alternative implementation. It's obviously simplified (all the functions are dummies) and leaves out some of the related types likeRay
,Intersection
etc., but it should be enough to get the idea across:Or even:
I think this is quite nice and like that it allows us to call functions on the specific module instead of
Shape
.Anyway, just wanted to share this approach and didn't know a better way to get in touch 😃