Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VarNames.jl

Stable docs

This package provides two types, VarName and VarNamedTuple, along with associated functionality.

These types were originally developed for use in Turing.jl, and the code is directly lifted from its dependencies (with some usability improvements). However, they are general enough to be useful in other contexts and so have been extracted into a separate package.

VarName

A VarName, most simply, is a data structure which represents an address which can be assigned to. That is to say, it is a representation of an expression which can be used on the left-hand side of an assignment. These include plain symbols (x and y), along with indexed expressions (x[1]), property accesses (x.y), and combinations thereof (x[1].y).

VarNamedTuple

A VarNamedTuple is a mapping from VarNames to values. They are more general than NamedTuples in that they can contain VarNames which are not valid Symbols, such as x[1] or x.y. Unlike Dicts, VarNamedTuples are designed to retain the relationship between sibling VarNames. For example, you can store x[1] and x[2] in a VarNamedTuple, and then access x[1:2], or even x[:] or x (as long as the VarNamedTuple knows that x is a length-2 vector).

VarNamedTuples are also much more performant than Dicts, and in the case where only Symbols are used, they have identical performance to NamedTuples, making them a zero-cost abstraction.

About

VarName and VarNamedTuple

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages