acop.go 621 B

1234567891011121314151617181920212223242526272829303132333435
  1. package selsl
  2. type Wherer interface {
  3. Find(name string) Object
  4. }
  5. type Where struct {
  6. Wherer
  7. }
  8. type Actorer interface {
  9. Where() Where
  10. }
  11. type Signature string
  12. type Actor struct {
  13. Actorer
  14. Actions map[Signature]Action
  15. }
  16. type Action func(*Actor, ...Object) Object
  17. func (a *Actor) Do(action string, names ...string) Object {
  18. objects := []Object{}
  19. for _, name := range names {
  20. object := a.Where().Find(name) // XXX error checking
  21. objects = append(objects, object)
  22. }
  23. /// XXX calculate signature based on object types.
  24. act := a.Actions[Signature(action)]
  25. /// XXX error checking
  26. return act(a, objects...)
  27. }