[julia-users] Re: How to debug the Debug.jl

2015-10-28 Thread juliatylors
Thanks all,
I managed to do it.

On Tuesday, October 27, 2015 at 9:43:45 PM UTC-7, julia...@gmail.com wrote:
>
> I want to debug the Debug.jl itself?
>
> Is there a special cut of instructions to do it? Because when i use @debug 
> and @bp macro on itself. it fails.
>
> Thanks
>


[julia-users] Function call tree

2015-10-28 Thread juliatylors
Hi;

Is there an easy way to get function call tree in Julia.

For example, if a call f(3), it will give me a result like follows at least 
in text format.

f(3)
  |- g(4)
  | |- h(5)
  |- h(8)

Thanks


[julia-users] How to debug the Debug.jl

2015-10-27 Thread juliatylors
I want to debug the Debug.jl itself?

Is there a special cut of instructions to do it? Because when i use @debug 
and @bp macro on itself. it fails.

Thanks


[julia-users] Re: Generated Type from a Macro

2015-10-21 Thread juliatylors
Thanks for your help, but it works, but i have another problem, 
accidentally i opened a new post,

here is the link including a ccall and type definition in a macro:

https://groups.google.com/forum/#!topic/julia-users/jDayl3Wx8uU.

I followed the game you suggested but something is fishy i guess.

On Tuesday, October 20, 2015 at 12:02:37 PM UTC-7, julia...@gmail.com wrote:
>
> Hi fellows,
>
> Question 1:
>
> I am trying to generate a type  in a macro and expect to see it in the 
> calling context.
> this is what i am doing in the macro:
> code = quote eval(parse(string("type ", $(priv_typname), " end"))) end
>
> here is what is returned from the macro
> eval(parse(string("type ",$(Expr(:escape, "priv_Eq"))," end")))
>
> but in the julia shell, when i try to do this :
>
> julia> a = priv_Eq()
> ERROR: UndefVarError: priv_Eq not defined
>
> can somebody tell me why and what I am doing wrong?
>
>
> Question 2:
>
> I am also trying to generate a parametrized type like:
>
> type Eq{T,S}
> end
>
> any suggestions to append the type_params to the type programmatically?
>
> Thanks
>
>
>
>
>
>

[julia-users] ccall and type definition in a macro

2015-10-21 Thread juliatylors
Hi,

I am having the following problem. Here is my code:
julia> macro myname(arg)
  typname = esc(arg)
  privtypname = esc(symbol(string("priv",arg)))
  code = quote
  typealias $(typname) ccall( (:clock, "libc"), Int32, ())
  type $privtypname
  a
  end
  end
  return code
   end

the error i get is : *ERROR: error compiling anonymous: type definition not 
allowed inside a local scope*

Can anyone tell me what is wrong? The macroexpand code seems normal:

julia> macroexpand(:(@myname goox))
quote  # none, line 5:
typealias goox ccall((:clock,"libc"),Int32,()) # none, line 6:
type privgoox # none, line 7:
a
end
end

thanks


Re: [julia-users] Generated Type from a Macro

2015-10-20 Thread juliatylors
macro mymac(args...)
typname = esc(args[1])
priv_typname= esc(string("priv_",args[1]))
#code
code = quote
#create  a type
eval(parse(string("type ", $(priv_typname), " end")))
end
return code 
end

Here is the macro,
and i don't still understand what is going wrong?
and I also have another question, is it a good idea to use eval within a 
macro?

Thanks

On Tuesday, October 20, 2015 at 12:14:37 PM UTC-7, Isaiah wrote:
>
> Please do work through the examples in the Metaprogramming section of the 
> manual to learn how to take apart and reassemble expressions to do what you 
> need:
>
> http://docs.julialang.org/en/release-0.4/manual/metaprogramming/
>
> There are tools (such as `macroexpand`) introduced in the manual that will 
> help you debug this kind of issue. 
>
> In general, when asking questions on the list, please:
> - search for previous discussions (such as this one: 
> https://groups.google.com/forum/#!searchin/julia-users/type$20macro/julia-users/r9sGn-k7SDw/Xm0nKsKBBJYJ
> )
> - provide a complete example. "this is what i am doing in the macro" does 
> not provide enough context.
>
> Thanks!
>
> On Tue, Oct 20, 2015 at 3:02 PM, > wrote:
>
>> Hi fellows,
>>
>> Question 1:
>>
>> I am trying to generate a type  in a macro and expect to see it in the 
>> calling context.
>> this is what i am doing in the macro:
>> code = quote eval(parse(string("type ", $(priv_typname), " end"))) end
>>
>> here is what is returned from the macro
>> eval(parse(string("type ",$(Expr(:escape, "priv_Eq"))," end")))
>>
>> but in the julia shell, when i try to do this :
>>
>> julia> a = priv_Eq()
>> ERROR: UndefVarError: priv_Eq not defined
>>
>> can somebody tell me why and what I am doing wrong?
>>
>>
>> Question 2:
>>
>> I am also trying to generate a parametrized type like:
>>
>> type Eq{T,S}
>> end
>>
>> any suggestions to append the type_params to the type programmatically?
>>
>> Thanks
>>
>>
>>
>>
>>
>>
>

Re: [julia-users] Generated Type from a Macro

2015-10-20 Thread juliatylors
macro mymac(args...)
typname = args[1]
priv_typname= esc(string("priv_",trait.name))
#code
code = quote
#create  a type
eval(parse(string("type ", $(priv_typname), " end")))
end
return code 
end

Still couldn't get it to work, and i don't see what I am missing?
One more question, is it good idea to use eval within a macro?
thanks

On Tuesday, October 20, 2015 at 12:14:37 PM UTC-7, Isaiah wrote:
>
> Please do work through the examples in the Metaprogramming section of the 
> manual to learn how to take apart and reassemble expressions to do what you 
> need:
>
> http://docs.julialang.org/en/release-0.4/manual/metaprogramming/
>
> There are tools (such as `macroexpand`) introduced in the manual that will 
> help you debug this kind of issue. 
>
> In general, when asking questions on the list, please:
> - search for previous discussions (such as this one: 
> https://groups.google.com/forum/#!searchin/julia-users/type$20macro/julia-users/r9sGn-k7SDw/Xm0nKsKBBJYJ
> )
> - provide a complete example. "this is what i am doing in the macro" does 
> not provide enough context.
>
> Thanks!
>
> On Tue, Oct 20, 2015 at 3:02 PM, > wrote:
>
>> Hi fellows,
>>
>> Question 1:
>>
>> I am trying to generate a type  in a macro and expect to see it in the 
>> calling context.
>> this is what i am doing in the macro:
>> code = quote eval(parse(string("type ", $(priv_typname), " end"))) end
>>
>> here is what is returned from the macro
>> eval(parse(string("type ",$(Expr(:escape, "priv_Eq"))," end")))
>>
>> but in the julia shell, when i try to do this :
>>
>> julia> a = priv_Eq()
>> ERROR: UndefVarError: priv_Eq not defined
>>
>> can somebody tell me why and what I am doing wrong?
>>
>>
>> Question 2:
>>
>> I am also trying to generate a parametrized type like:
>>
>> type Eq{T,S}
>> end
>>
>> any suggestions to append the type_params to the type programmatically?
>>
>> Thanks
>>
>>
>>
>>
>>
>>
>

[julia-users] Generated Type from a Macro

2015-10-20 Thread juliatylors
Hi fellows,

Question 1:

I am trying to generate a type  in a macro and expect to see it in the 
calling context.
this is what i am doing in the macro:
code = quote eval(parse(string("type ", $(priv_typname), " end"))) end

here is what is returned from the macro
eval(parse(string("type ",$(Expr(:escape, "priv_Eq"))," end")))

but in the julia shell, when i try to do this :

julia> a = priv_Eq()
ERROR: UndefVarError: priv_Eq not defined

can somebody tell me why and what I am doing wrong?


Question 2:

I am also trying to generate a parametrized type like:

type Eq{T,S}
end

any suggestions to append the type_params to the type programmatically?

Thanks







[julia-users] Macro definition and call environments

2015-10-14 Thread juliatylors
Hi,

can someone explain what macro definition environment and macro call 
environment?

- I was reading the following page: 
http://docs.julialang.org/en/release-0.4/manual/metaprogramming/#man-metaprogramming
  - it says in the Hygiene section : 
"Local variables are then renamed to be unique (using the gensym() 
 function, 
which generates new symbols), and *global variables are resolved within the 
macro definition environment. "*
*  - Do these global variables also refer to function calls like 
 time(), println() within a macro??*


In a later passage:
  - Here the user expression ex is a call to time, but not the same time 
function that the macro uses. It clearly refers to MyModule.time. *Therefore 
we must arrange for the code in **ex to be resolved in the macro call 
environment.*


*I am kind of confused how to think of the hygiene of a macro:*
*  - Should i be thinking in terms of what is returned as an expr from the 
macro should not conflict with the code context where it is returned?*
*  - Or should i be thinking in terms of what is being supplied to macro 
should not conflict with what is inside the macro?*


*Thanks*


[julia-users] Macro definition & call environments

2015-10-14 Thread juliatylors
Hi,

can someone explain what macro definition environment and macro call 
environment?

- I was reading the following 
page: 
http://docs.julialang.org/en/release-0.4/manual/metaprogramming/#man-metaprogramming
  - it says in the Hygiene section : 
Local variables are then renamed to be unique (using the gensym() 
 
function, which generates new symbols), and *global variables are resolved 
within the macro definition environment. *


In a later passage:

Thanks.


Re: [julia-users] Call by name

2015-10-14 Thread juliatylors
I mean evaluation strategy.

for example, in scala you use :=> syntax for call by name evaluation 
strategy. is there a similar syntax in Julia?
Thanks

On Wednesday, October 14, 2015 at 1:01:45 PM UTC-7, Stefan Karpinski wrote:
>
> Do you mean the evaluation strategy 
> ? Or keyword 
> arguments 
> 
> ?
>
> On Wed, Oct 14, 2015 at 11:17 PM, > 
> wrote:
>
>> Hi,
>>
>> I was wondering whether there is a syntax for call by name parameter 
>> passing ?
>>
>> Thanks.
>>
>
>

[julia-users] Call by name

2015-10-14 Thread juliatylors
Hi,

I was wondering whether there is a syntax for call by name parameter 
passing ?

Thanks.


[julia-users] Parameter type

2015-10-13 Thread juliatylors
Hi, I would like to know the difference between:

function f1(::Int64) 

and 

function f2(::Type{Int64})


when to use which ?

Thanks


[julia-users] function parameter question

2015-10-12 Thread juliatylors
/*Function 1*/
function fun1(::Int64)


/*Function 2*/
function func2(::Type{Int64})


Hi fellows,

I am kind of confused what does these 2 parameter usages mean?

Where are they used? What are the use cases?

Thanks