Stipple.jl: Using @in variable with same name as function's keyword argument yields "invalid keyword argument name"
If a keyword argument is used inside the @handlers, then an @in or @out variable with the same name cannot be defined.
Here’s a MWE
using GenieFramework
@genietools
function test(;msg="hi")
println(msg)
end
@handlers begin
@in msg = ""
@onchange msg begin
test(;msg="")
end
end
function ui()
[textfield("Message", :msg)]
end
@page("/", ui)
Server.isrunning() || Server.up()
And the error I’m getting
julia> includet("mwe.jl")
ERROR: [ Info: 2023-01-11 16:05:53 Watching ["/Users/pere/genie/demos/GenieFrameworkDemos_NewAPI/Database/mwe"]
syntax: invalid keyword argument name "__model__.msg[]" around /Users/pere/genie/demos/GenieFrameworkDemos_NewAPI/Database/mwe/mwe.jl:11
Stacktrace:
[1] top-level scope
@ none:1
in expression starting at /Users/pere/genie/demos/GenieFrameworkDemos_NewAPI/Database/mwe/mwe.jl:8
If I change the variable’s name then it all works.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 21 (21 by maintainers)
With #159 we now have
Note that it is no longer necessary to have
@onchangeany@cleardeletes REACTIVE_STORAGE and HANDLERS. The use case is interactive development of models at the REPL. We already have some ReactiveTools demos on StippleDemos.jl which are all working on the REPL. If you execute one after the other they might not work without calling@clear.The new
@modelmacro does clear the storage, so if we stick to that syntax in the future we won’t have problems.This could be done, but I’m not sure how important this is for users. Furthermore, it’s not clear what should happen with the handler. If it is a specific handler with
on()it’s clear, but if it’s a handler with mutliple input variablesonany()we would need to see whether the variable is used and remove only the trigger from the list of observables. It would require a larger refactoring, I think. I could imagine a Dict rather than a vector, but what would we do with identical set of trigger variables…Well to be specific the assumption was one model type per module, but I was talking of model instances