On 2/28/19, Brian Craft <craft.br...@gmail.com> wrote: > So, when working with large data that is internal to an app, where schema > is guaranteed by serialization, there's no way to load that without another > O(N) pass to satisfy the type checker?
Right. This is how the type checker helps find & prevent bugs. There's no way to safely turn a JSExpr into a (Listof String) without proving that the data really is a list that really contains Strings and nothing else. If you know more about the schema and this O(N) pass is too slow, then you may want to write a function that parses a list from an input port and simultaneously checks the type of its elements. That will save 1 traversal. You can also delay the validation by writing functions that accept JSExpr data and perform pair? and string? checks as needed. This may or may not save time overall --- it depends on the program. Anything else is unsafe. (Wrapping in a struct helps if the (Listof String) needs to visit typed and untyped code.) -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.