kdmnk
kdmnk

Reputation: 5

Is it possible to define recursive entity structure with Elixir Spark?

defmodule Im.Dsl.Entities.ReceiveCmd do
  def cmd(), do: %Spark.Dsl.Entity{
        name: :rcv,
        describe: "Receive command.",
        target: Im.Commands.Receive,
        ...
        entities: [body: [
          Im.Dsl.Entities.IfCondCmd.cmd(),
          Im.Dsl.Entities.ReceiveCmd.cmd() # end up in infinite loop during compilation
        ]]
}

Is it possible to define an entity that can have the same type of entity as a child?

Context: I'm defining a DSL for defining semantics of processes with some predefined commands as entities. In this case, the process sends messages to 2 clients and receives their responses. But I can't add a receive statement within a receive statement:

snd user1, commitRequest
snd user2, commitRequest
rcv {message1, some_user} do
   rcv {message2, some_other_user} do
     ....
   end
end

Is there any alternative recommended way to design such DSLs?

Upvotes: 0

Views: 45

Answers (0)

Related Questions