1
1
"""
2
- VarName( sym[, indexing=()] )
2
+ VarName{ sym}( indexing::Tuple =())
3
3
4
4
A variable identifier for a symbol `sym` and indices `indexing` in the format
5
5
returned by [`@vinds`](@ref).
@@ -10,30 +10,30 @@ stores the indices requires to access the random variable from the Julia variabl
10
10
as a tuple of tuples. Each element of the tuple thereby contains the indices of one indexing
11
11
operation.
12
12
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
14
14
indexing expression through the [`@varname`](@ref) convenience macro.
15
15
16
16
# Examples
17
17
18
18
```jldoctest
19
- julia> vn = VarName(:x, ((Colon(), 1), (2,)))
19
+ julia> vn = VarName{:x}( ((Colon(), 1), (2,)))
20
20
x[Colon(),1][2]
21
21
22
22
julia> vn.indexing
23
23
((Colon(), 1), (2,))
24
24
25
- julia> VarName(AbstractPPL.@vsym(x[:, 1][1+1]), AbstractPPL.@vinds( x[:, 1][1+1]))
25
+ julia> @varname x[:, 1][1+1]
26
26
x[Colon(),1][2]
27
27
```
28
28
"""
29
29
struct VarName{sym, T<: Tuple }
30
30
indexing:: T
31
- end
32
31
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
34
34
35
35
"""
36
- VarName(vn::VarName[ , indexing=()] )
36
+ VarName(vn::VarName, indexing=())
37
37
38
38
Return a copy of `vn` with a new index `indexing`.
39
39
46
46
```
47
47
"""
48
48
function VarName (vn:: VarName , indexing:: Tuple = ())
49
- return VarName {getsym(vn), typeof(indexing) } (indexing)
49
+ return VarName {getsym(vn)} (indexing)
50
50
end
51
51
52
52
@@ -249,11 +249,11 @@ macro varname(expr::Union{Expr, Symbol})
249
249
return esc (varname (expr))
250
250
end
251
251
252
- varname (expr :: Symbol ) = VarName (expr )
252
+ varname (sym :: Symbol ) = :( $ (AbstractPPL . VarName){ $ ( QuoteNode (sym))}() )
253
253
function varname (expr:: Expr )
254
254
if Meta. isexpr (expr, :ref )
255
255
sym, inds = vsym (expr), vinds (expr)
256
- return :($ (AbstractPPL. VarName)( $ (QuoteNode (sym)), $ inds))
256
+ return :($ (AbstractPPL. VarName){ $ (QuoteNode (sym))}( $ inds))
257
257
else
258
258
throw (" Malformed variable name $(expr) !" )
259
259
end
@@ -269,13 +269,13 @@ For example, `@vsym x[1]` returns `:x`.
269
269
## Examples
270
270
271
271
```jldoctest
272
- julia> AbstractPPL. @vsym x
272
+ julia> @vsym x
273
273
:x
274
274
275
- julia> AbstractPPL. @vsym x[1,1][2,3]
275
+ julia> @vsym x[1,1][2,3]
276
276
:x
277
277
278
- julia> AbstractPPL. @vsym x[end]
278
+ julia> @vsym x[end]
279
279
:x
280
280
```
281
281
"""
@@ -307,19 +307,19 @@ Returns a tuple of tuples of the indices in `expr`.
307
307
## Examples
308
308
309
309
```jldoctest
310
- julia> AbstractPPL. @vinds x
310
+ julia> @vinds x
311
311
()
312
312
313
- julia> AbstractPPL. @vinds x[1,1][2,3]
313
+ julia> @vinds x[1,1][2,3]
314
314
((1, 1), (2, 3))
315
315
316
- julia> AbstractPPL. @vinds x[:,1][2,:]
316
+ julia> @vinds x[:,1][2,:]
317
317
((Colon(), 1), (2, Colon()))
318
318
319
- julia> AbstractPPL. @vinds x[2:3,1][2,1:2]
319
+ julia> @vinds x[2:3,1][2,1:2]
320
320
((2:3, 1), (2, 1:2))
321
321
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]]
323
323
((2:3, 2:3), ([1, 2], [1, 2]))
324
324
```
325
325
@@ -341,10 +341,10 @@ suitable for input of the [`VarName`](@ref) constructor.
341
341
## Examples
342
342
343
343
```jldoctest
344
- julia> AbstractPPL. vinds(:(x[end]))
344
+ julia> vinds(:(x[end]))
345
345
:((((lastindex)(x),),))
346
346
347
- julia> AbstractPPL. vinds(:(x[1, end]))
347
+ julia> vinds(:(x[1, end]))
348
348
:(((1, (lastindex)(x, 2)),))
349
349
```
350
350
"""
0 commit comments