From 2024167e11287aead6e4a6f95c029b9f84361d8d Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sun, 19 Aug 2012 23:14:50 -0400 Subject: [PATCH 1/4] possible fix for #1178 --- base/array.jl | 2 +- base/sort.jl | 10 +++++----- extras/bitarray.jl | 2 +- extras/glpk.jl | 4 ++-- src/julia-parser.scm | 18 ++++++++++++++---- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/base/array.jl b/base/array.jl index 267acb6b287c0..a43550896ceeb 100644 --- a/base/array.jl +++ b/base/array.jl @@ -1752,7 +1752,7 @@ function permute(A::StridedArray, perm) #inner most loop toReturn[1] = quote - P[ind] = A[+($counts...)+offset] + P[ind] = A[+($(counts...))+offset] ind+=1 $counts[1]+= $stridenames[1] end diff --git a/base/sort.jl b/base/sort.jl index d9489ae127ca5..8a3be9b4c4cd4 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -286,7 +286,7 @@ macro in_place_matrix_op(out_of_place, args...) in_place = esc(symbol("$(out_of_place)!")) out_of_place = esc(out_of_place) quote - function ($in_place)(($args...), a::AbstractMatrix, dim::Int) + function ($in_place)($(args...), a::AbstractMatrix, dim::Int) m = size(a,1) if dim == 1 for i = 1:m:numel(a) @@ -300,11 +300,11 @@ macro in_place_matrix_op(out_of_place, args...) return a end # TODO: in-place generalized AbstractArray implementation - ($in_place)(($args...), a::AbstractArray) = ($in_place)($(args...), a,1) + ($in_place)($(args...), a::AbstractArray) = ($in_place)($(args...), a,1) - ($out_of_place)(($args...), a::AbstractVector) = ($in_place)($(args...), copy(a)) - ($out_of_place)(($args...), a::AbstractArray, d::Int) = ($in_place)($(args...), copy(a), d) - ($out_of_place)(($args...), a::AbstractArray) = ($out_of_place)($(args...), a,1) + ($out_of_place)($(args...), a::AbstractVector) = ($in_place)($(args...), copy(a)) + ($out_of_place)($(args...), a::AbstractArray, d::Int) = ($in_place)($(args...), copy(a), d) + ($out_of_place)($(args...), a::AbstractArray) = ($out_of_place)($(args...), a,1) end end diff --git a/extras/bitarray.jl b/extras/bitarray.jl index 4a06f7d7e1e2c..6ee49f5cbf49f 100644 --- a/extras/bitarray.jl +++ b/extras/bitarray.jl @@ -1654,7 +1654,7 @@ function permute(B::BitArray, perm) #inner most loop toReturn[1] = quote - P[ind] = B[+($counts...)+offset] + P[ind] = B[+($(counts...))+offset] ind+=1 $counts[1]+= $stridenames[1] end diff --git a/extras/glpk.jl b/extras/glpk.jl index d93c92cdd137c..bedc2b6f5cca5 100644 --- a/extras/glpk.jl +++ b/extras/glpk.jl @@ -14,14 +14,14 @@ _jl_libglpk_wrapper = dlopen("libglpk_wrapper") macro glpk_ccall(func, args...) f = "glp_$(func)" quote - ccall(dlsym(_jl_libglpk, $f), $args...) + ccall(dlsym(_jl_libglpk, $f), $(args...)) end end macro glpkw_ccall(func, args...) f = "_jl_glpkw__$(func)" quote - ccall(dlsym(_jl_libglpk_wrapper, $f), $args...) + ccall(dlsym(_jl_libglpk_wrapper, $f), $(args...)) end end diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 01c2fdd6e3d85..06055689f910c 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -61,7 +61,7 @@ (define (assignment? e) (and (pair? e) (eq? (car e) '=))) -(define unary-ops '(+ - ! ~ $ & |<:| |>:|)) +(define unary-ops '(+ - ! ~ |<:| |>:|)) ; operators that are both unary and binary (define unary-and-binary-ops '(+ - $ & ~)) @@ -550,8 +550,6 @@ (next (peek-token s))) (cond ((closing-token? next) op) ; return operator by itself, as in (+) - ((syntactic-unary-op? op) - (list op (parse-unary s))) ((eqv? next #\{) ;; this case is +{T}(x::T) = ... (ts:put-back! s op) (parse-factor s)) @@ -614,10 +612,22 @@ `(<: ,(cadr e) ,(cadddr e)) e)) +(define (parse-unary-prefix s) + (let ((op (peek-token s))) + (if (syntactic-unary-op? op) + (begin (take-token s) + (if (eqv? (peek-token s) #\( ) + ;; in $(...) the $ only applies to the parens + (list op (parse-atom s)) + (if (closing-token? (peek-token s)) + op + (list op (parse-call s))))) + (parse-atom s)))) + ; parse function call, indexing, dot, and transpose expressions ; also handles looking for syntactic reserved words (define (parse-call s) - (let ((ex (parse-atom s))) + (let ((ex (parse-unary-prefix s))) (if (memq ex reserved-words) (parse-resword s ex) (let loop ((ex ex)) From fd6b6fc92ede46b00fd14a15d60990f3168ecad4 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Fri, 14 Sep 2012 05:23:59 -0400 Subject: [PATCH 2/4] make $ fully ungreedy and fix syntax of all uses in base --- base/abstractarray.jl | 4 ++-- base/array.jl | 24 +++++++++++------------ base/base.jl | 2 +- base/char.jl | 2 +- base/dict.jl | 6 +++--- base/error.jl | 2 +- base/expr.jl | 4 ++-- base/float.jl | 16 ++++++++-------- base/grisu.jl | 2 +- base/linalg_blas.jl | 20 ++++++++++---------- base/linalg_lapack.jl | 44 +++++++++++++++++++++---------------------- base/math_libm.jl | 20 ++++++++++---------- base/multi.jl | 28 +++++++++++++-------------- base/pointer.jl | 2 +- base/printf.jl | 8 ++++---- base/process.jl | 2 +- base/sort.jl | 18 +++++++++--------- base/task.jl | 2 +- base/util.jl | 4 ++-- src/julia-parser.scm | 11 +++-------- 20 files changed, 108 insertions(+), 113 deletions(-) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 49d9072c84c1c..d1a6a932bd1b9 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -235,7 +235,7 @@ function gen_cartesian_map(cache, genbodies, ranges, exargnames, exargs...) quote local _F_ function _F_($(dimargnames...), $(exargnames...)) - $make_loop_nest(ivars, dimargnames, body, bodies) + $(make_loop_nest(ivars, dimargnames, body, bodies)) end _F_ end @@ -333,7 +333,7 @@ function gen_array_index_map(cache, genbody, ranges, exargnames, exargs...) fexpr = quote local _F_ function _F_($(dimargnames...), $(exargnames...)) - $make_arrayind_loop_nest(loopvars, offsetvars, stridevars, linearind, dimargnames, body, exargnames[1]) + $(make_arrayind_loop_nest(loopvars, offsetvars, stridevars, linearind, dimargnames, body, exargnames[1])) end return _F_ end diff --git a/base/array.jl b/base/array.jl index 71c7bb22f7b1b..1e788ecaee3a7 100644 --- a/base/array.jl +++ b/base/array.jl @@ -1269,7 +1269,7 @@ end let findn_cache = nothing function findn_one(ivars) - s = { quote I[$i][count] = $ivars[i] end for i = 1:length(ivars)} + s = { quote I[$i][count] = $(ivars[i]) end for i = 1:length(ivars)} quote Aind = A[$(ivars...)] if Aind != z @@ -1353,19 +1353,19 @@ function gen_areduce_func(n, f) setlims = { quote # each dim of reduction is either 1:sizeA or ivar:ivar if contains(region,$i) - $lo[i] = 1 - $hi[i] = size(A,$i) + $(lo[i]) = 1 + $(hi[i]) = size(A,$i) else - $lo[i] = $hi[i] = $ivars[i] + $(lo[i]) = $(hi[i]) = $(ivars[i]) end end for i=1:n } - rranges = { :( ($lo[i]):($hi[i]) ) for i=1:n } # lo:hi for all dims + rranges = { :( $(lo[i]):$(hi[i]) ) for i=1:n } # lo:hi for all dims body = quote _tot = v0 $(setlims...) - $make_loop_nest(rvars, rranges, - :(_tot = ($f)(_tot, A[$(rvars...)]))) + $(make_loop_nest(rvars, rranges, + :(_tot = ($f)(_tot, A[$(rvars...)])))) R[_ind] = _tot _ind += 1 end @@ -1373,7 +1373,7 @@ function gen_areduce_func(n, f) local _F_ function _F_(f, A, region, R, v0) _ind = 1 - $make_loop_nest(ivars, { :(1:size(R,$i)) for i=1:n }, body) + $(make_loop_nest(ivars, { :(1:size(R,$i)) for i=1:n }, body)) end _F_ end @@ -1768,25 +1768,25 @@ function permute(A::StridedArray, perm) tmp = counts[end] toReturn[len+1] = quote ind = 1 - $tmp = $stridenames[len] + $tmp = $(stridenames[len]) end #inner most loop toReturn[1] = quote P[ind] = A[+($(counts...))+offset] ind+=1 - $counts[1]+= $stridenames[1] + $(counts[1]) += $(stridenames[1]) end for i = 1:len-1 tmp = counts[i] val = i toReturn[(i+1)] = quote - $tmp = $stridenames[val] + $tmp = $(stridenames[val]) end tmp2 = counts[i+1] val = i+1 toReturn[(i+1)+(len+1)] = quote - $tmp2 += $stridenames[val] + $tmp2 += $(stridenames[val]) end end toReturn diff --git a/base/base.jl b/base/base.jl index a4f3dbed595ed..e68debadd71a5 100644 --- a/base/base.jl +++ b/base/base.jl @@ -134,7 +134,7 @@ function append_any(xs...) out end -macro thunk(ex); :(()->$esc(ex)); end +macro thunk(ex); :(()->$(esc(ex))); end macro L_str(s); s; end function compile_hint(f, args::Tuple) diff --git a/base/char.jl b/base/char.jl index 16861e252bdff..fb7ea1b975e17 100644 --- a/base/char.jl +++ b/base/char.jl @@ -84,5 +84,5 @@ for f = (:iswalnum, :iswalpha, :iswblank, :iswcntrl, :iswdigit, # these are BSD-only #:iswhexnumber, :iswideogram, :iswnumber, :iswphonogram, :iswrune, :iswspecial, ) - @eval ($f)(c::Char) = bool(ccall($expr(:quote,f), Int32, (Char,), c)) + @eval ($f)(c::Char) = bool(ccall($(expr(:quote,f)), Int32, (Char,), c)) end diff --git a/base/dict.jl b/base/dict.jl index 96817e114820b..8b752a79cc7ff 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -167,17 +167,17 @@ hash(x::Integer) = _jl_hash64(uint64(x)) # hash as integer if equal to some integer. note the result of # float to int conversion is only defined for in-range values. if x < 0 - if $float64(typemin(Int64)) <= x + if $(float64(typemin(Int64))) <= x return hash(int64(x)) end else # note: float64(typemax(Uint64)) == 2^64 - if x < $float64(typemax(Uint64)) + if x < $(float64(typemax(Uint64))) return hash(uint64(x)) end end end - isnan(x) ? $_jl_hash64(NaN) : _jl_hash64(float64(x)) + isnan(x) ? $(_jl_hash64(NaN)) : _jl_hash64(float64(x)) end function hash(t::Tuple) diff --git a/base/error.jl b/base/error.jl index 167eacab7cd8b..9d7933666d471 100644 --- a/base/error.jl +++ b/base/error.jl @@ -21,5 +21,5 @@ assert(x) = assert(x,'?') assert(x,labl) = x ? nothing : error("assertion failed: ", labl) macro assert(ex) - :($esc(ex) ? nothing : error("assertion failed: ", $string(ex))) + :($(esc(ex)) ? nothing : error("assertion failed: ", $(string(ex)))) end diff --git a/base/expr.jl b/base/expr.jl index 90cf47a579c3f..0b61c49b8c839 100644 --- a/base/expr.jl +++ b/base/expr.jl @@ -16,7 +16,7 @@ gensym(ss::Union(ASCIIString, UTF8String)...) = map(gensym, ss) macro gensym(names...) blk = expr(:block) for name in names - push(blk.args, :($esc(name) = gensym($(string(name))))) + push(blk.args, :($(esc(name)) = gensym($(string(name))))) end push(blk.args, :nothing) return blk @@ -60,5 +60,5 @@ macroexpand(x) = ccall(:jl_macroexpand, Any, (Any,), x) ## misc syntax ## macro eval(x) - :(eval($expr(:quote,x))) + :(eval($(expr(:quote,x)))) end diff --git a/base/float.jl b/base/float.jl index 0b864f1ba9b41..c863f713827f8 100644 --- a/base/float.jl +++ b/base/float.jl @@ -190,8 +190,8 @@ const NaN = box(Float64,unbox(Uint64,0x7ff8000000000000)) inf{T<:FloatingPoint}(x::T) = inf(T) nan{T<:FloatingPoint}(x::T) = nan(T) - isdenormal(x::Float32) = (abs(x) < $box(Float32,unbox(Uint32,0x00800000))) - isdenormal(x::Float64) = (abs(x) < $box(Float64,unbox(Uint64,0x0010000000000000))) + isdenormal(x::Float32) = (abs(x) < $(box(Float32,unbox(Uint32,0x00800000)))) + isdenormal(x::Float64) = (abs(x) < $(box(Float64,unbox(Uint64,0x0010000000000000)))) typemin(::Type{Float32}) = $(-Inf32) typemax(::Type{Float32}) = $(Inf32) @@ -200,10 +200,10 @@ const NaN = box(Float64,unbox(Uint64,0x7ff8000000000000)) typemin{T<:Real}(x::T) = typemin(T) typemax{T<:Real}(x::T) = typemax(T) - realmin(::Type{Float32}) = $box(Float32,unbox(Uint32,0x00800000)) - realmin(::Type{Float64}) = $box(Float64,unbox(Uint64,0x0010000000000000)) - realmax(::Type{Float32}) = $box(Float32,unbox(Uint32,0x7f7fffff)) - realmax(::Type{Float64}) = $box(Float64,unbox(Uint64,0x7fefffffffffffff)) + realmin(::Type{Float32}) = $(box(Float32,unbox(Uint32,0x00800000))) + realmin(::Type{Float64}) = $(box(Float64,unbox(Uint64,0x0010000000000000))) + realmax(::Type{Float32}) = $(box(Float32,unbox(Uint32,0x7f7fffff))) + realmax(::Type{Float64}) = $(box(Float64,unbox(Uint64,0x7fefffffffffffff))) realmin{T<:FloatingPoint}(x::T) = realmin(T) realmax{T<:FloatingPoint}(x::T) = realmax(T) realmin() = realmin(Float64) @@ -215,8 +215,8 @@ const NaN = box(Float64,unbox(Uint64,0x7ff8000000000000)) prevfloat(x::FloatingPoint) = nextfloat(x,-1) eps(x::FloatingPoint) = isfinite(x) ? abs(nextfloat(x)-x) : nan(x) - eps(::Type{Float32}) = $box(Float32,unbox(Uint32,0x34000000)) - eps(::Type{Float64}) = $box(Float64,unbox(Uint64,0x3cb0000000000000)) + eps(::Type{Float32}) = $(box(Float32,unbox(Uint32,0x34000000))) + eps(::Type{Float64}) = $(box(Float64,unbox(Uint64,0x3cb0000000000000))) eps() = eps(Float64) end diff --git a/base/grisu.jl b/base/grisu.jl index 1024e7e6d999f..30ce72b70302e 100644 --- a/base/grisu.jl +++ b/base/grisu.jl @@ -16,7 +16,7 @@ macro grisu_ccall(value, mode, ndigits) ccall(dlsym(Base.libgrisu, :grisu), Void, (Float64, Int32, Int32, Ptr{Uint8}, Int32, Ptr{Bool}, Ptr{Int32}, Ptr{Int32}), - $esc(value), $esc(mode), $esc(ndigits), + $(esc(value)), $(esc(mode)), $(esc(ndigits)), DIGITS, BUFLEN, NEG, LEN, POINT) end end diff --git a/base/linalg_blas.jl b/base/linalg_blas.jl index e61f3ea447d5b..74e0bde1abfaa 100644 --- a/base/linalg_blas.jl +++ b/base/linalg_blas.jl @@ -5,7 +5,7 @@ for (fname, elty) in ((:dcopy_,:Float64), (:scopy_,:Float32), (:zcopy_,:Complex128), (:ccopy_,:Complex64)) @eval begin function _jl_blas_copy(n::Integer, DX::Union(Ptr{$elty},Array{$elty}), incx::Integer, DY::Union(Ptr{$elty},Array{$elty}), incy::Integer) - ccall(dlsym(_jl_libblas, $string(fname)), + ccall(dlsym(_jl_libblas, $(string(fname))), Void, (Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}), &n, DX, &incx, DY, &incy) @@ -51,7 +51,7 @@ end for (fname, elty) in ((:ddot_,:Float64), (:sdot_,:Float32)) @eval begin function _jl_blas_dot(n::Integer, DX::Union(Ptr{$elty},Array{$elty}), incx::Integer, DY::Union(Ptr{$elty},Array{$elty}), incy::Integer) - ccall(dlsym(_jl_libblas, $string(fname)), + ccall(dlsym(_jl_libblas, $(string(fname))), $elty, (Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}), &n, DX, &incx, DY, &incy) @@ -82,7 +82,7 @@ for (fname, elty, ret_type) in ((:dnrm2_,:Float64,:Float64), (:scnrm2_,:Complex64,:Float32)) @eval begin function _jl_blas_nrm2(n::Integer, X::Union(Ptr{$elty},Array{$elty}), incx::Integer) - ccall(dlsym(_jl_libblas, $string(fname)), + ccall(dlsym(_jl_libblas, $(string(fname))), $ret_type, (Ptr{Int32}, Ptr{$elty}, Ptr{Int32}), &n, X, &incx) @@ -111,7 +111,7 @@ for (fname, elty) in ((:daxpy_,:Float64), (:saxpy_,:Float32), function _jl_blas_axpy(n::Integer, a::($elty), DX::Union(Ptr{$elty},Array{$elty}), incx::Integer, DY::Union(Ptr{$elty},Array{$elty}), incy::Integer) - ccall(dlsym(_jl_libblas, $string(fname)), + ccall(dlsym(_jl_libblas, $(string(fname))), Void, (Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}), &n, &a, DX, &incx, DY, &incy) @@ -152,7 +152,7 @@ for (fname, elty) in ((:dsyrk_,:Float64), (:ssyrk_,:Float32), function _jl_blas_syrk(uplo, trans, n::Integer, k::Integer, alpha::($elty), A::StridedMatrix{$elty}, lda::Integer, beta::($elty), C::StridedMatrix{$elty}, ldc::Integer) - ccall(dlsym(_jl_libblas, $string(fname)), + ccall(dlsym(_jl_libblas, $(string(fname))), Void, (Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, @@ -177,7 +177,7 @@ for (fname, elty) in ((:zherk_,:Complex128), (:cherk_,:Complex64)) function _jl_blas_herk(uplo, trans, n::Integer, k::Integer, alpha::($elty), A::StridedMatrix{$elty}, lda::Integer, beta::($elty), C::StridedMatrix{$elty}, ldc::Integer) - ccall(dlsym(_jl_libblas, $string(fname)), + ccall(dlsym(_jl_libblas, $(string(fname))), Void, (Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, @@ -204,7 +204,7 @@ for (fname, elty) in ((:dgbmv_,:Float64), (:sgbmv_,:Float32), alpha::($elty), A::StridedMatrix{$elty}, lda::Integer, x::StridedVector{$elty}, incx::Integer, beta::($elty), y::StridedVector{$elty}, incy::Integer) - ccall(dlsym(_jl_libblas, $string(fname)), + ccall(dlsym(_jl_libblas, $(string(fname))), Void, (Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, @@ -234,7 +234,7 @@ for (fname, elty) in ((:dsbmv_,:Float64), (:ssbmv_,:Float32), alpha::($elty), A::StridedMatrix{$elty}, lda::Integer, x::StridedVector{$elty}, incx::Integer, beta::($elty), y::StridedVector{$elty}, incy::Integer) - ccall(dlsym(_jl_libblas, $string(fname)), + ccall(dlsym(_jl_libblas, $(string(fname))), Void, (Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, @@ -263,7 +263,7 @@ for (fname, elty) in ((:dgemm_,:Float64), (:sgemm_,:Float32), alpha::($elty), A::StridedMatrix{$elty}, lda::Integer, B::StridedMatrix{$elty}, ldb::Integer, beta::($elty), C::StridedMatrix{$elty}, ldc::Integer) - ccall(dlsym(_jl_libblas, $string(fname)), + ccall(dlsym(_jl_libblas, $(string(fname))), Void, (Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, @@ -465,7 +465,7 @@ for (fname, elty) in ((:dgemv_,:Float64), (:sgemv_,:Float32), alpha::($elty), A::StridedMatrix{$elty}, lda::Integer, X::StridedVector{$elty}, incx::Integer, beta::($elty), Y::StridedVector{$elty}, incy::Integer) - ccall(dlsym(_jl_libblas, $string(fname)), + ccall(dlsym(_jl_libblas, $(string(fname))), Void, (Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, diff --git a/base/linalg_lapack.jl b/base/linalg_lapack.jl index 44ead3905af64..5f9628f2fb59a 100644 --- a/base/linalg_lapack.jl +++ b/base/linalg_lapack.jl @@ -25,7 +25,7 @@ for (gbtrf, geqrf, geqp3, getrf, potrf, elty) in m = int32(size(A, 1)) n = int32(size(A, 2)) lda = int32(stride(A, 2)) - ccall(dlsym(_jl_liblapack, $string(potrf)), + ccall(dlsym(_jl_liblapack, $(string(potrf))), Void, (Ptr{Uint8}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{Int32}), &uplo, &n, A, &lda, info) @@ -54,7 +54,7 @@ for (gbtrf, geqrf, geqp3, getrf, potrf, elty) in n = int32(size(A, 2)) lda = int32(stride(A, 2)) ipiv = Array(Int32, n) - ccall(dlsym(_jl_liblapack, $string(getrf)), + ccall(dlsym(_jl_liblapack, $(string(getrf))), Void, (Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32}), @@ -79,7 +79,7 @@ for (gbtrf, geqrf, geqp3, getrf, potrf, elty) in lwork = int32(-1) work = Array($elty, (1,)) for i in 1:2 # first call returns lwork as work[1] - ccall(dlsym(_jl_liblapack, $string(geqrf)), + ccall(dlsym(_jl_liblapack, $(string(geqrf))), Void, (Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{Int32}), @@ -115,14 +115,14 @@ for (gbtrf, geqrf, geqp3, getrf, potrf, elty) in if cmplx rwork = Array(Rtyp, 2n) end for i in 1:2 if cmplx - ccall(dlsym(_jl_liblapack, $string(geqp3)), + ccall(dlsym(_jl_liblapack, $(string(geqp3))), Void, (Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{Rtyp}, Ptr{Int32}), &m, &n, A, &lda, jpvt, tau, work, &lwork, rwork, info) else - ccall(dlsym(_jl_liblapack, $string(geqp3)), + ccall(dlsym(_jl_liblapack, $(string(geqp3))), Void, (Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, @@ -152,7 +152,7 @@ for (gbtrf, geqrf, geqp3, getrf, potrf, elty) in mnmn = min(m, n) ldab = stride(AB, 2) ipiv = Array(Int32, mnmn) - ccall(dlsym(_jl_liblapack, $string(gbtrf)), + ccall(dlsym(_jl_liblapack, $(string(gbtrf))), Void, (Ptr{Int32}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32}), @@ -185,7 +185,7 @@ for (orgqr, elty) in lwork = -1 work = Array($elty, (1,)) for i in 1:2 - ccall(dlsym(_jl_liblapack, $string(orgqr)), + ccall(dlsym(_jl_liblapack, $(string(orgqr))), Void, (Ptr{Int32}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{Int32}), @@ -231,14 +231,14 @@ for (syev, geev, elty) in for i in 1:2 if iscomplex(A) rwork = Array(Rtyp, max(1, 2n-1)) - ccall(dlsym(_jl_liblapack, $string(syev)), + ccall(dlsym(_jl_liblapack, $(string(syev))), Void, (Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{Rtyp}, Ptr{Int32}), &jobz, &uplo, &n, A, &lda, W, work, &lwork, rwork, info) else - ccall(dlsym(_jl_liblapack, $string(syev)), + ccall(dlsym(_jl_liblapack, $(string(syev))), Void, (Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, @@ -290,7 +290,7 @@ for (syev, geev, elty) in end for i = 1:2 if cmplx - ccall(dlsym(_jl_liblapack, $string(geev)), + ccall(dlsym(_jl_liblapack, $(string(geev))), Void, (Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, @@ -299,7 +299,7 @@ for (syev, geev, elty) in &jobvl, &jobvr, &n, A, &lda, W, VL, &n, VR, &n, work, &lwork, rwork, info) else - ccall(dlsym(_jl_liblapack, $string(geev)), + ccall(dlsym(_jl_liblapack, $(string(geev))), Void, (Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, @@ -401,7 +401,7 @@ for (gesvd, gesdd, elty) in if cmplx rwork = Array(Rtyp, job == 'N' ? 5minmn : minmn*max(5minmn+7,2max(m,n)+2minmn+1)) end for i = 1:2 if iscomplex(A) - ccall(dlsym(_jl_liblapack, $string(gesdd)), + ccall(dlsym(_jl_liblapack, $(string(gesdd))), Void, (Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, @@ -410,7 +410,7 @@ for (gesvd, gesdd, elty) in &job, &m, &n, A, &lda, S, U, &m, VT, &n, work, &lwork, rwork, iwork, info) else - ccall(dlsym(_jl_liblapack, $string(gesdd)), + ccall(dlsym(_jl_liblapack, $(string(gesdd))), Void, (Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, @@ -454,7 +454,7 @@ for (gesvd, gesdd, elty) in if cmplx rwork = Array(Rtyp, 5minmn) end for i in 1:2 if cmplx - ccall(dlsym(_jl_liblapack, $string(gesvd)), + ccall(dlsym(_jl_liblapack, $(string(gesvd))), Void, (Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, @@ -463,7 +463,7 @@ for (gesvd, gesdd, elty) in &jobu, &jobvt, &m, &n, A, &lda, S, U, &m, VT, &n, work, &lwork, rwork, info) else - ccall(dlsym(_jl_liblapack, $string(gesvd)), + ccall(dlsym(_jl_liblapack, $(string(gesvd))), Void, (Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, @@ -849,7 +849,7 @@ for (gttrf, pttrf, elty) in info = Array(Int32, 1) n = int32(length(M.d)) ipiv = Array(Int32, n) - ccall(dlsym(_jl_liblapack, $string(gttrf)), + ccall(dlsym(_jl_liblapack, $(string(gttrf))), Void, (Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{Int32}), @@ -863,7 +863,7 @@ for (gttrf, pttrf, elty) in if length(E) != n-1 error("subdiagonal must be one element shorter than diagonal") end - ccall(dlsym(_jl_liblapack, $string(pttrf)), + ccall(dlsym(_jl_liblapack, $(string(pttrf))), Void, (Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}), &n, D, E, info) @@ -887,7 +887,7 @@ for (gtsv, ptsv, elty) in n = int32(length(M.d)) nrhs = int32(size(B, 2)) ldb = int32(stride(B, 2)) - ccall(dlsym(_jl_liblapack, $string(gtsv)), + ccall(dlsym(_jl_liblapack, $(string(gtsv))), Void, (Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{Int32}), @@ -903,7 +903,7 @@ for (gtsv, ptsv, elty) in n = int32(length(M.d)) nrhs = int32(size(B, 2)) ldb = int32(stride(B, 2)) - ccall(dlsym(_jl_liblapack, $string(ptsv)), + ccall(dlsym(_jl_liblapack, $(string(ptsv))), Void, (Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{Int32}), @@ -928,7 +928,7 @@ for (gttrs, pttrs, elty) in n = int32(length(M.d)) nrhs = int32(size(B, 2)) ldb = int32(stride(B, 2)) - ccall(dlsym(_jl_liblapack, $string(gttrs)), + ccall(dlsym(_jl_liblapack, $(string(gttrs))), Void, (Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, @@ -948,7 +948,7 @@ for (gttrs, pttrs, elty) in end nrhs = int32(size(B, 2)) ldb = int32(stride(B, 2)) - ccall(dlsym(_jl_liblapack, $string(pttrs)), + ccall(dlsym(_jl_liblapack, $(string(pttrs))), Void, (Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{Int32}), @@ -985,7 +985,7 @@ for (stev, elty) in work = Array($elty, max(1, 2*n-2)) end info = Array(Int32, 1) - ccall(dlsym(_jl_liblapack, $string(stev)), + ccall(dlsym(_jl_liblapack, $(string(stev))), Void, (Ptr{Uint8}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, diff --git a/base/math_libm.jl b/base/math_libm.jl index 26fcf4bc631f5..127c37d237f26 100644 --- a/base/math_libm.jl +++ b/base/math_libm.jl @@ -2,18 +2,18 @@ _jl_libm = dlopen("libm") macro _jl_libmfunc_1arg_float(T,f) quote - ($esc(f))(x::Float64) = ccall(dlsym(_jl_libm,$string(f)), Float64, (Float64,), x) - ($esc(f))(x::Float32) = ccall(dlsym(_jl_libm,$string(f,"f")), Float32, (Float32,), x) - ($esc(f))(x::Real) = ($f)(float(x)) + $(esc(f))(x::Float64) = ccall(dlsym(_jl_libm,$(string(f))), Float64, (Float64,), x) + $(esc(f))(x::Float32) = ccall(dlsym(_jl_libm,$(string(f,"f"))), Float32, (Float32,), x) + $(esc(f))(x::Real) = ($f)(float(x)) @vectorize_1arg $T $f end end macro _jl_libfdmfunc_1arg_float(T,f) quote - ($esc(f))(x::Float64) = ccall(dlsym(_jl_libfdm,$string(f)), Float64, (Float64,), x) - ($esc(f))(x::Float32) = ccall(dlsym(_jl_libfdm,$string(f,"f")), Float32, (Float32,), x) - ($esc(f))(x::Real) = ($f)(float(x)) + $(esc(f))(x::Float64) = ccall(dlsym(_jl_libfdm,$(string(f))), Float64, (Float64,), x) + $(esc(f))(x::Float32) = ccall(dlsym(_jl_libfdm,$(string(f,"f"))), Float32, (Float32,), x) + $(esc(f))(x::Real) = ($f)(float(x)) @vectorize_1arg $T $f end end @@ -25,16 +25,16 @@ macro _jl_libmfunc_1arg_int(T,f,name...) fname = f end quote - ($esc(fname))(x::Float64) = ccall(dlsym(_jl_libm,$string(f)), Int32, (Float64,), x) - ($esc(fname))(x::Float32) = ccall(dlsym(_jl_libm,$string(f,"f")), Int32, (Float32,), x) + $(esc(fname))(x::Float64) = ccall(dlsym(_jl_libm,$(string(f))), Int32, (Float64,), x) + $(esc(fname))(x::Float32) = ccall(dlsym(_jl_libm,$(string(f,"f"))), Int32, (Float32,), x) @vectorize_1arg $T $fname end end macro _jl_libfdmfunc_2arg(T,f) quote - ($esc(f))(x::Float64, y::Float64) = ccall(dlsym(_jl_libfdm,$string(f)), Float64, (Float64, Float64,), x, y) - ($esc(f))(x::Float32, y::Float32) = ccall(dlsym(_jl_libfdm,$string(f,"f")), Float32, (Float32, Float32), x, y) + $(esc(f))(x::Float64, y::Float64) = ccall(dlsym(_jl_libfdm,$(string(f))), Float64, (Float64, Float64,), x, y) + $(esc(f))(x::Float32, y::Float32) = ccall(dlsym(_jl_libfdm,$(string(f,"f"))), Float32, (Float32, Float32), x, y) @vectorize_2arg $T $f end end diff --git a/base/multi.jl b/base/multi.jl index 0770ab456348e..546fe1f930822 100644 --- a/base/multi.jl +++ b/base/multi.jl @@ -1286,7 +1286,7 @@ end macro sync(block) quote sync_begin() - v = $esc(block) + v = $(esc(block)) sync_end() v end @@ -1354,7 +1354,7 @@ end macro spawn(expr) expr = localize_vars(:(()->($expr))) - :(spawn($esc(expr))) + :(spawn($(esc(expr)))) end function spawnlocal(thunk) @@ -1373,12 +1373,12 @@ end macro spawnlocal(expr) expr = localize_vars(:(()->($expr))) - :(spawnlocal($esc(expr))) + :(spawnlocal($(esc(expr)))) end macro spawnat(p, expr) expr = localize_vars(:(()->($expr))) - :(spawnat($p, $esc(expr))) + :(spawnat($p, $(esc(expr)))) end function at_each(f, args...) @@ -1390,7 +1390,7 @@ end macro everywhere(ex) quote @sync begin - at_each(()->eval($expr(:quote,ex))) + at_each(()->eval($(expr(:quote,ex)))) end end end @@ -1478,10 +1478,10 @@ function make_preduce_body(reducer, var, body) localize_vars( quote function (lo::Int, hi::Int) - $esc(var) = lo - ac = $esc(body) - for $esc(var) = (lo+1):hi - ac = ($esc(reducer))(ac, $esc(body)) + $(esc(var)) = lo + ac = $(esc(body)) + for $(esc(var)) = (lo+1):hi + ac = ($(esc(reducer)))(ac, $(esc(body))) end ac end @@ -1493,8 +1493,8 @@ function make_pfor_body(var, body) localize_vars( quote function (lo::Int, hi::Int) - for $esc(var) = lo:hi - $esc(body) + for $(esc(var)) = lo:hi + $(esc(body)) end end end @@ -1519,12 +1519,12 @@ macro parallel(args...) body = loop.args[2] if na==1 quote - pfor($make_pfor_body(var, body), $esc(r)) + pfor($(make_pfor_body(var, body)), $(esc(r))) end else quote - preduce($esc(reducer), - $make_preduce_body(reducer, var, body), $esc(r)) + preduce($(esc(reducer)), + $(make_preduce_body(reducer, var, body)), $(esc(r))) end end end diff --git a/base/pointer.jl b/base/pointer.jl index 1da817145b00a..bad38b5fc1c66 100644 --- a/base/pointer.jl +++ b/base/pointer.jl @@ -35,7 +35,7 @@ end integer(x::Ptr) = convert(Uint, x) unsigned(x::Ptr) = convert(Uint, x) -@eval sizeof(::Type{Ptr}) = $div(WORD_SIZE,8) +@eval sizeof(::Type{Ptr}) = $(div(WORD_SIZE,8)) ## limited pointer arithmetic & comparison ## diff --git a/base/printf.jl b/base/printf.jl index 800d97a7345ae..3b3b953372da7 100644 --- a/base/printf.jl +++ b/base/printf.jl @@ -501,7 +501,7 @@ end macro _handle_zero() quote - if $esc(:x) == 0 + if $(esc(:x)) == 0 POINT[1] = 1 DIGITS[1] = '0' return @@ -580,9 +580,9 @@ _int_HEX(x::Unsigned) = (NEG[1]=false; _decode_HEX(x)) macro _handle_negative() quote - if $esc(:x) < 0 + if $(esc(:x)) < 0 NEG[1] = true - $esc(:x) = -($esc(:x)) + $(esc(:x)) = -$(esc(:x)) else NEG[1] = false end @@ -784,7 +784,7 @@ macro printf(args...) end for i = length(args):-1:1 var = sym_args[i].args[1] - unshift(blk.args, :($var = $esc(args[i]))) + unshift(blk.args, :($var = $(esc(args[i])))) end blk end diff --git a/base/process.jl b/base/process.jl index 6c7b157ef0fe1..edccdb2f75a4e 100644 --- a/base/process.jl +++ b/base/process.jl @@ -723,5 +723,5 @@ function cmd_gen(parsed) end macro cmd(str) - :(cmd_gen($_jl_shell_parse(str))) + :(cmd_gen($(_jl_shell_parse(str)))) end diff --git a/base/sort.jl b/base/sort.jl index 89feda4ab3bc6..0432f32571982 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -31,7 +31,7 @@ function ($insertionsort)($(args...), a::AbstractVector, lo::Int, hi::Int) j = i x = a[i] while j > lo - if $lt(:x, :(a[j-1])) + if $(lt(:x, :(a[j-1]))) a[j] = a[j-1] j -= 1 continue @@ -50,7 +50,7 @@ function ($insertionsort)($(args...), a::AbstractVector, p::AbstractVector{Int}, x = a[i] xp = p[i] while j > lo - if $lt(:x, :(a[j-1])) + if $(lt(:x, :(a[j-1]))) a[j] = a[j-1] p[j] = p[j-1] j -= 1 @@ -64,13 +64,13 @@ function ($insertionsort)($(args...), a::AbstractVector, p::AbstractVector{Int}, return a, p end -($pivot_middle)(a,b,c) = $lt(:a,:b) ? ($lt(:b,:c) ? b : c) : ($lt(:a,:c) ? a : c) +($pivot_middle)(a,b,c) = $(lt(:a,:b)) ? ($(lt(:b,:c)) ? b : c) : ($(lt(:a,:c)) ? a : c) # very fast but unstable function ($quicksort)($(args...), a::AbstractVector, lo::Int, hi::Int) while hi > lo if hi-lo <= 20 - return $expr(:call, insertionsort, args..., :a, :lo, :hi) + return $(expr(:call, insertionsort, args..., :a, :lo, :hi)) end i, j = lo, hi # pivot = (a[lo]+a[hi])/2 # 1.14x @@ -79,8 +79,8 @@ function ($quicksort)($(args...), a::AbstractVector, lo::Int, hi::Int) # pivot = _jl_pivot_middle(a[lo], a[hi], a[(lo+hi)>>>1]) # 1.23x # pivot = a[randival(lo,hi)] # 1.28x while i <= j - while $lt(:(a[i]), :pivot); i += 1; end - while $lt(:pivot, :(a[j])); j -= 1; end + while $(lt(:(a[i]), :pivot)); i += 1; end + while $(lt(:pivot, :(a[j]))); j -= 1; end if i <= j a[i], a[j] = a[j], a[i] i += 1 @@ -88,7 +88,7 @@ function ($quicksort)($(args...), a::AbstractVector, lo::Int, hi::Int) end end if lo < j - $expr(:call, quicksort, args..., :a, :lo, :j) + $(expr(:call, quicksort, args..., :a, :lo, :j)) end lo = i end @@ -118,7 +118,7 @@ function ($mergesort)($(args...), a::AbstractVector, lo::Int, hi::Int, b::Abstra i = 1 k = lo while k < j <= hi - if $lt(:(a[j]), :(b[i])) + if $(lt(:(a[j]), :(b[i]))) a[k] = a[j] j += 1 else @@ -162,7 +162,7 @@ function ($mergesort)($(args...), i = 1 k = lo while k < j <= hi - if $lt(:(a[j]), :(b[i])) + if $(lt(:(a[j]), :(b[i]))) a[k] = a[j] p[k] = p[j] j += 1 diff --git a/base/task.jl b/base/task.jl index ae7b6ce506f99..60a18f7fdd691 100644 --- a/base/task.jl +++ b/base/task.jl @@ -39,5 +39,5 @@ done(t::Task, val) = istaskdone(t) next(t::Task, val) = (val, consume(t)) macro task(ex) - :(Task(()->$esc(ex))) + :(Task(()->$(esc(ex)))) end diff --git a/base/util.jl b/base/util.jl index 98f7f6ef02526..27534b6e276a3 100644 --- a/base/util.jl +++ b/base/util.jl @@ -35,7 +35,7 @@ end macro time(ex) quote local t0 = time() - local val = $esc(ex) + local val = $(esc(ex)) local t1 = time() println("elapsed time: ", t1-t0, " seconds") val @@ -46,7 +46,7 @@ end macro elapsed(ex) quote local t0 = time() - local val = $esc(ex) + local val = $(esc(ex)) time()-t0 end end diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 20b35962142f8..91a7482b6be31 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -606,8 +606,6 @@ (let ((next (peek-token s))) (cond ((closing-token? next) op) ; return operator by itself, as in (+) - ((syntactic-unary-op? op) - (list op (parse-unary s))) ((eqv? next #\{) ;; this case is +{T}(x::T) = ... (ts:put-back! s op) (parse-factor s)) @@ -665,12 +663,9 @@ (let ((op (peek-token s))) (if (syntactic-unary-op? op) (begin (take-token s) - (if (eqv? (peek-token s) #\( ) - ;; in $(...) the $ only applies to the parens - (list op (parse-atom s)) - (if (closing-token? (peek-token s)) - op - (list op (parse-call s))))) + (cond ((closing-token? (peek-token s)) op) + ((eq? op '&) (list op (parse-call s))) + (else (list op (parse-atom s))))) (parse-atom s)))) ; parse function call, indexing, dot, and transpose expressions From ad5361bf3c7ad78d0a7790eca120e0fb0dc64eff Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Fri, 14 Sep 2012 05:51:01 -0400 Subject: [PATCH 3/4] fix a few more $ --- examples/staged.jl | 2 +- extras/cairo.jl | 28 ++++++++++++++-------------- extras/memoize.jl | 6 +++--- extras/options.jl | 16 ++++++++-------- extras/profile.jl | 2 +- extras/winston.jl | 2 +- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/examples/staged.jl b/examples/staged.jl index ce9228365e009..b8a19d5d39246 100644 --- a/examples/staged.jl +++ b/examples/staged.jl @@ -50,7 +50,7 @@ end end for i = 1:length(dims) ex = quote - for ($names[i]) in dims[$i] + for $(names[i]) in dims[$i] $ex end end diff --git a/extras/cairo.jl b/extras/cairo.jl index e450cda205e74..1a522bfa034ef 100644 --- a/extras/cairo.jl +++ b/extras/cairo.jl @@ -164,8 +164,8 @@ end macro _CTX_FUNC_V(NAME, FUNCTION) quote - ($esc(NAME))(ctx::CairoContext) = - ccall(dlsym(_jl_libcairo,$string(FUNCTION)), + $(esc(NAME))(ctx::CairoContext) = + ccall(dlsym(_jl_libcairo,$(string(FUNCTION))), Void, (Ptr{Void},), ctx.ptr) end end @@ -187,8 +187,8 @@ end macro _CTX_FUNC_I(NAME, FUNCTION) quote - ($esc(NAME))(ctx::CairoContext, i0::Integer) = - ccall(dlsym(_jl_libcairo,$string(FUNCTION)), + $(esc(NAME))(ctx::CairoContext, i0::Integer) = + ccall(dlsym(_jl_libcairo,$(string(FUNCTION))), Void, (Ptr{Void},Int32), ctx.ptr, i0) end end @@ -197,8 +197,8 @@ end macro _CTX_FUNC_D(NAME, FUNCTION) quote - ($esc(NAME))(ctx::CairoContext, d0::Real) = - ccall(dlsym(_jl_libcairo,$string(FUNCTION)), + $(esc(NAME))(ctx::CairoContext, d0::Real) = + ccall(dlsym(_jl_libcairo,$(string(FUNCTION))), Void, (Ptr{Void},Float64), ctx.ptr, d0) end end @@ -208,8 +208,8 @@ end macro _CTX_FUNC_DD(NAME, FUNCTION) quote - ($esc(NAME))(ctx::CairoContext, d0::Real, d1::Real) = - ccall(dlsym(_jl_libcairo,$string(FUNCTION)), + $(esc(NAME))(ctx::CairoContext, d0::Real, d1::Real) = + ccall(dlsym(_jl_libcairo,$(string(FUNCTION))), Void, (Ptr{Void},Float64,Float64), ctx.ptr, d0, d1) end end @@ -223,8 +223,8 @@ end macro _CTX_FUNC_DDD(NAME, FUNCTION) quote - ($esc(NAME))(ctx::CairoContext, d0::Real, d1::Real, d2::Real) = - ccall(dlsym(_jl_libcairo,$string(FUNCTION)), + $(esc(NAME))(ctx::CairoContext, d0::Real, d1::Real, d2::Real) = + ccall(dlsym(_jl_libcairo,$(string(FUNCTION))), Void, (Ptr{Void},Float64,Float64,Float64), ctx.ptr, d0, d1, d2) end end @@ -233,8 +233,8 @@ end macro _CTX_FUNC_DDDD(NAME, FUNCTION) quote - ($esc(NAME))(ctx::CairoContext, d0::Real, d1::Real, d2::Real, d3::Real) = - ccall(dlsym(_jl_libcairo,$string(FUNCTION)), Void, + $(esc(NAME))(ctx::CairoContext, d0::Real, d1::Real, d2::Real, d3::Real) = + ccall(dlsym(_jl_libcairo,$(string(FUNCTION))), Void, (Ptr{Void},Float64,Float64,Float64,Float64), ctx.ptr, d0, d1, d2, d3) end @@ -245,8 +245,8 @@ end macro _CTX_FUNC_DDDDD(NAME, FUNCTION) quote - ($esc(NAME))(ctx::CairoContext, d0::Real, d1::Real, d2::Real, d3::Real, d4::Real) = - ccall(dlsym(_jl_libcairo,$string(FUNCTION)), Void, + $(esc(NAME))(ctx::CairoContext, d0::Real, d1::Real, d2::Real, d3::Real, d4::Real) = + ccall(dlsym(_jl_libcairo,$(string(FUNCTION))), Void, (Ptr{Void},Float64,Float64,Float64,Float64,Float64), ctx.ptr, d0, d1, d2, d3, d4) end diff --git a/extras/memoize.jl b/extras/memoize.jl index 667483cbf3694..c56cf17c1ccb1 100644 --- a/extras/memoize.jl +++ b/extras/memoize.jl @@ -9,9 +9,9 @@ macro memoize(ex) end f_cache = esc(symbol(string(f,"_cache"))) quote - ($esc(ex)) + $(esc(ex)) const ($f_cache) = Dict{Tuple,Any}() - ($esc(f))(args...) = has(($f_cache),args) ? - ($f_cache)[args] : (($f_cache)[args] = ($esc(u))(args...)) + $(esc(f))(args...) = has(($f_cache),args) ? + ($f_cache)[args] : (($f_cache)[args] = $(esc(u))(args...)) end end diff --git a/extras/options.jl b/extras/options.jl index a871d37976b29..fe66652155756 100644 --- a/extras/options.jl +++ b/extras/options.jl @@ -172,7 +172,7 @@ end macro defaults(opts,ex...) # Create a new variable storing the checkflag varname = strcat("_",string(opts),"_checkflag") - exret = :($esc(symbol(varname)) = ischeck($esc(opts))) + exret = :($(esc(symbol(varname))) = ischeck($(esc(opts)))) # Transform the tuple into a vector, so that # we can manipulate it ex = {ex...} @@ -203,13 +203,13 @@ macro defaults(opts,ex...) sym = y.args[1] exret = quote $exret - htindex = Base.ht_keyindex(($esc(opts)).key2index,$expr(:quote,sym)) + htindex = Base.ht_keyindex($(esc(opts)).key2index,$(expr(:quote,sym))) if htindex > 0 - htindex = ($esc(opts)).key2index.vals[htindex] - ($esc(sym)) = ($esc(opts)).vals[htindex] - ($esc(opts)).used[htindex] = true + htindex = $(esc(opts)).key2index.vals[htindex] + $(esc(sym)) = $(esc(opts)).vals[htindex] + $(esc(opts)).used[htindex] = true else - ($esc(y)) + $(esc(y)) end end i += 1 @@ -223,7 +223,7 @@ end # @check_used opts macro check_used(opts) varname = strcat("_",string(opts),"_checkflag") - :(docheck($esc(opts),$esc(symbol(varname)))) + :(docheck($(esc(opts)),$(esc(symbol(varname))))) end # Macro for setting options. Usage: @@ -302,7 +302,7 @@ macro set_options(opts,ex...) val = y.args[2] exret = quote $exret - ($esc(opts))[$expr(:quote,sym)] = $esc(val) + $(esc(opts))[$(expr(:quote,sym))] = $(esc(val)) end i += 1 end diff --git a/extras/profile.jl b/extras/profile.jl index 887c88531e0d9..98d20e3b6f47f 100644 --- a/extras/profile.jl +++ b/extras/profile.jl @@ -262,7 +262,7 @@ function profile_report() ret = gensym() exret[1] = :($ret = {}) for i = 1:length(_PROFILE_REPORTS) - exret[i+1] = :(push($ret,$expr(:call,{_PROFILE_REPORTS[i]}))) + exret[i+1] = :(push($ret,$(expr(:call,{_PROFILE_REPORTS[i]})))) end exret[end] = :(profile_print($ret)) return expr(:block,exret) diff --git a/extras/winston.jl b/extras/winston.jl index b7b6425a44622..1dbe7b2a08af2 100644 --- a/extras/winston.jl +++ b/extras/winston.jl @@ -22,7 +22,7 @@ typealias List Array{Any,1} typealias PlotAttributes Associative # TODO: does Associative need {K,V}? macro desc(x) - :( println($string(x)," = ",$esc(x)) ) + :( println($(string(x))," = ",$(esc(x))) ) end # config ---------------------------------------------------------------------- From efca015345014372ca310caffca9c933449441cd Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sat, 15 Sep 2012 00:05:09 -0400 Subject: [PATCH 4/4] fix remaining $ uses --- extras/Rmath.jl | 48 +++++++++++++++++++++++----------------------- extras/bitarray.jl | 40 +++++++++++++++++++------------------- extras/enum.jl | 10 +++++----- test/runtests.jl | 8 ++++---- 4 files changed, 53 insertions(+), 53 deletions(-) diff --git a/extras/Rmath.jl b/extras/Rmath.jl index 999c58e44bab7..2ca178e282521 100644 --- a/extras/Rmath.jl +++ b/extras/Rmath.jl @@ -115,14 +115,14 @@ macro _jl_libRmath_1par_0d(base) quote global $dd, $pp, $qq, $rr ($dd)(x::Number, p1::Number, give_log::Bool) = - ccall(dlsym(_jl_libRmath,$string(dd)), Float64, (Float64,Float64,Int32), x, p1, give_log) + ccall(dlsym(_jl_libRmath,$(string(dd))), Float64, (Float64,Float64,Int32), x, p1, give_log) ($dd){T<:Number}(x::AbstractArray{T}, p1::Number, give_log::Bool) = reshape([ ($dd)(x[i], p1, give_log) for i=1:numel(x) ], size(x)) ($dd)(x::Number, p1::Number) = ($dd)(x, p1, false) @vectorize_2arg Number $dd ($pp)(q::Number, p1::Number, lower_tail::Bool, log_p::Bool) = - ccall(dlsym(_jl_libRmath,$string(pp)), Float64, (Float64,Float64,Int32,Int32), q, p1, lower_tail, log_p) + ccall(dlsym(_jl_libRmath,$(string(pp))), Float64, (Float64,Float64,Int32,Int32), q, p1, lower_tail, log_p) ($pp){T<:Number}(q::AbstractArray{T}, p1::Number, lower_tail::Bool, log_p::Bool) = reshape([ ($pp)(q[i], p1, lower_tail, log_p) for i=1:numel(q) ], size(q)) ($pp)(q::Number, p1::Number, lower_tail::Bool) = ($pp)(q, p1, lower_tail, false) @@ -131,7 +131,7 @@ macro _jl_libRmath_1par_0d(base) @vectorize_2arg Number $pp ($qq)(p::Number, p1::Number, lower_tail::Bool, log_p::Bool) = - ccall(dlsym(_jl_libRmath,$string(qq)), Float64, (Float64,Float64,Int32,Int32), p, p1, lower_tail, log_p) + ccall(dlsym(_jl_libRmath,$(string(qq))), Float64, (Float64,Float64,Int32,Int32), p, p1, lower_tail, log_p) ($qq){T<:Number}(p::AbstractArray{T}, p1::Number, lower_tail::Bool, log_p::Bool) = reshape([ ($qq)(p[i], p1, lower_tail, log_p) for i=1:numel(p) ], size(p)) ($qq)(p::Number, p1::Number, lower_tail::Bool) = ($qq)(p, p1, lower_tail, false) @@ -140,7 +140,7 @@ macro _jl_libRmath_1par_0d(base) @vectorize_2arg Number $qq ($rr)(nn::Integer, p1::Number) = - [ ccall(dlsym(_jl_libRmath,$string(rr)), Float64, (Float64,), p1) for i=1:nn ] + [ ccall(dlsym(_jl_libRmath,$(string(rr))), Float64, (Float64,), p1) for i=1:nn ] end end @@ -158,7 +158,7 @@ macro _jl_libRmath_1par_1d(base, d1) quote global $dd, $pp, $qq, $rr ($dd)(x::Number, p1::Number, give_log::Bool) = - ccall(dlsym(_jl_libRmath,$string(dd)), Float64, (Float64,Float64,Int32), x, p1, give_log) + ccall(dlsym(_jl_libRmath,$(string(dd))), Float64, (Float64,Float64,Int32), x, p1, give_log) ($dd){T<:Number}(x::AbstractArray{T}, p1::Number, give_log::Bool) = reshape([ ($dd)(x[i], p1, give_log) for i=1:numel(x) ], size(x)) ($dd)(x::Number, give_log::Bool) = ($dd)(x, $d1, give_log) @@ -169,7 +169,7 @@ macro _jl_libRmath_1par_1d(base, d1) ($dd){T<:Number}(x::AbstractArray{T}) = ($dd)(x, $d1, false) ($pp)(q::Number, p1::Number, lower_tail::Bool, log_p::Bool) = - ccall(dlsym(_jl_libRmath,$string(pp)), Float64, (Float64,Float64,Int32,Int32), q, p1, lower_tail, log_p) + ccall(dlsym(_jl_libRmath,$(string(pp))), Float64, (Float64,Float64,Int32,Int32), q, p1, lower_tail, log_p) ($pp){T<:Number}(q::AbstractArray{T}, p1::Number, lower_tail::Bool, log_p::Bool) = reshape([ ($pp)(q[i], p1, lower_tail, log_p) for i=1:numel(q) ], size(q)) ($pp)(q::Number, lower_tail::Bool, log_p::Bool) = ($pp)(q, $d1, lower_tail, log_p) @@ -184,7 +184,7 @@ macro _jl_libRmath_1par_1d(base, d1) ($pp){T<:Number}(q::AbstractArray{T}) = ($pp)(q, $d1, true, false) ($qq)(p::Number, p1::Number, lower_tail::Bool, log_p::Bool) = - ccall(dlsym(_jl_libRmath,$string(qq)), Float64, (Float64,Float64,Int32,Int32), p, p1, lower_tail, log_p) + ccall(dlsym(_jl_libRmath,$(string(qq))), Float64, (Float64,Float64,Int32,Int32), p, p1, lower_tail, log_p) ($qq){T<:Number}(p::AbstractArray{T}, p1::Number, lower_tail::Bool, log_p::Bool) = reshape([ ($qq)(p[i], p1, lower_tail, log_p) for i=1:numel(p) ], size(p)) ($qq)(p::Number, lower_tail::Bool, log_p::Bool) = ($qq)(p, $d1, lower_tail, log_p) @@ -199,7 +199,7 @@ macro _jl_libRmath_1par_1d(base, d1) ($qq){T<:Number}(p::AbstractArray{T}) = ($qq)(p, $d1, true, false) ($rr)(nn::Integer, p1::Number) = - [ ccall(dlsym(_jl_libRmath,$string(rr)), Float64, (Float64,), p1) for i=1:nn ] + [ ccall(dlsym(_jl_libRmath,$(string(rr))), Float64, (Float64,), p1) for i=1:nn ] ($rr)(nn::Integer) = ($rr)(nn, $d1) end end @@ -216,14 +216,14 @@ macro _jl_libRmath_2par_0d(base) quote global $dd, $pp, $qq, $rr ($dd)(x::Number, p1::Number, p2::Number, give_log::Bool) = - ccall(dlsym(_jl_libRmath,$string(dd)), Float64, (Float64,Float64,Float64,Int32), x, p1, p2, give_log) + ccall(dlsym(_jl_libRmath,$(string(dd))), Float64, (Float64,Float64,Float64,Int32), x, p1, p2, give_log) ($dd){T<:Number}(x::AbstractArray{T}, p1::Number, p2::Number, give_log::Bool) = reshape([ ($dd)(x[i], p1, p2, give_log) for i=1:numel(x) ], size(x)) ($dd)(x::Number, p1::Number, p2::Number) = ($dd)(x, p1, p2, false) @_jl_libRmath_vectorize_3arg $dd ($pp)(q::Number, p1::Number, p2::Number, lower_tail::Bool, log_p::Bool) = - ccall(dlsym(_jl_libRmath,$string(pp)), Float64, (Float64,Float64,Float64,Int32,Int32), q, p1, p2, lower_tail, log_p) + ccall(dlsym(_jl_libRmath,$(string(pp))), Float64, (Float64,Float64,Float64,Int32,Int32), q, p1, p2, lower_tail, log_p) ($pp){T<:Number}(q::AbstractArray{T}, p1::Number, p2::Number, lower_tail::Bool, log_p::Bool) = reshape([ ($pp)(q[i], p1, p2, lower_tail, log_p) for i=1:numel(q) ], size(q)) ($pp)(q::Number, p1::Number, p2::Number, lower_tail::Bool) = ($pp)(q, p1, p2, lower_tail, false) @@ -233,7 +233,7 @@ macro _jl_libRmath_2par_0d(base) @_jl_libRmath_vectorize_3arg $pp ($qq)(p::Number, p1::Number, p2::Number, lower_tail::Bool, log_p::Bool) = - ccall(dlsym(_jl_libRmath,$string(qq)), Float64, (Float64,Float64,Float64,Int32,Int32), p, p1, p2, lower_tail, log_p) + ccall(dlsym(_jl_libRmath,$(string(qq))), Float64, (Float64,Float64,Float64,Int32,Int32), p, p1, p2, lower_tail, log_p) ($qq){T<:Number}(p::AbstractArray{T}, p1::Number, p2::Number, lower_tail::Bool, log_p::Bool) = reshape([ ($qq)(p[i], p1, p2, lower_tail, log_p) for i=1:numel(p) ], size(p)) ($qq)(p::Number, p1::Number, p2::Number, lower_tail::Bool) = ($qq)(p, p1, p2, lower_tail, false) @@ -243,7 +243,7 @@ macro _jl_libRmath_2par_0d(base) @_jl_libRmath_vectorize_3arg $qq ($rr)(nn::Integer, p1::Number, p2::Number) = - [ ccall(dlsym(_jl_libRmath,$string(rr)), Float64, (Float64,Float64), p1, p2) for i=1:nn ] + [ ccall(dlsym(_jl_libRmath,$(string(rr))), Float64, (Float64,Float64), p1, p2) for i=1:nn ] end end @@ -263,7 +263,7 @@ macro _jl_libRmath_2par_1d(base, d2) quote global $dd, $pp, $qq, $rr ($dd)(x::Number, p1::Number, p2::Number, give_log::Bool) = - ccall(dlsym(_jl_libRmath,$string(dd)), Float64, (Float64,Float64,Float64,Int32), x, p1, p2, give_log) + ccall(dlsym(_jl_libRmath,$(string(dd))), Float64, (Float64,Float64,Float64,Int32), x, p1, p2, give_log) ($dd){T<:Number}(x::AbstractArray{T}, p1::Number, p2::Number, give_log::Bool) = reshape([ ($dd)(x[i], p1, p2, give_log) for i=1:numel(x) ], size(x)) ($dd)(x::Number, p1::Number, give_log::Bool) = ($dd)(x, p1, $d2, give_log) @@ -274,7 +274,7 @@ macro _jl_libRmath_2par_1d(base, d2) @vectorize_2arg Number $dd ($pp)(q::Number, p1::Number, p2::Number, lower_tail::Bool, log_p::Bool) = - ccall(dlsym(_jl_libRmath,$string(pp)), Float64, (Float64,Float64,Float64,Int32,Int32), q, p1, p2, lower_tail, log_p) + ccall(dlsym(_jl_libRmath,$(string(pp))), Float64, (Float64,Float64,Float64,Int32,Int32), q, p1, p2, lower_tail, log_p) ($pp)(q::Number, p1::Number, lower_tail::Bool, log_p::Bool) = ($pp)(q, p1, $d2, lower_tail, log_p) ($pp){T<:Number}(q::AbstractArray{T}, p1::Number, p2::Number, lower_tail::Bool, log_p::Bool) = reshape([ ($pp)(q[i], p1, p2, lower_tail, log_p) for i=1:numel(q) ], size(q)) @@ -289,7 +289,7 @@ macro _jl_libRmath_2par_1d(base, d2) @vectorize_2arg Number $pp ($qq)(p::Number, p1::Number, p2::Number, lower_tail::Bool, log_p::Bool) = - ccall(dlsym(_jl_libRmath,$string(qq)), Float64, (Float64,Float64,Float64,Int32,Int32), p, p1, p2, lower_tail, log_p) + ccall(dlsym(_jl_libRmath,$(string(qq))), Float64, (Float64,Float64,Float64,Int32,Int32), p, p1, p2, lower_tail, log_p) ($qq)(p::Number, p1::Number, lower_tail::Bool, log_p::Bool) = ($qq)(p, p1, $d2, lower_tail, log_p) ($qq){T<:Number}(p::AbstractArray{T}, p1::Number, p2::Number, lower_tail::Bool, log_p::Bool) = reshape([ ($qq)(p[i], p1, p2, lower_tail, log_p) for i=1:numel(p) ], size(p)) @@ -304,7 +304,7 @@ macro _jl_libRmath_2par_1d(base, d2) @vectorize_2arg Number $qq ($rr)(nn::Integer, p1::Number, p2::Number) = - [ ccall(dlsym(_jl_libRmath,$string(rr)), Float64, (Float64,Float64), p1, p2) for i=1:nn ] + [ ccall(dlsym(_jl_libRmath,$(string(rr))), Float64, (Float64,Float64), p1, p2) for i=1:nn ] ($rr)(nn::Integer, p1::Number) = ($rr)(nn, p1, $d2) end end @@ -326,7 +326,7 @@ macro _jl_libRmath_2par_2d(base, d1, d2) quote global $dd, $pp, $qq, $rr ($dd)(x::Number, p1::Number, p2::Number, give_log::Bool) = - ccall(dlsym(_jl_libRmath,$string(ddsym)), Float64, (Float64,Float64,Float64,Int32), x, p1, p2, give_log) + ccall(dlsym(_jl_libRmath,$(string(ddsym))), Float64, (Float64,Float64,Float64,Int32), x, p1, p2, give_log) ($dd){T<:Number}(x::AbstractArray{T}, p1::Number, p2::Number, give_log::Bool) = reshape([ ($dd)(x[i], p1, p2, give_log) for i=1:numel(x) ], size(x)) ($dd)(x::Number, p1::Number, give_log::Bool) = ($dd)(x, p1, $d2, give_log) @@ -342,7 +342,7 @@ macro _jl_libRmath_2par_2d(base, d1, d2) ($pp)(q::Number, p1::Number, p2::Number, lower_tail::Bool, log_p::Bool) = - ccall(dlsym(_jl_libRmath,$string(ppsym)), Float64, (Float64,Float64,Float64,Int32,Int32), q, p1, p2, lower_tail, log_p) + ccall(dlsym(_jl_libRmath,$(string(ppsym))), Float64, (Float64,Float64,Float64,Int32,Int32), q, p1, p2, lower_tail, log_p) ($pp){T<:Number}(q::AbstractArray{T}, p1::Number, p2::Number, lower_tail::Bool, log_p::Bool) = reshape([ ($pp)(q[i], p1, p2, lower_tail, log_p) for i=1:numel(q) ], size(q)) ($pp)(q::Number, p1::Number, lower_tail::Bool, log_p::Bool) = ($pp)(q, p1, $d2, lower_tail, log_p) @@ -363,7 +363,7 @@ macro _jl_libRmath_2par_2d(base, d1, d2) ($pp){T<:Number}(q::AbstractArray{T}) = ($pp)(q, $d1, $d2, true, false) ($qq)(p::Number, p1::Number, p2::Number, lower_tail::Bool, log_p::Bool) = - ccall(dlsym(_jl_libRmath,$string(qqsym)), Float64, (Float64,Float64,Float64,Int32,Int32), p, p1, p2, lower_tail, log_p) + ccall(dlsym(_jl_libRmath,$(string(qqsym))), Float64, (Float64,Float64,Float64,Int32,Int32), p, p1, p2, lower_tail, log_p) ($qq){T<:Number}(p::AbstractArray{T}, p1::Number, p2::Number, lower_tail::Bool, log_p::Bool) = reshape([ ($qq)(p[i], p1, p2, lower_tail, log_p) for i=1:numel(p) ], size(p)) ($qq)(p::Number, p1::Number, lower_tail::Bool, log_p::Bool) = ($qq)(p, p1, $d2, lower_tail, log_p) @@ -384,7 +384,7 @@ macro _jl_libRmath_2par_2d(base, d1, d2) ($qq){T<:Number}(p::AbstractArray{T}) = ($qq)(p, $d1, $d2, true, false) ($rr)(nn::Integer, p1::Number, p2::Number) = - [ ccall(dlsym(_jl_libRmath,$string(rr)), Float64, (Float64,Float64), p1, p2) for i=1:nn ] + [ ccall(dlsym(_jl_libRmath,$(string(rr))), Float64, (Float64,Float64), p1, p2) for i=1:nn ] ($rr)(nn::Integer, p1::Number) = ($rr)(nn, p1, $d2) ($rr)(nn::Integer) = ($rr)(nn, $d1, $d2) end @@ -405,14 +405,14 @@ macro _jl_libRmath_3par_0d(base) quote global $dd, $pp, $qq, $rr ($dd)(x::Number, p1::Number, p2::Number, p3::Number, give_log::Bool) = - ccall(dlsym(_jl_libRmath,$string(dd)), Float64, (Float64,Float64,Float64,Float64,Int32), x, p1, p2, p3, give_log) + ccall(dlsym(_jl_libRmath,$(string(dd))), Float64, (Float64,Float64,Float64,Float64,Int32), x, p1, p2, p3, give_log) ($dd){T<:Number}(x::AbstractArray{T}, p1::Number, p2::Number, p3::Number, give_log::Bool) = reshape([ ($dd)(x[i], p1, p2, p3, give_log) for i=1:numel(x) ], size(x)) ($dd)(x::Number, p1::Number, p2::Number, p3::Number) = ($dd)(x, p1, p2, p3, false) @_jl_libRmath_vectorize_4arg $dd ($pp)(q::Number, p1::Number, p2::Number, p3::Number, lower_tail::Bool, log_p::Bool) = - ccall(dlsym(_jl_libRmath,$string(pp)), Float64, (Float64,Float64,Float64,Float64,Int32,Int32), q, p1, p2, p3, lower_tail, log_p) + ccall(dlsym(_jl_libRmath,$(string(pp))), Float64, (Float64,Float64,Float64,Float64,Int32,Int32), q, p1, p2, p3, lower_tail, log_p) ($pp){T<:Number}(q::AbstractArray{T}, p1::Number, p2::Number, p3::Number, lower_tail::Bool, log_p::Bool) = reshape([ ($pp)(q[i], p1, p2, p3, lower_tail, log_p) for i=1:numel(q) ], size(q)) ($pp)(q::Number, p1::Number, p2::Number, p3::Number, lower_tail::Bool) = ($pp)(q, p1, p2, p3, lower_tail, false) @@ -422,7 +422,7 @@ macro _jl_libRmath_3par_0d(base) @_jl_libRmath_vectorize_4arg $pp ($qq)(p::Number, p1::Number, p2::Number, p3::Number, lower_tail::Bool, log_p::Bool) = - ccall(dlsym(_jl_libRmath,$string(qq)), Float64, (Float64,Float64,Float64,Float64,Int32,Int32), p, p1, p2, p3, lower_tail, log_p) + ccall(dlsym(_jl_libRmath,$(string(qq))), Float64, (Float64,Float64,Float64,Float64,Int32,Int32), p, p1, p2, p3, lower_tail, log_p) ($qq){T<:Number}(p::AbstractArray{T}, p1::Number, p2::Number, p3::Number, lower_tail::Bool, log_p::Bool) = reshape([ ($qq)(p[i], p1, p2, p3, lower_tail, log_p) for i=1:numel(p) ], size(p)) ($qq)(p::Number, p1::Number, p2::Number, p3::Number, lower_tail::Bool) = ($qq)(p, p1, p2, p3, lower_tail, false) @@ -432,7 +432,7 @@ macro _jl_libRmath_3par_0d(base) @_jl_libRmath_vectorize_4arg $qq ($rr)(nn::Integer, p1::Number, p2::Number, p3::Number) = - [ ccall(dlsym(_jl_libRmath,$string(rr)), Float64, (Float64,Float64,Float64), p1, p2, p3) for i=1:nn ] + [ ccall(dlsym(_jl_libRmath,$(string(rr))), Float64, (Float64,Float64,Float64), p1, p2, p3) for i=1:nn ] end end diff --git a/extras/bitarray.jl b/extras/bitarray.jl index 6ee49f5cbf49f..5d6b9426222aa 100644 --- a/extras/bitarray.jl +++ b/extras/bitarray.jl @@ -1,10 +1,10 @@ # prelimnary definitions: constants, macros # and functions used throughout the code const _msk64 = ~uint64(0) -macro _mskr(l) quote _msk64 >>> (64-$esc(l)) end end -macro _div64(l) quote $esc(l) >>> 6 end end -macro _mod64(l) quote $esc(l) & 63 end end -macro _msk_end(l) quote @_mskr @_mod64 $esc(l) end end +macro _mskr(l) quote _msk64 >>> (64-$(esc(l))) end end +macro _div64(l) quote $(esc(l)) >>> 6 end end +macro _mod64(l) quote $(esc(l)) & 63 end end +macro _msk_end(l) quote @_mskr @_mod64 $(esc(l)) end end _jl_num_bit_chunks(n::Int) = @_div64 (n+63) function _jl_check_is_valid_bit{T}(x::T) if !(isequal(x, zero(T)) || isequal(x, one(T))) @@ -1210,13 +1210,13 @@ end # implemented as a macro to improve performance macro _jl_reverse_bits(dest, src) quote - z = $esc(src) + z = $(esc(src)) z = ((z >>> 1) & 0x5555555555555555) | ((z << 1) & 0xaaaaaaaaaaaaaaaa) z = ((z >>> 2) & 0x3333333333333333) | ((z << 2) & 0xcccccccccccccccc) z = ((z >>> 4) & 0x0f0f0f0f0f0f0f0f) | ((z << 4) & 0xf0f0f0f0f0f0f0f0) z = ((z >>> 8) & 0x00ff00ff00ff00ff) | ((z << 8) & 0xff00ff00ff00ff00) z = ((z >>> 16) & 0x0000ffff0000ffff) | ((z << 16) & 0xffff0000ffff0000) - $esc(dest) = ((z >>> 32) & 0x00000000ffffffff) | ((z << 32) & 0xffffffff00000000) + $(esc(dest)) = ((z >>> 32) & 0x00000000ffffffff) | ((z << 32) & 0xffffffff00000000) end end @@ -1346,7 +1346,7 @@ end let findn_cache = nothing function findn_one(ivars) - s = { quote I[$i][count] = $ivars[i] end for i = 1:length(ivars)} + s = { quote I[$i][count] = $(ivars[i]) end for i = 1:length(ivars)} quote Bind = B[$(ivars...)] if Bind != z @@ -1398,19 +1398,19 @@ function gen_bitareduce_func(n, f) setlims = { quote # each dim of reduction is either 1:sizeA or ivar:ivar if contains(region,$i) - $lo[i] = 1 - $hi[i] = size(A,$i) + $(lo[i]) = 1 + $(hi[i]) = size(A,$i) else - $lo[i] = $hi[i] = $ivars[i] + $(lo[i]) = $(hi[i]) = $(ivars[i]) end end for i=1:n } - rranges = { :( ($lo[i]):($hi[i]) ) for i=1:n } # lo:hi for all dims + rranges = { :( $(lo[i]):$(hi[i]) ) for i=1:n } # lo:hi for all dims body = quote _tot = v0 $(setlims...) - $make_loop_nest(rvars, rranges, - :(_tot = ($f)(_tot, A[$(rvars...)]))) + $(make_loop_nest(rvars, rranges, + :(_tot = ($f)(_tot, A[$(rvars...)])))) R[_ind] = _tot _ind += 1 end @@ -1418,7 +1418,7 @@ function gen_bitareduce_func(n, f) local _F_ function _F_(f, A, region, R, v0) _ind = 1 - $make_loop_nest(ivars, { :(1:size(R,$i)) for i=1:n }, body) + $(make_loop_nest(ivars, { :(1:size(R,$i)) for i=1:n }, body)) end _F_ end @@ -1526,13 +1526,13 @@ transpose(B::BitVector) = reshape(copy(B), 1, length(B)) # implemented as a macro to improve performance macro _jl_transpose8x8(x) quote - y = $esc(x) + y = $(esc(x)) t = (y $ (y >>> 7)) & 0x00aa00aa00aa00aa; y = y $ t $ (t << 7) t = (y $ (y >>> 14)) & 0x0000cccc0000cccc y = y $ t $ (t << 14) t = (y $ (y >>> 28)) & 0x00000000f0f0f0f0 - $esc(x) = y $ t $ (t << 28) + $(esc(x)) = y $ t $ (t << 28) end end @@ -1649,25 +1649,25 @@ function permute(B::BitArray, perm) tmp = counts[end] toReturn[len+1] = quote ind = 1 - $tmp = $stridenames[len] + $tmp = $(stridenames[len]) end #inner most loop toReturn[1] = quote P[ind] = B[+($(counts...))+offset] ind+=1 - $counts[1]+= $stridenames[1] + $(counts[1]) += $(stridenames[1]) end for i = 1:len-1 tmp = counts[i] val = i toReturn[(i+1)] = quote - $tmp = $stridenames[val] + $tmp = $(stridenames[val]) end tmp2 = counts[i+1] val = i+1 toReturn[(i+1)+(len+1)] = quote - $tmp2 += $stridenames[val] + $tmp2 += $(stridenames[val]) end end toReturn diff --git a/extras/enum.jl b/extras/enum.jl index 69a872a846eb8..c0418ecd02c86 100644 --- a/extras/enum.jl +++ b/extras/enum.jl @@ -2,15 +2,15 @@ macro enum(T,syms...) N = int(Int.nbits) T = esc(T) sh = expr(:block, - {:(if x===$sym return print($string(sym)) end) for sym in syms}) + {:(if x===$sym return print($(string(sym))) end) for sym in syms}) blk = quote bitstype ($N) ($T) - ($esc(:symbols))(_::Type{$T}) = $syms - ($esc(:isequal))(a::($T), b::($T)) = eq_int(unbox($T,a),unbox($T,b)) - ($esc(:show))(io::IO, x::($T)) = $sh + $(esc(:symbols))(_::Type{$T}) = $syms + $(esc(:isequal))(a::($T), b::($T)) = eq_int(unbox($T,a),unbox($T,b)) + $(esc(:show))(io::IO, x::($T)) = $sh end for (sym,i) in enumerate(syms) - push(blk.args, :(const ($esc(sym)) = box($T,unbox(Int,$(i-1))))) + push(blk.args, :(const $(esc(sym)) = box($T,unbox(Int,$(i-1))))) end push(blk.args, :nothing) blk.head = :toplevel diff --git a/test/runtests.jl b/test/runtests.jl index 8636b4149ff47..f54b4100743d3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -16,7 +16,7 @@ end macro assert_approx_eq(a, b) quote - check_approx_eq($esc(a), $esc(b), $string(a), $string(b)) + check_approx_eq($(esc(a)), $(esc(b)), $(string(a)), $(string(b))) end end @@ -24,7 +24,7 @@ macro timeit(ex,name) quote t = Inf for i=1:5 - t = min(t, @elapsed $esc(ex)) + t = min(t, @elapsed $(esc(ex))) end println(rpad(strcat($name,":"), 20), t) end @@ -34,12 +34,12 @@ macro assert_fails(expr) quote ok = false try - $esc(expr) + $(esc(expr)) catch ok = true end if !ok - error(strcat("assertion failed: expected ",$string(expr)," to fail")) + error(strcat("assertion failed: expected ",$(string(expr))," to fail")) end end end