I am using Makie with text sliders, and I would like to understand a strange behavior of map. Consider the code:
using Makie
sradius, s_marker_radius = textslider((0.5f0:0.25f0:10f0), "Radius", start=2.f0)
map(s -> sin(s), s_marker_radius)
s(s_marker_radius)
s_marker_radius is of type Observable{Any}. Obviously, sin(s_marker_radius) gives an error:
ERROR: MethodError: no method matching sin(::Observable{Any})
Closest candidates are:
sin(::Float16) at math.jl:1104
sin(::Complex{Float16}) at math.jl:1105
sin(::Missing) at math.jl:1157
...
Stacktrace:
[1] top-level scope at none:0
However, the map statement produces no error. Why is that? Won’t the sin function be applied to an argument of type Observable, which should generate an error? And yet it does not.
I find that there is a method
map(f, observable::Observables.AbstractObservable, os...; init)
so clearly, this explains why map does not crash. But it does not explain why the sin() function does not crash when applied to the Observable. It is as if to_value is applied surreptitiously in the background. That type of hidden behavior should be documented.
Thank you for any insight.