# Does Julia syntax do enough to encourage type stability?

**URL:** https://discourse.julialang.org/t/does-julia-syntax-do-enough-to-encourage-type-stability/2219
**Category:** Internals & Design
**Tags:** type-stability
**Created:** [February 21, 2017, 5:30pm UTC](https://discourse.julialang.org/t/does-julia-syntax-do-enough-to-encourage-type-stability/2219 "2017-02-21T17:30:06Z")
**Posts on this page:** 3
**Page:** 2

<div class="post-metadata">

### Author: ![quinnj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/quinnj/32/11_2.png) [@quinnj](https://discourse.julialang.org/u/quinnj)
#### Post date: [February 22, 2017, 3:01pm UTC](https://discourse.julialang.org/t/does-julia-syntax-do-enough-to-encourage-type-stability/2219/21 "2017-02-22T15:01:33Z")

</div>

I think a great “plugin” to facilitate this would be something like:

```julia
function foo(bar, baz)
    # do cool stuff w/ bar and baz, but I'm worried about type-instabilities
end

@example foo(1, "hey there sailor")

```

In this example, the `@example` macro would expand to the actual function call if Atom was evaluating, and `nothing` otherwise. That way it could be idiomatic to include these and Atom could automatically do `@code_warntype` based on the example provided. This probably has the limitation of only allowing a single `@example foo...` per function, but it still seems like a nice way to easily set things up.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [February 22, 2017, 3:31pm UTC](https://discourse.julialang.org/t/does-julia-syntax-do-enough-to-encourage-type-stability/2219/22 "2017-02-22T15:31:38Z")

</div>

Could it be possible to hook into the runtime via something like:

```julia
@disable_dynamic_dispatch begin
    code...
end

```

and if the runtime have to do a dynamic dispatch call within that block, an error with information is raised.

---

<div class="post-metadata">

### Author: ![MikeInnes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikeinnes/32/3656_2.png) [@MikeInnes](https://discourse.julialang.org/u/MikeInnes)
#### Post date: [February 22, 2017, 5:58pm UTC](https://discourse.julialang.org/t/does-julia-syntax-do-enough-to-encourage-type-stability/2219/23 "2017-02-22T17:58:16Z")

</div>

Incidentally, this has been part of the GSoC projects list since forever: [http://julialang.org/soc/projects/tooling.html#performance-linting](http://julialang.org/soc/projects/tooling.html#performance-linting)

So if anyone is interested in making this happen, that would be a great way to do it.

[Previous page](https://discourse.julialang.org/t/does-julia-syntax-do-enough-to-encourage-type-stability/2219.md?page=1)
