Coder Social home page Coder Social logo

mixers.jl's People

Contributors

femtocleaner[bot] avatar hhaensel avatar juliatagbot avatar kristofferc avatar rafaqz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mixers.jl's Issues

How about mixing functions?

This is a neat idea to copy fields from one type to another. Is there a convenient way to do the same for functions?

TagBot trigger issue

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!

@mix doesn't work with module qualified macros

MWE:

using Mixers

@mix Base.@kwdef struct Foo
    bar = 1
end

fails with error:

ERROR: LoadError: MethodError: Cannot `convert` an object of type Expr to an object of type Symbol
Closest candidates are:
  convert(::Type{T}, ::T) where T at essentials.jl:205
  Symbol(::Any...) at strings/basic.jl:229
Stacktrace:
  [1] push!(a::Vector{Symbol}, item::Expr)
    @ Base ./array.jl:932
  [2] chained_macros!(macros::Vector{Symbol}, ex::Expr)
    @ Mixers ~/.julia/packages/Mixers/f3AVv/src/Mixers.jl:87
  [3] chained_macros
    @ ~/.julia/packages/Mixers/f3AVv/src/Mixers.jl:83 [inlined]
  [4] defmacro(ex::Expr, prepend::Bool)
    @ Mixers ~/.julia/packages/Mixers/f3AVv/src/Mixers.jl:37
  [5] var"@mix"(__source__::LineNumberNode, __module__::Module, ex::Any)
    @ Mixers ~/.julia/packages/Mixers/f3AVv/src/Mixers.jl:24
  [6] eval
    @ ./boot.jl:360 [inlined]
  [7] eval
    @ ./Base.jl:39 [inlined]
  [8] repleval(m::Module, code::Expr, #unused#::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/repl.jl:157
  [9] (::VSCodeServer.var"#69#71"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/repl.jl:123
 [10] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:491
 [11] with_logger
    @ ./logging.jl:603 [inlined]
 [12] (::VSCodeServer.var"#68#70"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/repl.jl:124
 [13] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
 [14] invokelatest(::Any)
    @ Base ./essentials.jl:706
 [15] macro expansion
    @ ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
 [16] (::VSCodeServer.var"#53#54")()
    @ VSCodeServer ./task.jl:411
in expression starting at REPL[10]:1

but

using Mixers
using Base: @kwdef

@mix @kwdef struct Foo
    bar = 1
end

works fine.

Mixers v0.1.1 on:

julia> versioninfo()
Julia Version 1.6.5
Commit 9058264a69 (2021-12-19 12:30 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 4

Could @Premix and @mix be linked to an abstract type?

Someithing like:

abstract type Drink

@premix @with_kw struct Fruitjuice{P,B}     {link to Drink}
    pommegranite::P
    orange::B
end

@mix @with_kw struct Soda{J}                {link to Drink}
    soda::J = 2u"L"
end

So that

struct Punch{L} <: Drink
    vodka::L
end

would be equivalent to

@Fruitjuice @Soda struct Punch{L} 
    vodka::L
end

Sorry If I've misunderstood the proper usage.

Generate mix or premix from existing (mixed) structs?

First, great package, thanks for that!

Is there any fancy way to use @mix or @premix on existing mixed structs? I need a bit more nested levels...

Here is a non-working dummy example:

@premix struct FooTemplate
    x
end

@FooTemplate struct Bar
    y
end

# now create a @BarTemplate which contains both x and y 

@premix BarTemplate Bar   # this will of course not work

@BarTemplate Baz
    z
end

So that Baz now has the fields x, y and z.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.