COMEFROM flow control

According to wikipedia, COMEFROM flow control is considered a joke, unreadable or completely harmful. I would suggest that such a feature would be very useful in AOP scripts (for example, adding a logger to methods without adding log calls to methods).

Is the non-obviousness of such a management structure of potential disadvantage? Are there any other disadvantages?

Request for this question because of this .

+7
source share
2 answers

For beginners, it’s basically useless in any modern language, because you need to either:

  • Link to the position to go from the line number, and they are unstable.
  • Put a marker or label in the code to indicate the position from which you could move, thus destroying any possible benefits that do not require this.

also:

  • Makes any debugging check essentially useless.
  • It is not possible to capture any context where it jumped from unless you save the constant variables that cause the problems.

Best idea would be:

  • Write an API to connect.
  • Function call!
+1
source

For this purpose, Aspect Oriented Programming (wikipedia) seems to be a more organized solution than comefrom . See Bottom of Motivation and Basic Concepts (ibid) for an example of how registration can be added to a method in a separate text unit.

In a fairly dynamic language, you can handle these things with the help of β€œwrap” modifiers prior to the method:

  def do_something ... end log :do_something, "Something got done" 

In this far-fetched example, the log macro causes the do_something method to be replaced with a new method, which first calls the original do_something method and then writes something to the log.

0
source

All Articles