# Is there a way to include \`⅔\` in function name?

**URL:** <https://discourse.julialang.org/t/is-there-a-way-to-include-in-function-name/45378>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 22, 2020, 5:52pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-include-in-function-name/45378 "2020-08-22T17:52:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Post date:** [August 22, 2020, 5:52pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-include-in-function-name/45378/1 "2020-08-22T17:52:48Z")

</div>

I want to define a function named `^⅔`, which means

```julia
using SymPy: Sym

^⅔(x::Sym) = x^(2 // 3)
^⅔(x::Number) = x^(2 / 3)

```

That is, I need `2 // 3` for pretty-printing expressions in fractionals, but `2 / 3` for speed in real calculations. But it does not seem to be parsable:

```julia
julia> ^⅔(x) = x^(2 / 3)
ERROR: syntax: invalid character "⅔" near column 2
...

```

I wish to somehow keep the simple syntax `a^⅔` while I can dispatch on different types of `a`.

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [August 22, 2020, 5:57pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-include-in-function-name/45378/2 "2020-08-22T17:57:01Z")

</div>

`^` is an infix operator, so you can’t use it in identifiers. You need to give your function a different name. (If you really want to, you could use `var"^⅔"` as a name, but then you always need to write it like that with the `var`.)

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [August 22, 2020, 8:05pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-include-in-function-name/45378/3 "2020-08-22T20:05:02Z")

</div>

> [@simeonschaub](#):
>
> `^` is an infix operator, so you can’t use it in identifiers.

You could look through the table of [unicode input](https://docs.julialang.org/en/v1/manual/unicode-input/) for alternatives. For example, `\invv\2/3` which yields `ʌ⅔`.

Another idea would be something like this:

```julia
using SymPy: Sym, @vars

struct TwoThirds end
const _⅔ = TwoThirds()
Base.:(^)(x::Number, ::TwoThirds) = x^(2 / 3)
Base.:(^)(x::Sym, ::TwoThirds) = x^(2 // 3)

```

Now:

```julia
julia> a, b = @vars a b;

julia> 3.4 ^ _⅔
 2.261097438656042

julia> a * b ^ _⅔
    2/3
a⋅b

```

You could also define other methods for `TwoThirds()` like `+` or `*`.

---

<div class="post-metadata">

**Author:** ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Post date:** [August 22, 2020, 9:47pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-include-in-function-name/45378/4 "2020-08-22T21:47:40Z")

</div>

That’s exactly what I am using. Thank you!
