queirozfcom / rachinations

Other
2 stars 0 forks source link

Think about what I would need to do to enable using nodes that are not yet created #70

Closed queirozfcom closed 9 years ago

queirozfcom commented 9 years ago

Sometimes it seems more natural to define bahaviours of nodes in relation to nodes that were not yet created. For example, situations like the following:

  # 'p1' is mentioned here but it's only created in the next line
  source 's1', :automatic, triggers: 'p1' 
  pool 'p1'

It's not very clear to me when this would actually raise errors (because it would depend on when methods are actually called on class Diagram) but it probably would eventually.

Maybe I would need to defer the actual method calls until after all nodes, edges have been added.

queirozfcom commented 9 years ago

Right now I have a problem because methods like Node#attach_edge! are called on an actual node when a call to edge (in the DSL) is made. I need to delay all these 'links' until after the whole diagram has been created.

queirozfcom commented 9 years ago

Method calls in the DSL will not cause actual methods in class Diagramto get called. These things will be saved internally and will only be available to the DSL.

At the end of the block started by diagram, I will read all these things and call the actual methods in class Diagram. At this point, I will be able to order the method calls so that all needed nodes and edges are created prior to being referenced.

This would, however, preclude circular references like

pool 'p1', triggers: 'p2' 
pool 'p2', triggered_by: 'p3'
pool 'p3', something_something_references_pool_p1

Because the references would never be able to be realized.

(maybe not because I could create each node bare (i.e. just the object with nothing else) and then add stuff to them piecemeal.)

queirozfcom commented 9 years ago

All this without breaking any tests :smile: