I have inadvertently made this mistake:

```
F(x, f::F) where F = f(x)
julia> F(0.5, sin)
ERROR: MethodError: no method matching F(::Float64, ::typeof(sin))
```

Shouldn’t the first line throw and error or are there cases where that is useful?

I have inadvertently made this mistake:

```
F(x, f::F) where F = f(x)
julia> F(0.5, sin)
ERROR: MethodError: no method matching F(::Float64, ::typeof(sin))
```

Shouldn’t the first line throw and error or are there cases where that is useful?

I don’t see why we’d need to prohibit something like:

```
foo(x, ::typeof(foo)) = 3x
foo(x, g::G) where {G} = g(x)
foo(2, foo)
foo(2, abs2)
```

EDIT:

Wrong answer, see below.

Maybe I shouldn’t answer questions at 3am. Obviously `::F`

isn’t the same as `::typeof(F)`

.

2 Likes

the code with `F`

twice doesn’t actually create a method:

```
julia> F(x, f::F) where F = f(x)
F (generic function with 0 methods)
```

4 Likes