Compile error: Polymorphic External slot is not possible.

Jeremy Cowgar jeremy at cowgar.com
Tue Aug 25 22:04:08 UTC 2009


> I think BUTTON must reimplement the slot perform_action from a parent.
> And, Lisaac can't do that when the redefined slot is in the Section
> External. It's simply not possible. Find another name for your external
> slot.
> 
> External slots are not like any other slots, they work completely
> differently, better not to try making one inherit from the other.

BUTTON is the only place that perform_action is implemented. The problem
was/is this (after more experimenting I figured out a way around it, but
I think it's a bug):

Section Header
  + name := BUTTON;

Section External
  - perform_action ... ... ...

Now, the user of the BUTTON object registers a block of code to perform
the action. That function looks like this:

Section Public
  - set_action b:{INTEGER} <-
  (
    // code to set the action
    `IupSetCallback(@h, "ACTION", perform_action)`;
    
    `
    #if 0
    `;
    perform_action NULL;
    `
    #endif
    `;
  );

Now, the #if 0 is in there so that my perform_action is not optimized
away. This works fine when you only have 1 button. However, if you do
this (in the program that uses BUTTON):

  b1 := BUTTON.make "Hello";
  b1.set_action { "Hello".println; 0 };
  b2 := BUTTON.make "Bye";
  b2.set_action { "Goodbye".println; 0 };

That causes my error. It seems that Lisaac thinks the external is going
to be called from two different BUTTON instances, and it will not allow
it for some reason.

Anyway, I got around this problem, but it stems from the root that
Section External's are optimized out of the resulting .c file.

-- 
Jeremy Cowgar <jeremy at cowgar.com>




More information about the Lisaac-devel mailing list