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 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 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 3, 2016 at 10:49:12 PM UTC-5, Julia Tylors wrote:
>>>>
>>>> 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 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 return statements, use `expand(a)` to convert the expression to 
>>>>> goto form, which should contain only explicit returns.
>>>>>
>>>>> [1] https://github.com/JuliaLang/julia/pull/8712
>>>>>
>>>>> On Sun, Jan 3, 2016 at 6:52 PM, Julia Tylors <[email protected]> 
>>>>> wrote:
>>>>>
>>>>>> 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 normal function 
>>>>>> calls(fx.val,y).
>>>>>> and i also want to identify the return statement, (x.val*y). How can 
>>>>>> i do it programmatically?
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>>        
>>>>>>
>>>>>
>>>>>

Reply via email to