julia> begin
           @show vara = 33
           @show varb = vara * 14
           @show varc = varb * 77
       end
vara = 33 = 33
varb = vara * 14 = 462
varc = varb * 77 = 35574
35574


On Sun, Jan 4, 2015 at 5:47 AM, Mike Innes <[email protected]> wrote:

> Have you met @show?
>
> On 4 January 2015 at 11:10, <[email protected]> wrote:
>
>> I think you need a macro, something like:
>>
>> macro printvar(var)
>>        return :(print($(string(var))); print("="); println($var))
>> end
>>
>> julia> a=2
>> 2
>>
>> julia> @printvar a
>> a=2
>>
>> Cheers
>> Lex
>>
>> On Sunday, January 4, 2015 8:48:27 PM UTC+10, Arch Call wrote:
>>>
>>> I frequently find myself writing Julia snippet scripts like this:
>>>
>>>
>>>  vara = 33
>>>
>>> varb = vara * 14
>>>
>>> varc = varb * 77
>>>
>>> println(“varb = “, varb) #--debug print
>>>
>>> println(“varc = “, varc) #--debug print
>>>
>>>
>>>  I would like to eliminate having to enter the variable name twice
>>>
>>> in the debug print lines by using a function.
>>>
>>>
>>>  I have tried all kinds of variations of a debug print function like:
>>>
>>>
>>>  function debugprint(somevar)
>>>
>>> println(“???? = ”, somevar)
>>>
>>> end
>>>
>>>
>>>  What can I put in place of “????” to get the actual Symbol of the
>>> variable being passed to debugprint?
>>>
>>
>

Reply via email to