#2023 dynamic class

rhodes Sat 8 Sep 2012

I submit the following for consideration.

dynamic class MyObj
{
  **
  ** trap would always be called when accessing a slot
  **
  override Obj? trap(...
}

Marking a class dynamic would mean that any attempt to access one of its slots would result in a call to trap.

myObj.field1   // trap would be called even without an explicit dynamic accessor

would be the same as

myObj->field1

for this class.

brian Sun 9 Sep 2012

Hi @rhodes, welcome to Fantom.

That is sort of how C# handles where an object is either dynamic or static and we just use one operator. I discussed this a bit in a blog entry. I think it is always nice to mix the two on the same object. Even in your case if you wanted to trap everything, then there is still core methods like toStr that should be typed.

Login or Signup to reply.