juliacomputing / easyconfig.jl Goto Github PK
View Code? Open in Web Editor NEWEasy-to-write JSON-like data structure for Julia
License: MIT License
Easy-to-write JSON-like data structure for Julia
License: MIT License
Hello again!
I was thinking whether it would be possible or useful to create an AbstractConfig type where most of the AbstractDict interface functions are defined, and make just Config a default concrete subtype.
I don't know if it could have drawbacks, but it would allow to create a different more specific subtype (like PlotlyConfig) to solve the problem here JuliaComputing/PlotlyLight.jl#12 by just defining a custom method for
setproperty!(o::PlotlyConfig, k::Symbol, v)
to ensure that 2D arrays are stored as vectors of vectors.
I did not think into details about possible corner cases but I guess having the abstract type might give only potential benefits.
Sorry about the weird title, I don't really know how to call this behavior as I'm not quite sure what's happening here.
julia> cfg = Config(x=0)
Config with 1 entry:
:x => 0
julia> cfg.f()=begin
return cfg.x+1
end
julia> cfg
Config with 1 entry:
:x => 0
julia> cfg.x #tab only shows x as a potential keyword
julia> cfg.f()
1
julia> cfg. #tab now shows f and x
f x
julia> cfg.f #f is not a function
Config()
julia> cfg.f() #but it is still callable
1
julia> c.┌ Error: Error in the keymap
│ exception =
│ MethodError: Cannot `convert` an object of type Config to an object of type Symbol
│ Closest candidates are:
│ convert(::Type{T}, ::T) where T at essentials.jl:171
│ Symbol(::Any...) at strings/basic.jl:227
│ Stacktrace:
│ [1] REPL.REPLCompletions.PropertyCompletion(::Config, ::Config) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPLCompletions.jl:30
│ [2] complete_symbol(::String, ::REPL.REPLCompletions.var"#21#25", ::Module) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPLCompletions.jl:150
│ [3] completions(::String, ::Int64, ::Module) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPLCompletions.jl:716
│ [4] completions(::String, ::Int64) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPLCompletions.jl:580
│ [5] complete_line(::REPL.REPLCompletionProvider, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:464
│ [6] complete_line(::REPL.LineEdit.PromptState, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:329
│ [7] complete_line(::REPL.LineEdit.MIState) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:320
│ [8] edit_tab(::REPL.LineEdit.MIState, ::Any, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:2032 (repeats 2 times)
│ [9] (::REPL.LineEdit.var"#109#162")(::Any, ::Any, ::Vararg{Any,N} where N) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:2073
│ [10] #invokelatest#1 at ./essentials.jl:710 [inlined]
│ [11] invokelatest at ./essentials.jl:709 [inlined]
│ [12] (::REPL.LineEdit.var"#22#23"{REPL.LineEdit.var"#109#162",String})(::Any, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:1364
│ [13] prompt!(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:2447
│ [14] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:2350
│ [15] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:1143
│ [16] (::REPL.var"#38#42"{REPL.LineEditREPL,REPL.REPLBackendRef})() at ./task.jl:356
└ @ REPL.LineEdit /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:2449
Easy fix. I'll get to it today.
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
The first example provided in the README does not seem to correctly initialize a Config object (at least on Julia 1.7.1 on Windows)
julia> c = Config().one.two.three = 1
1
julia> c
1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.