Re:The Crystal Programming Language
by IshKebab on Monday April 16, 2018 @06:13PM
(#16853333)
That sounds like how you have to access JSON data dynamically in any statically typed language.
[ Parent
| on HN ]
Re:The Crystal Programming Language
by actsasbuffoon on Tuesday April 17, 2018 @05:28PM
(#16862465)
But these other languages wouldn't necessarily remain type-safe.
The functor approach doesn't involve any type casting, and null pointer exceptions are impossible.
So, like this sort of thing:
int JsonValue::getAsInt(int defaultIfError);
Or, in Go:
func (JsonValue*) AsInt() (int64, error)
Or are you just talking about it returning the value as a Rust-style Result sum type?