You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm surprised we haven't noticed this until now, but simple where clauses don't work right now:
Salsa.@derivedmulti_method(db::AbstractComponent, ::Type{T}) where T =sizeof(T)
The reason is because we are currently evaluating all the argument types to figure out what type of dictionary and key type to create for this function. We are currently using the (typeof(f) and Tuple{Type}) to represent individual methods like this, and so we were calling eval for each argument type in order to build that tuple, but if you attempt to eval(Type{T}), of course T is not defined.
There are a few approaches to take that would fix this:
Move the Key construction into the function body, instead of in the macro body, where the types are available. But we were doing it in the macro body because constructing the Dict() itself seemed to be expensive, and we were hoping to precompute this in the macro.
We should consider simplifying how we use these types for keys:
Maybe we should stop using separate dictionaries for each derived function, and just use one big dictionary for all derived functions?
And then, we can also stop keying the derived values by DependencyKey(key=DerivedKey{F, Tuple{Int,Any}}, args=(2,"hi")) and instead just key it by F and the actual args themselves, something like: DependencyKey{Derived, F}(2,"hi").
I don't think we actually need to keep track of which method was called, because julia can track that itself! The only problem would be if a user defines a new, more specific method after starting to use a Salsa state, in which case the key would incorrectly carry over to the new function, but I don't think that's a supported mode anyway.
The text was updated successfully, but these errors were encountered:
I'm surprised we haven't noticed this until now, but simple
where
clauses don't work right now:The reason is because we are currently evaluating all the argument types to figure out what type of dictionary and key type to create for this function. We are currently using the (
typeof(f)
andTuple{Type}
) to represent individual methods like this, and so we were callingeval
for each argument type in order to build that tuple, but if you attempt toeval(Type{T})
, of courseT
is not defined.There are a few approaches to take that would fix this:
Dict()
itself seemed to be expensive, and we were hoping to precompute this in the macro.DependencyKey(key=DerivedKey{F, Tuple{Int,Any}}, args=(2,"hi"))
and instead just key it byF
and the actual args themselves, something like:DependencyKey{Derived, F}(2,"hi")
.The text was updated successfully, but these errors were encountered: