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

Extend @show: allow multiple args, return value of last #1757

Merged
merged 1 commit into from Jan 8, 2013

Conversation

toivoh
Copy link
Contributor

@toivoh toivoh commented Dec 14, 2012

This patch extends the @show macro in two ways, to make it more handy in debugging:

  • Multiple arguments are allowed, e.g.

    x, y = 3, 4
    @show x y
    

    prints

    x   = 3
    y   = 4
    
  • The value of @show is the value of it's last argument. Using this, @show can be inserted pretty much anywhere in an expression to produce a printout, e.g.

    f(args...) = some_computation_based_on_args
    

    can be rewritten to print out its return value like

    f(args...) = @show some_computation_based_on_args
    

    instead of

    function f(args...)
        result = some_computation_based_on_args
        @show result
        result
    end
    

I haven't come up with a case where it makes much sense to use both features at the same time. If anyone thinks that the value of @show with several arguments should be something else, please let me know.

@ViralBShah
Copy link
Member

This looks good to me. Any other views?

Also, needs a rebase for merging, assuming there are no other views.

@toivoh
Copy link
Contributor Author

toivoh commented Dec 29, 2012

I see that @StefanKarpinski already did the multiple arguments part. I've written a new patch on top of his.

@StefanKarpinski
Copy link
Sponsor Member

Sorry about that – I missed this patch.

@toivoh
Copy link
Contributor Author

toivoh commented Dec 29, 2012

No worries.

@toivoh
Copy link
Contributor Author

toivoh commented Jan 8, 2013

Ok, so good to merge?

StefanKarpinski added a commit that referenced this pull request Jan 8, 2013
Extend @show: allow multiple args, return value of last
@StefanKarpinski StefanKarpinski merged commit 421e5ce into JuliaLang:master Jan 8, 2013
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

Successfully merging this pull request may close these issues.

None yet

3 participants