Skip to content
Snippets Groups Projects
Select Git revision
  • 061507215aff1ff33157c6e78fb7a57b6ed0f766
  • master default protected
2 results

tron_adapter.cpp

Blame
  • SCROLLBoot.scala 1.08 KiB
    import annotations.Role
    import scroll.internal.Compartment
    
    object SCROLLBoot extends App {
    
      /**
       * Just a simple natural type.
       * Can not do anything but printing some statement on stdout.
       */
      class SomePlayer {
        def hello(): Unit = {
          println("Hello World from some player!")
        }
      }
    
      /**
       * A new compartment. Only containing one role for demo purposes.
       */
      class SomeCompartment extends Compartment {
    
        /**
         * A role that will be bound to [[SomePlayer]] later on
         * and will alter its behaviour.
         */
        @Role class SomeRole {
          def hello(): Unit = {
            println("Hello World from some role!")
          }
        }
    
      }
    
      val player = new SomePlayer()
    
      /**
       * This will use the standard behaviour defined in the natural type.
       */
      player.hello()
    
      /**
       * Creating an anonymous instance of the [[Compartment]] defined above.
       */
      new SomeCompartment {
        /**
         * Creating a play-relation now and calling the compound-objects behaviour
         * which is actually defined in its role [[SomeRole]].
         */
        player play new SomeRole() hello()
      }
    }