11"""
2- VarName( sym[, indexing=()] )
2+ VarName{ sym}( indexing::Tuple =())
33
44A variable identifier for a symbol `sym` and indices `indexing` in the format
55returned by [`@vinds`](@ref).
@@ -10,30 +10,30 @@ stores the indices requires to access the random variable from the Julia variabl
1010as a tuple of tuples. Each element of the tuple thereby contains the indices of one indexing
1111operation.
1212
13- `VarName`s can be manually constructed using the `VarName( sym, indexing)` constructor, or from an
13+ `VarName`s can be manually constructed using the `VarName{ sym}( indexing)` constructor, or from an
1414indexing expression through the [`@varname`](@ref) convenience macro.
1515
1616# Examples
1717
1818```jldoctest
19- julia> vn = VarName(:x, ((Colon(), 1), (2,)))
19+ julia> vn = VarName{:x}( ((Colon(), 1), (2,)))
2020x[Colon(),1][2]
2121
2222julia> vn.indexing
2323((Colon(), 1), (2,))
2424
25- julia> VarName(AbstractPPL.@vsym(x[:, 1][1+1]), AbstractPPL.@vinds( x[:, 1][1+1]))
25+ julia> @varname x[:, 1][1+1]
2626x[Colon(),1][2]
2727```
2828"""
2929struct VarName{sym, T<: Tuple }
3030 indexing:: T
31- end
3231
33- VarName (sym:: Symbol , indexing:: Tuple = ()) = VarName {sym, typeof(indexing)} (indexing)
32+ VarName {sym} (indexing:: Tuple = ()) where {sym} = new {sym,typeof(indexing)} (indexing)
33+ end
3434
3535"""
36- VarName(vn::VarName[ , indexing=()] )
36+ VarName(vn::VarName, indexing=())
3737
3838Return a copy of `vn` with a new index `indexing`.
3939
4646```
4747"""
4848function VarName (vn:: VarName , indexing:: Tuple = ())
49- return VarName {getsym(vn), typeof(indexing) } (indexing)
49+ return VarName {getsym(vn)} (indexing)
5050end
5151
5252
@@ -249,11 +249,11 @@ macro varname(expr::Union{Expr, Symbol})
249249 return esc (varname (expr))
250250end
251251
252- varname (expr :: Symbol ) = VarName (expr )
252+ varname (sym :: Symbol ) = :( $ (AbstractPPL . VarName){ $ ( QuoteNode (sym))}() )
253253function varname (expr:: Expr )
254254 if Meta. isexpr (expr, :ref )
255255 sym, inds = vsym (expr), vinds (expr)
256- return :($ (AbstractPPL. VarName)( $ (QuoteNode (sym)), $ inds))
256+ return :($ (AbstractPPL. VarName){ $ (QuoteNode (sym))}( $ inds))
257257 else
258258 throw (" Malformed variable name $(expr) !" )
259259 end
@@ -269,13 +269,13 @@ For example, `@vsym x[1]` returns `:x`.
269269## Examples
270270
271271```jldoctest
272- julia> AbstractPPL. @vsym x
272+ julia> @vsym x
273273:x
274274
275- julia> AbstractPPL. @vsym x[1,1][2,3]
275+ julia> @vsym x[1,1][2,3]
276276:x
277277
278- julia> AbstractPPL. @vsym x[end]
278+ julia> @vsym x[end]
279279:x
280280```
281281"""
@@ -307,19 +307,19 @@ Returns a tuple of tuples of the indices in `expr`.
307307## Examples
308308
309309```jldoctest
310- julia> AbstractPPL. @vinds x
310+ julia> @vinds x
311311()
312312
313- julia> AbstractPPL. @vinds x[1,1][2,3]
313+ julia> @vinds x[1,1][2,3]
314314((1, 1), (2, 3))
315315
316- julia> AbstractPPL. @vinds x[:,1][2,:]
316+ julia> @vinds x[:,1][2,:]
317317((Colon(), 1), (2, Colon()))
318318
319- julia> AbstractPPL. @vinds x[2:3,1][2,1:2]
319+ julia> @vinds x[2:3,1][2,1:2]
320320((2:3, 1), (2, 1:2))
321321
322- julia> AbstractPPL. @vinds x[2:3,2:3][[1,2],[1,2]]
322+ julia> @vinds x[2:3,2:3][[1,2],[1,2]]
323323((2:3, 2:3), ([1, 2], [1, 2]))
324324```
325325
@@ -341,10 +341,10 @@ suitable for input of the [`VarName`](@ref) constructor.
341341## Examples
342342
343343```jldoctest
344- julia> AbstractPPL. vinds(:(x[end]))
344+ julia> vinds(:(x[end]))
345345:((((lastindex)(x),),))
346346
347- julia> AbstractPPL. vinds(:(x[1, end]))
347+ julia> vinds(:(x[1, end]))
348348:(((1, (lastindex)(x, 2)),))
349349```
350350"""
0 commit comments