# Annotating global variable's type (v1.8) but only known at runtime

**URL:** https://discourse.julialang.org/t/annotating-global-variables-type-v1-8-but-only-known-at-runtime/82016
**Category:** General Usage
**Created:** [May 31, 2022, 9:44pm UTC](https://discourse.julialang.org/t/annotating-global-variables-type-v1-8-but-only-known-at-runtime/82016 "2022-05-31T21:44:21Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [June 1, 2022, 2:09am UTC](https://discourse.julialang.org/t/annotating-global-variables-type-v1-8-but-only-known-at-runtime/82016/2 "2022-06-01T02:09:32Z")

</div>

> [@Seven Lines of Julia (examples sought)](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416/157):
>
> In Julia v1.8 we’ll have the possibility of type-annotating global variables, to promise their type won’t change: julia\> x::Float64 = 3.14 3.14 julia\> x = 2.71 2.71 julia\> x = "hello world" ERROR: MethodError: Cannot `convert` an object of type String to an object of type Float64 Wouldn’t it be nice if we could automatically get the type annotation without having to explicitly type it ourselves? Here be dragons macros (note that the macro definition is exactly 7 lines): julia\> macro stable…

---

_[View the full topic](https://discourse.julialang.org/t/annotating-global-variables-type-v1-8-but-only-known-at-runtime/82016)._
