circular dependency

View: New views
6 Messages — Rating Filter:   Alert me  

circular dependency

by Ittay Dror :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have the following build file:
define 'proj' do
  define 'A' do
    project('B')
  end

  define 'B' do
    project('A')
  end
end


running buildr, i get the message:
Circular dependency detected: TOP => proj:A => proj:B => proj:A

this is done (i think) because the 'project' method invokes the project
task. project('B') invokes 'B' which then has 'project('A')' which
invokes A.

is there a way to avoid this? (I actually need it to get properties from
the project, it doesn't need to take any action)

thank you,
ittay

--
--
Ittay Dror <ittay.dror@...>



Re: circular dependency

by Assaf Arkin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Jul 16, 2008 at 4:40 AM, Ittay Dror <ittay.dror@...> wrote:

> Hi,
>
> I have the following build file:
> define 'proj' do
>  define 'A' do
>   project('B')
>  end
>
>  define 'B' do
>   project('A')
>  end
> end
>
>
> running buildr, i get the message:
> Circular dependency detected: TOP => proj:A => proj:B => proj:A
>
> this is done (i think) because the 'project' method invokes the project
> task. project('B') invokes 'B' which then has 'project('A')' which invokes
> A.
>
> is there a way to avoid this? (I actually need it to get properties from
> the project, it doesn't need to take any action)


If the properties of that project are unknown until it's defined, then you
have a classical circular dependency: the definition of A depends on the
definition of B which depends on the definition of A.

If the properties are not decided by the definition, then you can put the
outside, e.g. define a constant and access it from either definition.

Assaf


>
>
> thank you,
> ittay
>
> --
> --
> Ittay Dror <ittay.dror@...>
>
>
>

Re: circular dependency

by Ittay Dror :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Assaf Arkin wrote:

> On Wed, Jul 16, 2008 at 4:40 AM, Ittay Dror <ittay.dror@...> wrote:
>
>  
>> Hi,
>>
>> I have the following build file:
>> define 'proj' do
>>  define 'A' do
>>   project('B')
>>  end
>>
>>  define 'B' do
>>   project('A')
>>  end
>> end
>>
>>
>> running buildr, i get the message:
>> Circular dependency detected: TOP => proj:A => proj:B => proj:A
>>
>> this is done (i think) because the 'project' method invokes the project
>> task. project('B') invokes 'B' which then has 'project('A')' which invokes
>> A.
>>
>> is there a way to avoid this? (I actually need it to get properties from
>> the project, it doesn't need to take any action)
>>    
>
>
> If the properties of that project are unknown until it's defined, then you
> have a classical circular dependency: the definition of A depends on the
> definition of B which depends on the definition of A.
>  
they each depend on the *act* of definition, that is, that a task is
invoked. if 'define' was just analogous to 'new', things would work.
putting the properties outside will break the nice modularization.

> If the properties are not decided by the definition, then you can put the
> outside, e.g. define a constant and access it from either definition.
>
> Assaf
>
>
>  
>> thank you,
>> ittay
>>
>> --
>> --
>> Ittay Dror <ittay.dror@...>
>>
>>
>>
>>    
>
>  

--
--
Ittay Dror <ittay.dror@...>


Re: circular dependency

by Assaf Arkin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Jul 16, 2008 at 9:01 PM, Ittay Dror <ittay.dror@...> wrote:

>
>
> Assaf Arkin wrote:
>
>> On Wed, Jul 16, 2008 at 4:40 AM, Ittay Dror <ittay.dror@...> wrote:
>>
>>
>>
>>> Hi,
>>>
>>> I have the following build file:
>>> define 'proj' do
>>>  define 'A' do
>>>  project('B')
>>>  end
>>>
>>>  define 'B' do
>>>  project('A')
>>>  end
>>> end
>>>
>>>
>>> running buildr, i get the message:
>>> Circular dependency detected: TOP => proj:A => proj:B => proj:A
>>>
>>> this is done (i think) because the 'project' method invokes the project
>>> task. project('B') invokes 'B' which then has 'project('A')' which
>>> invokes
>>> A.
>>>
>>> is there a way to avoid this? (I actually need it to get properties from
>>> the project, it doesn't need to take any action)
>>>
>>>
>>
>>
>> If the properties of that project are unknown until it's defined, then you
>> have a classical circular dependency: the definition of A depends on the
>> definition of B which depends on the definition of A.
>>
>>
> they each depend on the *act* of definition, that is, that a task is
> invoked. if 'define' was just analogous to 'new', things would work. putting
> the properties outside will break the nice modularization.


If define worked like new, then A couldn't reference B because B doesn't
exist when define('A') is called.  So what Buildr is doing is holding on to
the definition under proj, but not running it (equivalent to constructor)
until absolutely necessary.

You can rewrite it as:

a = define('a')
b = define('b') do
  a.invoke
end
a.enhance do
  b.invoke
end

Assaf


>
>  If the properties are not decided by the definition, then you can put the
>> outside, e.g. define a constant and access it from either definition.
>>
>> Assaf
>>
>>
>>
>>
>>> thank you,
>>> ittay
>>>
>>> --
>>> --
>>> Ittay Dror <ittay.dror@...>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>
> --
> --
>
> Ittay Dror <ittay.dror@...>
>
>

Re: circular dependency

by Ittay Dror :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Assaf Arkin wrote:

> On Wed, Jul 16, 2008 at 9:01 PM, Ittay Dror <ittay.dror@...> wrote:
>
>  
>> Assaf Arkin wrote:
>>
>>    
>>> On Wed, Jul 16, 2008 at 4:40 AM, Ittay Dror <ittay.dror@...> wrote:
>>>
>>>
>>>
>>>      
>>>> Hi,
>>>>
>>>> I have the following build file:
>>>> define 'proj' do
>>>>  define 'A' do
>>>>  project('B')
>>>>  end
>>>>
>>>>  define 'B' do
>>>>  project('A')
>>>>  end
>>>> end
>>>>
>>>>
>>>> running buildr, i get the message:
>>>> Circular dependency detected: TOP => proj:A => proj:B => proj:A
>>>>
>>>> this is done (i think) because the 'project' method invokes the project
>>>> task. project('B') invokes 'B' which then has 'project('A')' which
>>>> invokes
>>>> A.
>>>>
>>>> is there a way to avoid this? (I actually need it to get properties from
>>>> the project, it doesn't need to take any action)
>>>>
>>>>
>>>>        
>>> If the properties of that project are unknown until it's defined, then you
>>> have a classical circular dependency: the definition of A depends on the
>>> definition of B which depends on the definition of A.
>>>
>>>
>>>      
>> they each depend on the *act* of definition, that is, that a task is
>> invoked. if 'define' was just analogous to 'new', things would work. putting
>> the properties outside will break the nice modularization.
>>    
>
>
> If define worked like new, then A couldn't reference B because B doesn't
> exist when define('A') is called.  So what Buildr is doing is holding on to
> the definition under proj, but not running it (equivalent to constructor)
> until absolutely necessary.
>
> You can rewrite it as:
>
> a = define('a')
> b = define('b') do
>   a.invoke
>  
here a.already_invoked is set to true
> end
> a.enhance do
>   b.invoke
> end
>  
this action is never called since task a (the project) is already invoked


> Assaf
>
>
>  
>>  If the properties are not decided by the definition, then you can put the
>>    
>>> outside, e.g. define a constant and access it from either definition.
>>>
>>> Assaf
>>>
>>>
>>>
>>>
>>>      
>>>> thank you,
>>>> ittay
>>>>
>>>> --
>>>> --
>>>> Ittay Dror <ittay.dror@...>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>        
>>>
>>>      
>> --
>> --
>>
>> Ittay Dror <ittay.dror@...>
>>
>>
>>    
>
>  

--
--
Ittay Dror <ittay.dror@...>


Re: circular dependency

by Ittay Dror :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i solved this by
define 'A' do
  ....project('B')....
end

define 'B' do
....
end

project('B').compile.with(project('A'))

ittay

Assaf Arkin wrote:

> On Wed, Jul 16, 2008 at 9:01 PM, Ittay Dror <ittay.dror@...> wrote:
>
>  
>> Assaf Arkin wrote:
>>
>>    
>>> On Wed, Jul 16, 2008 at 4:40 AM, Ittay Dror <ittay.dror@...> wrote:
>>>
>>>
>>>
>>>      
>>>> Hi,
>>>>
>>>> I have the following build file:
>>>> define 'proj' do
>>>>  define 'A' do
>>>>  project('B')
>>>>  end
>>>>
>>>>  define 'B' do
>>>>  project('A')
>>>>  end
>>>> end
>>>>
>>>>
>>>> running buildr, i get the message:
>>>> Circular dependency detected: TOP => proj:A => proj:B => proj:A
>>>>
>>>> this is done (i think) because the 'project' method invokes the project
>>>> task. project('B') invokes 'B' which then has 'project('A')' which
>>>> invokes
>>>> A.
>>>>
>>>> is there a way to avoid this? (I actually need it to get properties from
>>>> the project, it doesn't need to take any action)
>>>>
>>>>
>>>>        
>>> If the properties of that project are unknown until it's defined, then you
>>> have a classical circular dependency: the definition of A depends on the
>>> definition of B which depends on the definition of A.
>>>
>>>
>>>      
>> they each depend on the *act* of definition, that is, that a task is
>> invoked. if 'define' was just analogous to 'new', things would work. putting
>> the properties outside will break the nice modularization.
>>    
>
>
> If define worked like new, then A couldn't reference B because B doesn't
> exist when define('A') is called.  So what Buildr is doing is holding on to
> the definition under proj, but not running it (equivalent to constructor)
> until absolutely necessary.
>
> You can rewrite it as:
>
> a = define('a')
> b = define('b') do
>   a.invoke
> end
> a.enhance do
>   b.invoke
> end
>
> Assaf
>
>
>  
>>  If the properties are not decided by the definition, then you can put the
>>    
>>> outside, e.g. define a constant and access it from either definition.
>>>
>>> Assaf
>>>
>>>
>>>
>>>
>>>      
>>>> thank you,
>>>> ittay
>>>>
>>>> --
>>>> --
>>>> Ittay Dror <ittay.dror@...>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>        
>>>
>>>      
>> --
>> --
>>
>> Ittay Dror <ittay.dror@...>
>>
>>
>>    
>
>  

--
--
Ittay Dror <ittay.dror@...>