Is it possible to convert an instance to one of it's subclasses temporarely at runtime?
-- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
???
An instance of A always _is_ an instance of its subclass B (with a few exceptions like {A=Object, B=String} and similar ones). E.g. did I misunderstood something in the question? Herby Mircea Samoilă wrote: > Is it possible to convert an instance to one of it's subclasses temporarely at runtime? > -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Consider the class hierarchy:
Object - SomeClass - AnotherClass - ThirdClass anInstance := AnotherClass new. How could I convert anInstance to be based off ThirdClass now... and then back again when I need to. OR More complex example: Object - SomeClass - AnotherClass Object - ThirdClass Consider firstInstance of AnotherClass and secondInstance of ThirdClass. How can I make the two instances behave like one, Messages sent to secondInstance and implemented in ThirdClass are fine but all others get redirect to firstInstance as if "super" the keyword were a pointer to firstInstance. This would make it seem, temporarily that ThirdClass inherits from AnotherClass and the two instances are glued together. Closest I could find is https://en.m.wikipedia.org/wiki/Object_slicing OR Even more complicated. Can I hack the "super" keyword directly via Javascript somewhere so that certain Instances see other Instances as their "super". PS. Instances don't need to actually be merged, communication is one way and when the instance that super was pointing to is gone I would like it to revert to normal functionality. Pe 17 sept. 2015, la 18:42, Herby Vojčík <[hidden email]> a scris: > ??? > > An instance of A always _is_ an instance of its subclass B (with a few exceptions like {A=Object, B=String} and similar ones). > > E.g. did I misunderstood something in the question? > > Herby > > Mircea Samoilă wrote: >> Is it possible to convert an instance to one of it's subclasses temporarely at runtime? > > -- > You received this message because you are subscribed to the Google Groups "amber-lang" group. > To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Mircea Samoilă wrote: > Consider the class hierarchy: > Object > - SomeClass > - AnotherClass > - ThirdClass > > anInstance := AnotherClass new. > > How could I convert anInstance to be based off ThirdClass now... and then back again when I need to. > > OR > > More complex example: > > Object > - SomeClass > - AnotherClass > > Object > - ThirdClass > > Consider firstInstance of AnotherClass and secondInstance of ThirdClass. How can I make the two instances behave like one, Messages sent to secondInstance and implemented in ThirdClass are fine but all others get redirect to firstInstance as if "super" the keyword were a pointer to firstInstance. > > This would make it seem, temporarily that ThirdClass inherits from AnotherClass and the two instances are glued together. Closest I could find is https://en.m.wikipedia.org/wiki/Object_slicing > > OR > > Even more complicated. Can I hack the "super" keyword directly via Javascript somewhere so that certain Instances see other Instances as their "super". > > PS. Instances don't need to actually be merged, communication is one way and when the instance that super was pointing to is gone I would like it to revert to normal functionality. > > Pe 17 sept. 2015, la 18:42, Herby Vojčík<[hidden email]> a scris: > >> ??? >> >> An instance of A always _is_ an instance of its subclass B (with a few exceptions like {A=Object, B=String} and similar ones). Eh, of course not, I mixed some things in my head. >> >> E.g. did I misunderstood something in the question? >> >> Herby >> >> Mircea Samoilă wrote: >>> Is it possible to convert an instance to one of it's subclasses temporarely at runtime? >> -- >> You received this message because you are subscribed to the Google Groups "amber-lang" group. >> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. >> For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Seems like a strange use case...perhaps a case for using DNU (#doesNotUnderstand: ) Say in ThirdClass: On Thu, Sep 17, 2015, 5:26 PM Herby Vojčík <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |