mimopotato / funcml-core

Makes writing YAML or JSON files super cool with functions support!
https://funcml.org
MIT License
0 stars 0 forks source link

It should avoid circular recursivity #85

Open mimopotato opened 1 month ago

mimopotato commented 1 month ago

Leads to stack overflow:

value: $key
key: $value

To avoid this behavior, a state management must be implemented, taking care of:

Let's keep elegant in the solution.

An exception should be raise when this behavior is encountered, preferably at the first occurence:

CircularRecursivityError < ParserError
mimopotato commented 1 month ago

maybe funcml-core could determine this behavior at the loading phase, before calling mutations.

# fake logic to explain
read_file
| parse_file
| analyze_circular_recursivity
| call_recursivity!

otherwise, each mutation call should pass its current object as a call parameter:

object.mutate(mutations, self)
class Object
  def mutate(mutations = {}, calling_object)
    # here we should check if the calling_object is also
    # part of the current mutation context.
  end
end

it would require all #mutate method to implement a logic and doesn't looks like a good abstraction.

Since this behavior can be introduced using simple data-structure, I don't think it should be analyzed on funcml-cli or Karist side.