Standard interface for programatic structure definition
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- julia
调研方向
该 issue 没有指明文件、测试或现有入口点;请先查看当前的 StructTypes.jl API 以及提案中列出的相关包。要完成这项工作,需要就结构定义达成一项约定标准,包括一次性形式和增量形式,以及任何与 StructTypes 相关的扩展。
由索引模型根据 Issue 内容生成。
描述
I think it would be useful to have a standard interface for programmatic structure. Here I give the basic structure, but StructTypes related features can be added to the functions.
1-time function
functions API:
struct_define(struct_name::Symbol; fields_names::Vector{Symbol}, fields_types::Vector{Union{DataTypes, Symbol, Missing})
Example
struct_define(:Foo, [:a, :b, :c], [:Int64, missing, :String])
over-time method
functions API:
struct_define(struct_data::StructConstructor) # defines a struct based on the data
mutable struct StructConstructor
name::Symbol
fields_names::Vector{Symbol}
fields_types::Vector{Union{DataType, Symbol, Missing}}
end
# a constructor for when we know the name and number of fields:
function StructConstructor(nfields::Integer)
fields_names = Vector{Symbol}(undef, nfields)
fields_names = Vector{Union{DataType, Symbol, Missing}}(undef, nfields)
return StructConstructor(:TempName, fields_names, fields_names)
end
function StructConstructor(name::Symbol, nfields::Integer)
fields_names = Vector{Symbol}(undef, nfields)
fields_names = Vector{Union{DataType, Symbol, Missing}}(undef, nfields)
return StructConstructor(name, fields_names, fields_names)
end
Example
mystruct_data = StructConstructor()
mystruct_data = mystruct_data.name = :Foo # adds name
names = [:a, :b, :c]
types = [:Int64, missing, :String]
for (name, type) in zip(types, names)
push!(mystruct_data.fields_names, name)
push!(mystruct_data.fields_types, type)
end
struct_define(mystruct_data)
mystruct_data = StructConstructor(:Foo, 3)
names = [:a, :b, :c]
types = [:Int64, missing, :String]
for ifield = 1:3
mystruct_data.fields_names[ifield] = names[ifield]
mystruct_data.fields_types[ifield] = types[ifield]
end
struct_define(mystruct_data)
We can more feature such as
- the default value for the fields
- functions that check the values during the definition of an instance or updating
Related packages:
- 主要语言
- Julia
- 星标
- 86
- 派生
- 21
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
JuliaData/StructTypes.jl 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
JuliaData/StructTypes.jl#104 ·
-
难度 2/5 1-3 小时 新手友好度 45/100
JuliaData/StructTypes.jl#102 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 35/100
JuliaData/StructTypes.jl#98 · 2 条评论 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 30/100
JuliaData/StructTypes.jl#96 · 1 条评论 ·
-
`StructTypes.x` is not defined可能已有人在做 @sunoru 于 1125 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 25/100
JuliaData/StructTypes.jl#92 · 3 条评论 ·
查看 JuliaData/StructTypes.jl 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
CliMA/ClimaAtmos.jl#4891 · 1 条评论 ·
维护者通常 1 天内回复
-
tagbot-manual
难度 1/5 1 小时以内 新手友好度 75/100
tshort/StaticCompiler.jl#191 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
SciML/SciMLSensitivity.jl#1703 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
JuliaGPU/GPUCompiler.jl#1008 ·
维护者通常 1 天内回复
-
`biggs6` disagrees with CUTEst and is unbounded below可能已有人在做 @timholy 于 1 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 68/100