Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@assert message does not interpolate #5267

Closed
aviks opened this issue Dec 31, 2013 · 3 comments
Closed

@assert message does not interpolate #5267

aviks opened this issue Dec 31, 2013 · 3 comments

Comments

@aviks
Copy link
Member

aviks commented Dec 31, 2013

julia> versioninfo()
Julia Version 0.3.0-prerelease+695
Commit 47915f3* (2013-12-27 05:27 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin11.4.2)
  CPU: Intel(R) Core(TM)2 Duo CPU     L9400  @ 1.86GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY)
  LAPACK: libopenblas
  LIBM: libopenlibm

julia> a=1;b=2
2

julia> @assert a==b "$a not equal $b"
ERROR: assertion failed: :($(Expr(:string, :a, " not equal ", :b)))
 in error at error.jl:21
@JeffBezanson
Copy link
Member

I've added support for this, but doing this is not recommended since a lot of extra code has to be generated for constructing the interpolated string. While of course the string itself is only allocated in case of an error, it can still negatively affect surrounding code.

@mbauman
Copy link
Member

mbauman commented Jan 6, 2014

@JeffBezanson is that negative impact just in terms of compilation time and total code size (cache misses)? Or is there something else that I'm missing? It was one of the first things I tried to do as a beginner myself, so I'm just curious. As long as it's not in library code or a hot-path, it should be fine, yes?

@JeffBezanson
Copy link
Member

If the containing function is otherwise very simple, it can cause generation of a GC frame, which can slightly slow down calls to the function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants