Skip to content

MaxInertia/IFJuliaSrc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

Fun with MetaProgramming

MP Structs!

macro Struct(structName, fieldWithType)
    return :(
        struct $structName
            $fieldWithType
        end
    )
end

This enables (slightly) more concise struct definitions:

@Struct Time value::Number
@Struct Velocity value::Number
@Struct Displacement value::Number

You can use Generics too:

@Struct Time{T} value::T
@Struct Velocity{T} value::T
@Struct Displacement{T} value::T

Generics with Type Constraints:

@Struct Time{T <: Number} value::T
@Struct Velocity{T <: Number} value::T
@Struct Displacement{T <: Number} value::T

About

Learning Julia!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages