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

UndefVarError: @showln not defined #2

Closed
svaksha opened this issue Apr 11, 2016 · 9 comments
Closed

UndefVarError: @showln not defined #2

svaksha opened this issue Apr 11, 2016 · 9 comments

Comments

@svaksha
Copy link

svaksha commented Apr 11, 2016

Hi Tim,
I tried the @showln example in the readme and it throws an error :

LoadError: UndefVarError: @showln not defined

The errors are on v0.5 and v0.4 (Debian and Opensuse). Can you please explain with another example how your lib walks through the readme sample code?
Thanks in Advance.

@timholy
Copy link
Owner

timholy commented Apr 11, 2016

I should have explicitly said you need to have using DebuggingUtilities somewhere (either at the REPL or in the script). I just changed the README. Thanks!

@svaksha
Copy link
Author

svaksha commented Apr 12, 2016

@timholy I had that (Ps: I would have thought its obvious :-) ) and it still didnt work, so I am not sure what is wrong.

@timholy
Copy link
Owner

timholy commented Apr 12, 2016

To someone as knowledgeable as yourself, I also assumed that would have been obvious, but I couldn't imagine what else might have explained an UndefVarError.

So let's back up: if you do a git checkout git pull to make sure you're running the latest master, does the README example still fail? If so, can you paste your entire session in here?

@timholy timholy reopened this Apr 12, 2016
@svaksha
Copy link
Author

svaksha commented Apr 13, 2016

Hah, you flatter me needlessly :). Anyway, I pulled the latest master and tried it with a clean repo and while the UndefVarError didnt occur, the example does not return the value of the variable x. I crosschecked it on this scraper, @showln category, returns category = "Utilities" which is a variable hence returned correctly. Am I missing something here?

Additionally, I noticed that calling an array sets keyword @showln push! returns push! = push! which means there is no value being returned, which it should'nt as the lib is supposed to work on variables. Perhaps,it would be useful if the lib alerted the user about not using this on non-variables, or is this behaviour intentional? Thanks.

@timholy
Copy link
Owner

timholy commented Apr 13, 2016

It only prints the value, it shouldn't return it (that function returns nothing). Did it fail to print it?

I see though, that the built-in show returns a value. However, it's a little weird:

julia> x = 3
3

julia> y = 5
5

julia> z = @show x y
x = 3
y = 5
5

julia> z
5

julia> z = @show y x
y = 5
x = 3
3

julia> z
3

So it returns the last value.

Also:

julia> @show push!
push! = push!
push! (generic function with 15 methods)

In other words, this is supposed to work the same way @show does, except also print line information. It largely seems to do that, except it doesn't return the last value. I could change that.

@svaksha
Copy link
Author

svaksha commented Apr 14, 2016

On Wed, Apr 13, 2016 at 6:20 PM, Tim Holy notifications@github.com wrote:

It only prints the value, it shouldn't return it (that function returns nothing). Did it fail to print it?

Oops, I meant it didnt print** anything on the screen.

** used 'return' as a colloquial word that refers to showing the
output but I realise it can cause confusion.

I see though, that the built-in show returns a value. However, it's a little weird:

{snip}
julia> z
3

So it returns the last value.

Besides the last value, it also reassigns (for lack of a better term)
the last value if you re-use the variable (see below). Hope I
understood the functionality correctly this time!?

julia> a = 1; b = 42; c = 23
23

julia> b = @show a b c
a = 1
b = 42
c = 23
23

julia> b = @show a b c
a = 1
b = 23
c = 23
23

Also:

julia> @show push!
push! = push!
push! (generic function with 15 methods)

In other words, this is supposed to work the same way @show does, except also print line information. It largely seems to do that, except it doesn't return the last value. I could change that.

Yes, that would be useful but in the example cited in the README didnt
print anything on screen when I run the file, hence this BR. Also
@show push does not print the information about the functions /
methods when the file is run. There is a difference between the REPL
and running the file.

SVAKSHA ॥ http://about.me/svaksha

@timholy
Copy link
Owner

timholy commented Apr 14, 2016

By "run the file", did you do this?

julia> include("/tmp/showln_test.jl")
foo (generic function with 1 method)

julia> foo()
                 x = 5
                 (in foo at ./error.jl:26 at /tmp/showln_test.jl:5)
                 x = 7
                 (in foo at ./error.jl:26 at /tmp/showln_test.jl:7)

julia>

Notice you only get output when you call foo().

If you don't see any output printed, does that change if you change @showln to @show? You should see something like this:

julia> include("/tmp/showln_test.jl")
foo (generic function with 1 method)

julia> foo()
x = 5
x = 7

julia>

If you don't see that, then there's something weird about your julia installation.

@svaksha
Copy link
Author

svaksha commented Apr 15, 2016

Hi @timholy Changing it to @show worked on one machine but not on the other one. Perhaps it may be a b0rked Julia installation as you suggest instead of a bug in your package, so I am sorry if your time was wasted. Let me check that possibility - Is there a canonical way to check this? The make testall threw some errors and I am not sure how to rectify this other than reinstalling Julia. Thanks for the help.

@timholy
Copy link
Owner

timholy commented Apr 24, 2016

Returning the last-evaluated expression was implemented in 5f20ac4.

@timholy timholy closed this as completed Apr 24, 2016
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

2 participants