# Know whether a value is a "core" Julia type

**URL:** <https://discourse.julialang.org/t/know-whether-a-value-is-a-core-julia-type/66190>\
**Category:** General Usage\
**Tags:** serialization\
**Created:** [August 11, 2021, 10:15am UTC](https://discourse.julialang.org/t/know-whether-a-value-is-a-core-julia-type/66190 "2021-08-11T10:15:44Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [August 22, 2021, 8:02am UTC](https://discourse.julialang.org/t/know-whether-a-value-is-a-core-julia-type/66190/11 "2021-08-22T08:02:26Z")

</div>

You have waay too many explicit type checks and custom functions for writing. Use `write(io, num, T::Number)` instead of `writenum(io, num, T)`. `write(io, str::String)` instead of `writestr(io, str)`. Use dispatch to your advantage, not to build explicit `ifelse` trees.

In reading, having a table converting tags to types is fine, but again - use dispatch to your advantage. `read(io, T::Number)` instead of `readnum(io, T)`. Call it via `tag = read(io, UInt8); read(io, tag2type[tag]` instead of manually doing `ifelse`s.

I think I’ve read your thread on that topic and I seem to remember that the code you’ve posted here was not one of the recommended ways of doing what you’re thinking of. Probably best for another topic though, would get OT here.

---

_[View the full topic](https://discourse.julialang.org/t/know-whether-a-value-is-a-core-julia-type/66190)._
