Hi;
I am looking for a way to detect constructor calls in a Expr and the return
statements.
a = quote
x = Foo(12)
y = x.val + x.id
I am planning to detect the constructor calls and return statement of a
function
a = quote begin
x = Foo(12)
y = 5 + 6
f(x.val,y)
x.val * y
end
a is an Expr, in this expression , I would like to detect the constructor
calls (Foo(12)( and distinguish them from nor
There is no AST-level distinction between a "constructor call" and a
"normal function call", see [1]. Look at the code in 'reflection.jl' to see
how to determine the applicable method for a given name (which may be a
constructor). If that doesn't help, it would be helpful to clarify the goal.
For
Hi, my end goal is whenever a constructor call is made, I want to detect it
and keep track of it by creating an object
For example
f = Foo(12)
I want to detect this and create a record and save it to a db.
Thanks
On Sunday, January 3, 2016 at 6:58:49 PM UTC-8, Isaiah wrote:
>
> There is
Hi,
Maybe I am missing something, but could you just put the recording code in
the constructor itself?
type Foo
x::Int
function Foo(x)
record_Foo()
new(x)
end
end
Hi Julia,
The simplest way to do this is to make Foo a type and define its type
constructor to behave as you wish.
type Foo
n::Float64
end
function Foo(n::Float64)
record = createRecordForFooDB(n)
saveRecordInFooDB(record)
println("saved Foo($(n)) to DB")
end
On Sunday, January
But the you can't be doing this for every new type which is being defined
by other programmers.
So I need more general way. For every constructor of every type,
That makes it a bit problematic.
Thanks
On Sunday, January 3, 2016 at 7:59:11 PM UTC-8, Jeffrey Sarnoff wrote:
>
> Hi Julia,
>
> The s
Do you want to create DB entries when other programmer's types are called?
On Sunday, January 3, 2016 at 11:22:10 PM UTC-5, Julia Tylors wrote:
>
> But the you can't be doing this for every new type which is being defined
> by other programmers.
> So I need more general way. For every constructor
Are you trying to instrument all creation of typed instances?
On Sunday, January 3, 2016 at 11:24:25 PM UTC-5, Jeffrey Sarnoff wrote:
>
> Do you want to create DB entries when other programmer's types are called?
>
> On Sunday, January 3, 2016 at 11:22:10 PM UTC-5, Julia Tylors wrote:
>>
>> But th
Yes basically I am trying to instrument all creation of typed instances.
detect an constructor call and record it. for a specific piece of code.
For example
@detect function f(x::Int64)
y = Foo(x)
end
On Sunday, January 3, 2016 at 8:28:04 PM UTC-8, Jeffrey Sarnoff wrote:
>
> Are you t
I have no direct knowledge of that. Until someone else can give you more
specific guidance, take a look at how profiling is done (as that involves
the same task):
https://github.com/timholy/IProfile.jl
http://docs.julialang.org/en/latest/manual/profile/
https://github.com/JuliaLang/julia/blob/ma
You could try looking for :new exprs:
julia> type Foo f::Int end
julia> f() = Foo(12)
f (generic function with 1 method)
julia> @code_typed f()
1-element Array{Any,1}:
:($(Expr(:lambda, Any[], Any[Any[],Any[],Any[],Any[]], :(begin # none, line
1:
return $(Expr(:new, :((top(getfield))(
How about we override
Base.call{T}(::Type{T},args...) = ( mystuff; original Base.call; )
Can i do something like this?
Thanks
On Sunday, January 3, 2016 at 6:58:49 PM UTC-8, Isaiah wrote:
>
> There is no AST-level distinction between a "constructor call" and a
> "normal function call", see [1]
I can get you halfway there:
julia> Base.call{T<:Function}(fn::T, arg::Any) = begin println("I see:
($fn($arg))"); fn(arg) end
call (generic function with 1037 methods)
julia> Base.call{T<:Function}(fn::T, arg1::Any, arg2::Any) = begin
println("I see: ($fn($arg1,$arg2))"); fn(arg1,arg2) end
cal
14 matches
Mail list logo